/* ── Sidebar Layout ────────────────────────────────── */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: #0f172a;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
    font-size: 1.35rem;
    font-weight: 800;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-500);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-logo-icon svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* ── Nav Items ─────────────────────────────────────── */
.sidebar-nav {
    padding: 12px 10px;
    flex: 1;
}

.sidebar-nav-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 16px 10px 8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
    font-size: 0.8125rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.05);
    color: #e2e8f0;
}

.sidebar-item.active {
    background: rgba(99, 102, 241, 0.18);
    color: #c7d2fe;
    font-weight: 600;
    border-left: 3px solid #818cf8;
    padding-left: 9px;
    box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.08);
}

.sidebar-item-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-item-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.05);
    margin: 8px 10px;
}

/* ── Footer / User ───────────────────────────────── */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    position: relative;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.06);
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-500);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    flex: 1;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: #64748b;
}

.sidebar-user-chevron {
    color: #64748b;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.sidebar-user.open .sidebar-user-chevron {
    transform: rotate(180deg);
}

/* ── User Menu Dropdown ────────────────────────────── */
.sidebar-user-menu {
    display: none;
    position: absolute;
    bottom: 64px;
    left: 8px;
    right: 8px;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
    z-index: 10;
}

.sidebar-user-menu.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.sidebar-menu-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.sidebar-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}

.sidebar-menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 4px 0;
}

/* ── Mobile Toggle ─────────────────────────────────── */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 110;
    background: #0f172a;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

/* ── Main Content Area (sidebar-based layout) ──────── */
.main-wrapper {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 280px);
}

.main-layout {
    max-width: 1800px;
    padding: 2rem 2.5rem;
    width: 100%;
}

/* ── Animations ────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1024px) {
    .main-layout {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay.open {
        display: block;
    }

    .mobile-sidebar-toggle {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .main-layout {
        padding: 1rem;
        padding-top: 60px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 16px 18px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions .btn {
        width: 100%;
        justify-content: center;
    }
}
