/* CSS Variables for Theming */
:root {
    --sidebar-width: 60px;
    --sidebar-width-expanded: 500px;
}

[data-theme="light"] {
    /* Light Theme (Default) */
    --primary-bg: rgb(248,249,250);
    --sidebar-bg: rgb(255,255,255);
    --sidebar-shadow: rgba(0, 0, 0, 0.1);
    --text-primary: rgb(51,51,51);
    --text-secondary: rgb(102,102,102);
    --accent-color: rgb(0,123,255);
    --hover-bg: rgb(240,240,240);
    --border-color: rgb(233,236,239);
    --hamburger-color: rgb(51,51,51);
    --sidebar-icon-strip-bg: var(--border-color); /* For the 60px icon bar */
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-bg: rgb(26,26,26);
    --sidebar-bg: rgb(45,45,45);
    --sidebar-shadow: rgba(0, 0, 0, 0.3);
    --text-primary: rgb(255,255,255);
    --text-secondary: rgb(204,204,204);
    --accent-color: rgb(77,171,247);
    --hover-bg: rgb(64,64,64);
    --border-color: rgb(64,64,64);
    --hamburger-color: rgb(255,255,255);
    --sidebar-icon-strip-bg: rgb(32,32,32); /* Darker strip for icon bar */
}

/* Blue Theme */
[data-theme="ocean"] {
    --primary-bg: rgb(227,242,253);
    --sidebar-bg: rgb(25,118,210);
    --sidebar-shadow: rgba(25, 118, 210, 0.3);
    --text-primary: rgb(255,255,255);
    --text-secondary: rgb(187,222,251);
    --accent-color: rgb(255,255,255);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --border-color: rgb(21,101,192);
    --hamburger-color: rgb(255,255,255);
    --sidebar-icon-strip-bg: var(--border-color); /* For the 60px icon bar */
}

/* Purple Theme */
[data-theme="fantasy"] {
    --primary-bg: rgb(243,229,245);
    --sidebar-bg: rgb(123,31,162);
    --sidebar-shadow: rgba(123, 31, 162, 0.3);
    --text-primary: rgb(255,255,255);
    --text-secondary: rgb(225,190,231);
    --accent-color: rgb(255,255,255);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --border-color: rgb(106,27,154);
    --hamburger-color: rgb(255,255,255);
    --sidebar-icon-strip-bg: var(--border-color); /* For the 60px icon bar */
}

/* Blue Theme */
[data-theme="bluejays"] {
    --primary-bg: rgb(227,242,253);
    --sidebar-bg: rgb(25,118,210);
    --sidebar-shadow: rgba(25, 118, 210, 0.3);
    --text-primary: rgb(255,255,255);
    --text-secondary: rgb(187,222,251);
    --accent-color: rgb(255,255,255);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --border-color: rgb(21,101,192);
    --hamburger-color: rgb(255,255,255);
    --sidebar-icon-strip-bg: var(--border-color); /* For the 60px icon bar */
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--sidebar-icon-strip-bg); /* Base background for collapsed state */
    box-shadow: 3px 0px 9px 2px var(--sidebar-shadow);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* z-index: 5; */
    display: flex; /* Added for vertical layout of children */
    flex-direction: column; /* Added for vertical layout of children */
}

.sidebar.expanded {
    width: var(--sidebar-width-expanded);
    background: linear-gradient(to right, var(--sidebar-icon-strip-bg) 60px, var(--sidebar-bg) 60px); /* New background for expanded state */
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: 60px;
    flex-shrink: 0; /* Prevent header from shrinking in flex layout */
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 20px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    width: var(--sidebar-width);
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-toggle-btn:hover {
    background-color: var(--hover-bg);
}

/* Hamburger Icon Animation */
.sidebar-hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    cursor: pointer;
}

.sidebar-hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background-color: var(--hamburger-color);
    border-radius: 1px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-hamburger span:nth-child(1) {
    top: 0px;
}

.sidebar-hamburger span:nth-child(2) {
    top: 8px;
}

.sidebar-hamburger span:nth-child(3) {
    top: 16px;
}

/* Hamburger to X Animation */
.sidebar.expanded .sidebar-hamburger span:nth-child(1) {
    top: 8px;
    transform: rotate(135deg);
}

.sidebar.expanded .sidebar-hamburger span:nth-child(2) {
    opacity: 0;
}

.sidebar.expanded .sidebar-hamburger span:nth-child(3) {
    top: 8px;
    transform: rotate(-135deg);
}

/* Sidebar Title */
.sidebar-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 16px;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-title {
    opacity: 1;
    transform: translateX(0);
}

/* Navigation Styles */
.sidebar-nav {
    padding-top: 20px; /* Maintain vertical padding */
    padding-bottom: 20px; /* Maintain vertical padding */
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent nav from shrinking if content area is large */
}

.sidebar-nav-list {
    list-style: none;
}

.sidebar-nav-list-bottom {
    bottom: 0px;
    position: fixed;
}

.sidebar-nav-item {
    padding-top: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.sidebar-nav-link {
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 5px 0 0 5px;
    margin: 0 0 0 2px;
}

.sidebar-nav-link:hover {
    background-color: var(--primary-bg);
    color: var(--accent-color);
    transform: translateX(5px);
}

.sidebar-nav-link.active {
    background-color: var(--primary-bg);
    color: var(--text-primary);
    transform: translateX(0);
    z-index: 1;
    margin-left: 6px;
    padding: 12px 8px 12px 22px;
}

.sidebar.expanded .sidebar-nav-link.active {
    background-color: var(--sidebar-bg); /* Match the wide part of the nav */
    color: var(--text-primary); /* Ensure text is readable against the new background */
    padding-right: 0; /* Set right padding to 0 */
}

.sidebar.expanded .sidebar-nav-link:hover {
    background-color: var(--sidebar-bg);
    color: var(--accent-color);
}

.sidebar-nav-icon {
    font-size: 20px;
    min-width: 40px;
    display: flex;
    justify-content: center;
    transition: transform 0.2s ease;
}

.sidebar-nav-link:hover .sidebar-nav-icon {
    transform: scale(1.1);
}

.sidebar-main-content {
    color: var(--text-secondary);
    margin-left: var(--sidebar-width); /* Always account for collapsed sidebar width */
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    position: relative;
    width: calc(100% - var(--sidebar-width)); /* Subtract sidebar width from total width */
    min-width: 0; /* Allow shrinking below content size - fixes minimum width issue */
    overflow: hidden; /* Prevent horizontal overflow */
    display: flex;
    flex-direction: column;
}

.sidebar-main-content::after {
    content: '';
    border: 1px solid var(--sidebar-icon-strip-bg);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: 0px;
    height: 100vh;
    background-color: #000;
    z-index: 5;
    box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.3);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded ~ .sidebar-main-content::after {
    left: var(--sidebar-width-expanded);
}

/* For screens larger than 1400px, sidebar pushes content */
@media (min-width: 1401px) {
    .sidebar-main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    
    .sidebar.expanded ~ .sidebar-main-content {
        margin-left: var(--sidebar-width-expanded);
        width: calc(100% - var(--sidebar-width-expanded)); /* Adjust width when sidebar expanded */
    }
}

/* Theme Controls */
.sidebar-theme-controls {
    background-color: var(--sidebar-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--sidebar-shadow);
    margin-top: 30px;
}

.sidebar-theme-controls h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.sidebar-theme-controls button {
    background-color: var(--accent-color);
    color: var(--sidebar-bg);
    border: none;
    padding: 10px 16px;
    margin: 5px 5px 5px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-theme-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-theme-controls button:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 1400px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(0);
    }
    
    .sidebar.expanded {
        width: var(--sidebar-width-expanded);
        transform: translateX(0);
    }
    
    /* Hide everything except toggle button when collapsed */
    .sidebar:not(.expanded) .sidebar-title,
    .sidebar:not(.expanded) .sidebar-nav {
        opacity: 0;
        pointer-events: none;
    }
    
    .sidebar-main-content {
        padding: 0; /* Remove padding to use full available space */
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    
    .sidebar.expanded ~ .sidebar-main-content {
        margin-left: var(--sidebar-width-expanded);
        width: calc(100% - var(--sidebar-width-expanded)); /* Properly account for expanded sidebar */
    }
    
    /* Overlay for mobile */
    .sidebar.expanded::after {
        content: '';
        position: fixed;
        top: 0;
        left: var(--sidebar-width-expanded);
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
} 

.sidebar-content-area {
    position: absolute;
    top: 0px;
    left: var(--sidebar-width);
    width: calc(var(--sidebar-width-expanded) - var(--sidebar-width));
    height: 100vh;
    background-color: var(--sidebar-bg); /* Add background to hide content behind the card */
    overflow: hidden;
    padding: 0px;
    /* padding-left: 8px; */
    pointer-events: none;   /* disable pointer events by default */
    
    /* Animation properties: start off-screen and invisible */
    opacity: 0;
    transform: translateX(-100%);
    transition: none; /* No transition by default for instant switching */
    z-index: 10; /* Ensure sidebar cards appear above the main workspace */
}

/* Add transition ONLY when sidebar is toggling */
body.sidebar-animating .sidebar-content-area {
    transition: 
        opacity 0.35s cubic-bezier(0.4,0,0.2,1),
        transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* Show and slide in the ACTIVE card when the sidebar is EXPANDED */
.sidebar.expanded ~ .sidebar-content-area.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Profile card styles */
.profile-card {
    padding: 2rem;
    background: var(--chat-bg-secondary);
    border-radius: 12px;
    margin: 1rem;
    border: 1px solid var(--chat-border);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.profile-info h3 {
    margin: 0 0 0.25rem 0;
    color: var(--chat-text-primary);
    font-size: 1.25rem;
}

.profile-info p {
    margin: 0;
    color: var(--chat-text-secondary);
    font-size: 0.9rem;
}

.profile-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.profile-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--chat-border);
    border-radius: 8px;
    background: var(--chat-bg-secondary);
    color: var(--chat-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.profile-btn:hover {
    background: var(--chat-hover);
    border-color: var(--chat-accent);
}

.profile-btn.sb-sign-out-btn {
    background: transparent;
    color: #dc3545;
    border-color: #dc3545;
}

.profile-btn.sb-sign-out-btn:hover {
    background: #dc3545;
    color: white;
}

