/* --- SIDEBAR VARIABLES & BASE --- */
:root {
    --sidebar-bg: linear-gradient(180deg, #064e3b, #022c22);
    --sidebar-text: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --emerald: #0f766e;
    --sidebar-width: 260px;
    --sidebar-width-closed: 80px;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    height: 100vh;
    /* Full height */
}

/* HEADER */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    height: 40px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    white-space: nowrap;
    color: #fff;
    text-decoration: none;
}

.brand i {
    margin-right: 12px;
    font-size: 24px;
    min-width: 30px;
    text-align: center;
}

/* TOGGLE BUTTON (Desktop) */
.sidebar-header .toggle-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

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

/* MENU CONTAINER */
.sidebar-menu-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* BUTTONS SECTION */
.sidebar-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* GENERAL BUTTON STYLE */
.sidebar button {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    margin-bottom: 0;
    flex-shrink: 0;
    text-align: left;
}

.sidebar button i {
    font-size: 16px;
    min-width: 30px;
    text-align: center;
    margin-right: 10px;
    flex-shrink: 0;
    opacity: 0.9;
}

.sidebar button span {
    white-space: nowrap;
    opacity: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar button:hover {
    background: var(--sidebar-hover);
    color: white;
}

    /* SPECIFIC BUTTON STYLES (Primary Buttons) */
    #newChatButton,
    #mesinButton,
    #katalogButton,
    #textSearchButton,
    #listButton,
    #searchButton,
    #topicButton {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
    opacity: 1;
    /* Ensure consistent opacity */
    font-size: 14px;
    /* Ensure consistent font size */
}

/* Active State (JS applied) */
.sidebar button.active-page {
    background: var(--emerald) !important;
    border-color: var(--emerald) !important;
    color: white !important;
    opacity: 1 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* HISTORY SECTION */
.sidebar-history {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.history-header {
    color: #9ca3af;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 0 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

#sessionList {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding-bottom: 10px;
    flex-grow: 1;
}

/* SESSION ITEMS */
.session-item {
    position: relative;
}

.session-btn {
    padding: 10px 12px !important;
    padding-right: 35px !important;
    font-size: 13px !important;
    opacity: 0.8;
    background: transparent;
}

.session-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08) !important;
}

.session-options-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    justify-content: center !important;
    color: rgba(255, 255, 255, 0.4) !important;
}

.session-options-btn:hover {
    color: white !important;
    background: transparent !important;
}

/* DROPDOWN MENU */
.session-dropdown {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 6px;
    z-index: 9999;
    min-width: 160px;
    border: 1px solid #e5e7eb;
}

.session-dropdown button {
    color: #374151 !important;
    font-size: 14px !important;
    padding: 10px !important;
    border-radius: 6px;
    background: transparent;
}

.session-dropdown button:hover {
    background: #f3f4f6 !important;
    color: var(--emerald) !important;
}

.session-dropdown button i {
    color: inherit;
    width: 20px;
    margin-right: 10px;
}

/* COLLAPSED STATE (Desktop) */
.sidebar.closed {
    width: var(--sidebar-width-closed);
    padding: 20px 10px;
}

.sidebar.closed .brand span,
.sidebar.closed button span,
.sidebar.closed .history-header,
.sidebar.closed #sessionList {
    display: none;
}

.sidebar.closed .sidebar-header {
    justify-content: center;
}

.sidebar.closed .brand {
    display: none;
}

.sidebar.closed .toggle-btn {
    transform: rotate(180deg);
    margin: 0;
}

.sidebar.closed button {
    justify-content: center;
    padding: 12px;
}

.sidebar.closed button i {
    margin-right: 0;
    opacity: 1;
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-header .toggle-btn {
        display: none;
    }

    .sidebar-header {
        justify-content: flex-start;
    }
}
