﻿/* ── VARIABLES ─────────────────────────────────── */
:root {
    --sidebar-w: 262px;
    --topbar-h: 52px;
    --transition: 0.27s cubic-bezier(.4,0,.2,1);
}

body {
    overflow-x: hidden;
}

/* ── OVERLAY ────────────────────────────────────── */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

    #sidebar-overlay.show {
        display: block;
    }

/* ── SIDEBAR ────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, #1a1f36 0%, #2c3358 100%);
    color: #fff;
    z-index: 1050;
    transform: translateX(calc(-1 * var(--sidebar-w)));
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 28px rgba(0,0,0,0.22);
}

    #sidebar.open {
        transform: translateX(0);
    }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 700;
    font-size: .95rem;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

    .sidebar-brand:hover {
        color: #90caf9;
    }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.15);
        border-radius: 2px;
    }

.sidebar-section {
    padding: 8px 18px 2px;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: rgba(255,255,255,0.38);
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: .855rem;
    transition: background .14s, color .14s, padding-left .14s;
    border-left: 3px solid transparent;
}

    .sidebar-item:hover, .sidebar-item.active {
        background: rgba(255,255,255,0.08);
        color: #fff;
    }

    .sidebar-item:hover {
        padding-left: 24px;
    }

    .sidebar-item.active {
        background: rgba(144,202,249,0.14);
        color: #90caf9;
        border-left-color: #90caf9;
        font-weight: 600;
    }

    .sidebar-item i {
        font-size: 1rem;
        flex-shrink: 0;
    }

/* Sub-items con indentación */
.sidebar-subitem {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 20px 7px 38px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: .82rem;
    border-left: 3px solid transparent;
    transition: background .14s, color .14s;
}

    .sidebar-subitem:hover {
        background: rgba(255,255,255,0.06);
        color: #fff;
    }

    .sidebar-subitem.active {
        color: #90caf9;
        border-left-color: #90caf9;
    }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-user-name {
    font-weight: 600;
    color: #fff;
    font-size: .88rem;
}

.sidebar-user-role {
    display: inline-block;
    background: rgba(144,202,249,0.18);
    color: #90caf9;
    font-size: .67rem;
    padding: 1px 8px;
    border-radius: 20px;
    margin-top: 2px;
}

/* ── TOPBAR ──────────────────────────────────────── */
#topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.btn-hamburger {
    border: none;
    background: none;
    padding: 5px 7px;
    cursor: pointer;
    color: #334155;
    font-size: 1.25rem;
    border-radius: 6px;
    line-height: 1;
}

    .btn-hamburger:hover {
        background: #f1f5f9;
    }

#topbar .topbar-title {
    font-weight: 700;
    font-size: .95rem;
    color: #1e293b;
    text-decoration: none;
    white-space: nowrap;
}

    #topbar .topbar-title:hover {
        color: #1d4ed8;
    }

#topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bd-badge {
    font-size: .75rem;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 20px;
    padding: 3px 10px;
    font-weight: 600;
    white-space: nowrap;
}

.page-title-bar {
    font-size: .82rem;
    color: #64748b;
    border-left: 2px solid #e2e8f0;
    padding-left: 10px;
    margin-left: 4px;
    white-space: nowrap;
}

/* ── MAIN ────────────────────────────────────────── */
#layout-main {
    min-height: calc(100vh - var(--topbar-h));
}

/* ── SIDEBAR COLLAPSIBLE SECTIONS ───────────────── */
.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px 2px;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: rgba(255,255,255,0.38);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: color .15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

    .sidebar-section-toggle:hover {
        color: rgba(255,255,255,0.65);
    }

    .sidebar-section-toggle .toggle-icon {
        font-size: .7rem;
        transition: transform var(--transition);
    }

    .sidebar-section-toggle.collapsed .toggle-icon {
        transform: rotate(-90deg);
    }

.sidebar-group {
    overflow: hidden;
    transition: max-height var(--transition);
}

    .sidebar-group.collapsed {
        max-height: 0 !important;
    }
