﻿/* ── VARIABLES ─────────────────────────────────── */
:root {
    --sidebar-w: 262px;
    --topbar-h: 52px;
    --transition: 0.27s cubic-bezier(.4,0,.2,1);

    /* Paleta navy del sidebar (sidebar-mejorado.css) */
    --sb-bg: #1b2340;
    --sb-text: #c7cbe0;
    --sb-text-strong: #ffffff;
    --sb-text-muted: #8b90ad;
    --sb-text-faint: #565b7a;
    --sb-hover: rgba(255, 255, 255, 0.06);
    --sb-active-bg: rgba(59, 91, 219, 0.25);
    --sb-active-border: #6c8cff;
    --sb-active-icon: #a9bcff;
    --sb-border: rgba(255, 255, 255, 0.1);
    --sb-badge-bg: #d94b4b;
}

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: var(--sb-bg);
    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;
    }

.brand-logo {
    height: 36px;
    width: auto;
    vertical-align: middle;
}

.brand-logo--sidebar {
    background: rgba(255,255,255,0.92);
    border-radius: 4px;
    padding: 3px;
}

.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: var(--sb-active-icon);
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 20px;
    color: var(--sb-text);
    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: var(--sb-hover);
        color: var(--sb-text-strong);
    }

    .sidebar-item:hover {
        padding-left: 24px;
    }

    .sidebar-item.active {
        background: var(--sb-active-bg);
        color: var(--sb-text-strong);
        border-left-color: var(--sb-active-border);
        font-weight: 600;
    }

    .sidebar-item i {
        font-size: 1rem;
        flex-shrink: 0;
        color: var(--sb-text-muted);
    }

    .sidebar-item.active i {
        color: var(--sb-active-icon);
    }

/* Badge de conteo (pendientes) al final de un item del sidebar */
.sidebar-item-badge {
    background: var(--sb-badge-bg);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
    padding: 1px 6px;
    flex: 0 0 auto;
    margin-left: auto;
}

    .sidebar-item:hover .sidebar-item-badge {
        margin-left: 6px;
    }

/* Grupo "Principal": siempre visible, sin acordeón (no usa .sidebar-section-toggle) */
.sidebar-flat-group {
    display: flex;
    flex-direction: column;
}

/* Buscador del menú */
.sidebar-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 7px 10px;
    margin: 10px 12px 4px;
}

.sidebar-search-icon {
    color: var(--sb-text-muted);
    font-size: 16px;
}

.sidebar-search-input {
    background: none;
    border: none;
    outline: none;
    color: var(--sb-text-strong);
    font-size: 13px;
    width: 100%;
}

    .sidebar-search-input::placeholder {
        color: var(--sb-text-muted);
    }

.sidebar-no-results {
    color: var(--sb-text-faint);
    font-size: 13px;
    padding: 10px 20px;
}

.sidebar-pin-btn {
    margin-left: auto;
    padding: 3px 5px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
}

    .sidebar-item:hover .sidebar-pin-btn {
        opacity: .55;
    }

    .sidebar-pin-btn:hover {
        opacity: 1 !important;
        background: rgba(255,255,255,0.15);
        color: #ffc107;
    }

    .sidebar-pin-btn.sidebar-pin-btn-cargando {
        opacity: 1;
        pointer-events: none;
    }

    .sidebar-pin-btn.sidebar-pin-btn-fijado {
        opacity: .85;
        color: #ffc107;
    }

/* 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: var(--sb-active-bg);
    color: var(--sb-active-icon);
    font-size: .67rem;
    padding: 1px 8px;
    border-radius: 20px;
    margin-top: 2px;
}

/* ── TOPBAR ──────────────────────────────────────── */
#topbar {
    position: sticky;
    top: 0;
    z-index: 9998;
    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);
}

/* ── DROPDOWN MENUS ──────────────────────────────── */
#topbar .dropdown-menu {
    z-index: 9999 !important;
}

.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: var(--sb-active-icon);
    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: var(--sb-text-strong);
    }

    .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;
    }
