/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--bg-card-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.4s ease, border-color 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--bg-card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-close-btn {
    color: var(--text-secondary);
    transition: all var(--transition);
}

.sidebar-close-btn:hover {
    background: var(--bg-card-border);
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .sidebar .nav-item {
    color: #334155;
}

.nav-item[hidden],
.settings-menu-item[hidden] {
    display: none !important;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
    transform: scaleY(0);
    transition: transform var(--transition);
    opacity: 0;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-hover);
}

[data-theme="light"] .nav-item.active {
    background: rgba(99, 102, 241, 0.18);
}

.nav-item.active::before {
    transform: scaleY(1);
    opacity: 1;
}

.nav-item svg {
    flex: 0 0 auto;
    transition: transform var(--transition);
}

.nav-item:hover svg,
.nav-item.active svg {
    transform: scale(1.15) rotate(-5deg);
}

.nav-item span:not(.nav-badge) {
    min-width: 0;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    margin-left: auto;
    padding: 0 0.45rem;
    border: 1px solid rgba(248, 113, 113, 0.28);
    border-radius: 999px;
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
}

.nav-badge[hidden],
.topbar-request-badge[hidden] {
    display: none !important;
}

[data-theme="light"] .nav-badge {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--bg-card-border);
}

.btn-settings {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.btn-settings:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-chevron {
    margin-left: auto;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.settings-dropdown.open .settings-chevron {
    transform: rotate(180deg);
}

/* Settings Dropdown Menu */
.settings-dropdown {
    position: relative;
}

.settings-menu {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    min-width: 100%;
    width: max-content;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    padding: 0.5rem;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom center;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

[data-theme="light"] .settings-menu {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

.settings-dropdown.open .settings-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
    width: 100%;
    margin-bottom: 0.15rem;
}

.settings-menu-item:last-child {
    margin-bottom: 0;
}

.settings-menu-item:hover {
    background: var(--bg-hover);
    padding-left: 1.1rem;
}

.settings-menu-item--danger {
    color: var(--error);
}

.settings-menu-item--danger:hover {
    background: rgba(248, 113, 113, 0.1);
    padding-left: 1.1rem;
}

.settings-menu-divider {
    height: 1px;
    background: var(--bg-card-border);
    margin: 0.25rem 0.5rem;
}

/* ===== Main ===== */
.main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Desktop Collapse State */
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 74px;
    }
    
    .sidebar.collapsed .logo span,
    .sidebar.collapsed .settings-chevron {
        display: none;
    }
    
    .sidebar.collapsed .nav-item span:not(.nav-badge),
    .sidebar.collapsed .btn-settings span {
        position: absolute;
        left: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%) translateX(-10px);
        background: rgba(10, 10, 15, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        color: var(--text-primary);
        padding: 0.5rem 0.8rem;
        border-radius: var(--radius-sm);
        border: 1px solid var(--bg-card-border);
        font-size: 0.85rem;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    [data-theme="light"] .sidebar.collapsed .nav-item span:not(.nav-badge),
    [data-theme="light"] .sidebar.collapsed .btn-settings span {
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .sidebar.collapsed .nav-item:hover span:not(.nav-badge),
    .sidebar.collapsed .btn-settings:hover span {
        opacity: 1;
        visibility: visible;
        transform: translateY(-50%) translateX(0);
    }
    
    .sidebar.collapsed .sidebar-close-btn {
        transform: rotate(180deg);
    }
    
    .sidebar.collapsed .logo {
        justify-content: center;
        padding: 0;
    }
    
    .sidebar.collapsed .nav-item {
        justify-content: center;
        padding: 0.75rem 0;
        overflow: visible;
    }

    .sidebar.collapsed .nav-badge {
        position: absolute;
        top: 0.35rem;
        right: 0.35rem;
        min-width: 18px;
        height: 18px;
        padding: 0 0.3rem;
        font-size: 0.65rem;
    }
    
    .sidebar.collapsed .btn-settings {
        justify-content: center;
        padding: 0.65rem 0;
    }
    
    .sidebar.collapsed .sidebar-header {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.25rem 0;
    }
    
    .main.sidebar-collapsed {
        margin-left: 74px;
    }
    
    .main.sidebar-collapsed .menu-toggle {
        display: none;
    }
}

.topbar {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--bg-card-border);
    transition: border-color 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.topbar-request-badge {
    min-height: 30px;
    padding: 0 0.75rem;
    border: 1px solid rgba(248, 113, 113, 0.26);
    border-radius: 999px;
    background: rgba(248, 113, 113, 0.13);
    color: #fecaca;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.topbar-request-badge:hover {
    transform: translateY(-1px);
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.42);
}

[data-theme="light"] .topbar-request-badge {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.content {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.2s ease;
}

/* ===== Mobile Menu Toggle ===== */
.menu-toggle {
    display: none;
    color: var(--text-primary);
    transition: background var(--transition);
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), visibility var(--transition);
}

/* ===== Responsive Mobile ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 1rem 1.25rem;
    }

    .content {
        padding: 1.25rem;
    }

    .menu-toggle,
    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}
.sidebar.collapsed .sidebar-section-title {
    display: none !important;
}

.sidebar-section-title {
    padding: 0.5rem 1.25rem 0.25rem;
    color: color-mix(in srgb, var(--text-secondary) 72%, transparent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

[data-theme="light"] .sidebar-section-title {
    color: #64748b !important;
}

.sidebar-section-divider {
    height: 1px;
    background: rgba(229, 231, 235, 0.1);
    margin: 0.5rem 1.5rem;
}

.sidebar.collapsed .sidebar-section-divider {
    margin: 0.5rem 0.5rem;
}
