/* ===== 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;
}

.nav-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 {
    transition: transform var(--transition);
}

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

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

.btn-back {
    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;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

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

/* ===== 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 {
        display: none;
    }
    
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .btn-back 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,
    [data-theme="light"] .sidebar.collapsed .btn-back 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,
    .sidebar.collapsed .btn-back: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 .btn-back {
        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;
    flex: 1;
}

.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;
    }
}
