/* Sidebar Component CSS */

/* Sidebar - GPU Accelerated & Ultra Smooth */
.sidebar {
    width: 280px;
    /* Fixed width */
    transform: translateX(-210px);
    /* Show 70px as collapsed */
    background-color: var(--sidebar-bg);
    /* Use rgba background from variable */
    /* Remove backdrop-filter during animation for FPS boost */
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--header-border);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    overflow: hidden;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    will-change: transform;
    visibility: visible;
    contain: strict;
    /* Isolate sidebar for paint optimization */
}

/* Re-apply blur only when NOT moving if desired, but for now let's keep it simple for speed */
.sidebar.active {
    transform: translateX(0);
}

/* Logo Styles */
.logo {
    position: absolute;
    left: 65px;
    top: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.logo span {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(90deg, #4b90ff 0%, #ff5546 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar.active .logo {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s 0.1s;
}

/* Hide text when collapsed */
.sidebar .text,
.sidebar .recent-title {
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar.active .text,
.sidebar.active .recent-title {
    display: block;
    opacity: 1;
}

.sidebar.active .recent-item,
.sidebar.active .bottom-item {
    padding: 10px 14px;
}

.sidebar:not(.active) .recent-item,
.sidebar:not(.active) .bottom-item,
.sidebar:not(.active) .new-chat-btn,
.sidebar:not(.active) .top-section .menu-icon {
    transform: translateX(210px);
    /* Shift content back to visible area when collapsed */
    margin-right: 0;
    justify-content: center;
}

.sidebar:not(.active) .recent-item .text,
.sidebar:not(.active) .bottom-item .text,
.sidebar:not(.active) .new-chat-btn span:not(.material-symbols-outlined) {
    opacity: 0;
    pointer-events: none;
}

.sidebar:not(.active) .new-chat-btn {
    width: 45px;
    height: 45px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}

.top-section .menu-icon {
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.top-section .menu-icon:hover {
    background-color: var(--hover-color);
}

.new-chat-btn {
    margin-top: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #ffffff;
    padding: 12px 18px;
    border-radius: 30px;
    cursor: pointer;
    color: #1f1f1f;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.new-chat-btn:hover {
    background-color: #f2f2f2;
    color: #000000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.recent-list {
    flex: 1;
    margin-top: 25px;
    color: var(--secondary-text);
    overflow-y: auto;
}

.recent-list::-webkit-scrollbar {
    width: 5px;
}

.recent-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
    visibility: hidden;
}

.recent-list:hover::-webkit-scrollbar-thumb {
    visibility: visible;
}

.recent-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-left: 14px;
    opacity: 0.8;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item:hover {
    background-color: var(--hover-color);
    color: var(--text-color);
}

.recent-item.active {
    background-color: rgba(168, 199, 250, 0.15);
    color: var(--accent-blue);
    font-weight: 600;
}

.bottom-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.bottom-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    color: var(--secondary-text);
    transition: background 0.2s;
}

.bottom-item:hover {
    background-color: var(--hover-color);
    color: var(--text-color);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Adjustments */
@media (max-width: 900px) {
    .sidebar {
        left: -280px !important;
        width: 280px !important;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
    }

    .sidebar.active {
        left: 0 !important;
    }
}

/* History Management Styles */
.recent-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 14px;
    margin-bottom: 12px;
}

.recent-list-header .recent-title {
    margin-bottom: 0;
}

#clear-all-sessions {
    color: var(--secondary-text);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.8;
}

.sidebar.active #clear-all-sessions {
    opacity: 0.6;
}

#clear-all-sessions:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ff5546;
    opacity: 1 !important;
}

.sidebar.active .recent-item {
    position: relative;
    padding-right: 40px !important;
    /* Make room for 3 dots */
}

.sidebar.active .session-options-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    opacity: 0.4;
    transition: all 0.2s;
    z-index: 2;
}

.session-options-btn {
    display: none;
}

.recent-item:hover .session-options-btn {
    opacity: 1;
}

.session-options-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

/* Session Dropdown Menu */
.session-menu {
    position: fixed;
    background: #1e1f20;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    min-width: 140px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10002;
    display: none;
}

.session-menu.active {
    display: block;
}

.session-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-color);
    transition: background 0.2s;
}

.session-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.session-menu-item.delete {
    color: #ff5546;
}

.session-menu-item.delete:hover {
    background: rgba(255, 85, 70, 0.1);
}

/* Hide recent header when collapsed */
.sidebar:not(.active) .recent-list-header {
    display: none;
}

/* Ensure icons are a consistent size */
.recent-item span.material-symbols-outlined {
    font-size: 20px;
}

/* Fix active indicator in collapsed state */
.sidebar:not(.active) .recent-item.active {
    background-color: rgba(168, 199, 250, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 5px;
}