/* ==========================================================
   Sidebar Component Styles
   Extracted from style.css — used by components/sidebar.html
   ========================================================== */

/* ── Layout wrapper ─────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width, 256px);
    background: var(--bg-sidebar, #1e293b);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform .3s
}

/* ── Header ─────────────────────────────────────────────── */
.sidebar-header {
    height: 60px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05)
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem
}

.sidebar-brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: #fff
}

.sidebar-brand-text span {
    color: var(--warning)
}

/* ── Body / Scrollable nav area ─────────────────────────── */
.sidebar-body {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto
}

/* ── Nav group titles ───────────────────────────────────── */
.nav-title {
    padding: .5rem 1rem;
    font-size: .65rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em
}

/* ── Nav list ───────────────────────────────────────────── */
.nav-menu {
    list-style: none
}

.nav-item {
    margin: 2px .5rem
}

/* ── Nav links ──────────────────────────────────────────── */
.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .15s
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff
}

.nav-link.active {
    background: rgba(79, 70, 229, 0.2);
    color: #fff
}

.nav-link svg,
.nav-icon {
    width: 20px;
    height: 20px;
    opacity: .7;
    flex-shrink: 0;
    text-align: center;
    font-size: 1.1rem;
    line-height: 20px;
}

.nav-link:hover svg,
.nav-link:hover .nav-icon,
.nav-link.active svg,
.nav-link.active .nav-icon {
    opacity: 1
}

.nav-text {
    flex: 1
}

/* ── Badge (count pill on nav items) ───────────────────── */
.nav-badge {
    background: var(--primary);
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px
}

.nav-badge.green {
    background: var(--success)
}

/* ── Footer (user card + logout) ────────────────────────── */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05)
}

.user-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius)
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: .8rem
}

.user-name {
    color: #fff;
    font-size: .875rem;
    font-weight: 600
}

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

/* ── Logout button (inside sidebar footer) ──────────────── */
.logout-btn {
    display: flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem .875rem;
    background: var(--danger-bg, rgba(239, 68, 68, 0.1));
    color: var(--danger);
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    margin-top: .5rem;
    justify-content: center
}

.logout-btn:hover {
    background: var(--danger);
    color: #fff
}

.logout-btn svg {
    width: 16px;
    height: 16px
}

/* ── Mobile overlay (behind sidebar on small screens) ───── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99
}

.overlay.active {
    display: block
}

/* ── Mobile: sidebar slides in from left ────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

/* ── Desktop: sidebar can be toggled closed ────────────────── */
@media (min-width: 769px) {
    .sidebar.closed {
        transform: translateX(-100%);
    }
}

/* ==========================================================
   Admin Grid Layout Override
   When used inside the admin dashboard-container grid, 
   the sidebar should stick inside its column instead of floating.
   ========================================================== */
.dashboard-container .sidebar {
    position: sticky;
    width: 100%;
    height: 100vh;
    top: 0;
}

/* ==========================================================
   Unified Layout Wrapper (.app and .main)
   ========================================================== */
.app {
    display: none;
    min-height: 100vh;
}

.app.active {
    display: flex;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width, 256px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--mat-background, #f8fafc);
    transition: margin-left 0.3s ease;
}

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

@media (max-width: 768px) {
    .main {
        margin-left: 0;
    }
}
