/* sidebar.css */

/*
 * This file contains the styles for the ChatGPT-style sidebar.
 * It is responsible for the layout, appearance, and responsiveness of the sidebar.
 */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #f0f2f5;
    margin: 0;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #d4e1f5 0%, #c5d5ed 100%); /* Darker blue gradient */
    color: #1a202c; /* Dark text on light background */
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    border-right: 1px solid #a8bdd9; /* Darker blue border to match */
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    transition: width 0.3s ease; /* Smooth transition for collapsing */
    z-index: 1001; /* Ensure sidebar is above other content */
}

.sidebar.collapsed {
    width: 60px; /* Collapsed width */
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 8px;
    position: relative;
    min-height: 48px;
}

.sidebar.collapsed .sidebar-header {
    padding: 8px;
}

/* Sidebar Toggle Button - Integrated into sidebar */
.sidebar-toggle-btn {
    background-color: transparent;
    color: #718096;
    border: none;
    padding: 8px;
    cursor: pointer;
    position: absolute;
    right: 8px;
    top: 8px;
    border-radius: 6px;
    z-index: 1002;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.sidebar-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.6);
    color: #1a202c;
    box-shadow: 0 2px 4px rgba(76, 81, 191, 0.1);
}

.sidebar.collapsed .sidebar-toggle-btn {
    right: 50%;
    transform: translateX(50%);
    top: 8px;
}

/* Chat History / Navigation */
.chat-history {
    list-style: none;
    padding: 8px 12px;
    margin: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar.collapsed .chat-history {
    padding: 8px;
}

.chat-history > li {
    margin-bottom: 0;
}

.chat-history a {
    color: #4a5568;
    text-decoration: none;
    padding: 12px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    gap: 12px;
    font-size: 0.9rem;
    position: relative;
}

.sidebar.collapsed .chat-history a {
    justify-content: center;
    padding: 12px;
}

.chat-history a i {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

.sidebar.collapsed .chat-history a span:not(.new-badge) {
    display: none;
}

.sidebar.collapsed .chat-history a .new-badge {
    display: none;
}

.chat-history a:hover {
    background-color: rgba(255, 255, 255, 0.6);
    color: #1a202c;
    box-shadow: 0 2px 4px rgba(76, 81, 191, 0.1);
}

.chat-history a.active {
    background-color: rgba(255, 255, 255, 0.8);
    color: #4c51bf;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(76, 81, 191, 0.15);
}

/* Premium Badge - Updated to match stockpicker gradient style */
.new-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Previous Stocks Section */
.previous-stocks-section {
    margin-top: 8px;
    border-top: 1px solid #a8bdd9;
    padding-top: 8px;
}

.previous-stocks-header {
    color: #4a5568;
    text-decoration: none;
    padding: 12px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    gap: 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.previous-stocks-header:hover {
    background-color: rgba(255, 255, 255, 0.6);
    color: #1a202c;
    box-shadow: 0 2px 4px rgba(76, 81, 191, 0.1);
}

.previous-stocks-header i.fa-clock {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

.previous-stocks-header i.fa-chevron-down {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.previous-stocks-header.collapsed i.fa-chevron-down {
    transform: rotate(-90deg);
}

.sidebar.collapsed .previous-stocks-header span:not(.fa-clock) {
    display: none;
}

.sidebar.collapsed .previous-stocks-header i.fa-chevron-down {
    display: none;
}

/* Previous Stocks List */
.previous-stocks-list {
    list-style: none;
    padding: 0 0 0 32px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
}

.previous-stocks-list.collapsed {
    display: none;
}

.sidebar.collapsed .previous-stocks-list {
    display: none;
}

.previous-stocks-list li {
    margin: 0;
}

.previous-stocks-list a {
    color: #718096;
    text-decoration: none;
    padding: 8px 12px;
    display: block;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.85rem;
}

.previous-stocks-list a:hover {
    background-color: rgba(255, 255, 255, 0.6);
    color: #1a202c;
    box-shadow: 0 2px 4px rgba(76, 81, 191, 0.1);
}

/* Main content adjustment */
.main-content-wrapper {
    margin-left: 260px; /* Adjust main content to make space for the fixed sidebar */
    flex-grow: 1;
    padding: 20px;
    transition: margin-left 0.3s ease; /* Smooth transition for content shift */
}

.main-content-wrapper.collapsed {
    margin-left: 60px; /* Adjust margin when sidebar is collapsed */
}

/* Footer adjustment - no need for sidebar adjustments since it's centered */

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%); /* Hide sidebar off-screen by default */
        transition: transform 0.3s ease;
        width: 260px;
        z-index: 2000;
    }

    .sidebar.mobile-open {
        transform: translateX(0); /* Show sidebar when open */
    }

    .sidebar.collapsed {
        transform: translateX(-100%); /* Keep hidden when collapsed on mobile */
        width: 260px;
    }

    .main-content-wrapper {
        margin-left: 0 !important; /* No margin on mobile */
    }

    .main-content-wrapper.collapsed {
        margin-left: 0 !important;
    }

    /* Mobile hamburger button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1500;
        background-color: #4c51bf;
        color: white;
        border: none;
        padding: 0.75rem;
        border-radius: 8px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .mobile-menu-toggle:hover {
        background-color: #3e449a;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Hide desktop toggle button on mobile */
    .sidebar-toggle-btn {
        display: none;
    }

    footer {
        left: 0 !important;
        padding: 1.5rem 1rem;
    }
}

/* Desktop: hide mobile menu toggle */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }
}
