@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════════════════════════════
   1. VARIABLES
   ══════════════════════════════════════════════════════════════ */
:root {
    --topbar-height: 52px;
    --ribbon-height: 24px;
    --sidebar-width: 220px;
    --sidebar-collapsed: 60px;
    /* — Navy / Sidebar — Gris oscuro brillante */
    --navy-950: #1a1a1a;
    --navy-900: #2d2d2d;
    --navy-800: #323232; /* sidebar base */
    --navy-700: #404040;
    --navy-600: #4a4a4a;
    --navy-500: #1650b8;
    --navy-400: #2f74e0;
    --navy-300: #6fa2ef;
    --navy-200: #aecdf7;
    --navy-100: #dcebfd;
    --navy-50: #f0f7ff;
    /* — Azul Topbar (#032263 - Azul marino oscuro con brillo) — */
    --topbar-from: #032263;
    --topbar-to: #0d3fa8;
    /* — Acento (azul eléctrico para activos) — */
    --accent-600: #0a5ce0;
    --accent-500: #1e78f5;
    --accent-400: #4c9bfa;
    --accent-300: #8bc0fc;
    --accent-200: #c6e0fd;
    /* — Dorado sutil para detalles — */
    --gold-500: #c9943a;
    --gold-400: #dba94f;
    --gold-300: #f0c875;
    /* — Grises neutros — */
    --gray-900: #1a1a2e;
    --gray-700: #3f3f5a;
    --gray-600: #6b6b88;
    --gray-500: #8e8ea8;
    --gray-400: #b0b0c8;
    --gray-300: #d0d0e0;
    --gray-200: #e8e8f0;
    --gray-100: #f4f4f8;
    --gray-50: #fafafa;
    --white: #ffffff;
    --off-white: #f5f8fd;
    /* — Semánticos — */
    --danger-text: #fca5a5;
    --danger-bg: rgba(220, 38, 38, 0.12);
    --danger-hover: rgba(220, 38, 38, 0.22);
    /* — Ease — */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    /* — Sombras — */
    --shadow-topbar: 0 2px 18px rgba(3, 34, 99, 0.5), 0 1px 4px rgba(0,0,0,0.3);
    --shadow-sidebar: 2px 0 18px rgba(0,0,0,0.35);
}

/* ══════════════════════════════════════════════════════════════
   2. RESET Y BASE
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cascadia Code', 'Cascadia Mono', 'JetBrains Mono', 'Fira Code', 'Inter', system-ui, sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════════════
   3. RIBBON
   ══════════════════════════════════════════════════════════════ */
.gov-ribbon {
    flex-shrink: 0;
    height: var(--ribbon-height);
    background: var(--navy-950);
    border-bottom: 1px solid rgba(80, 140, 240, 0.25);
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1100;
}

    .gov-ribbon::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(90deg, var(--accent-500) 0%, var(--accent-300) 50%, transparent 100%);
    }

.gov-ribbon-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    width: 100%;
}

.gov-ribbon-flag {
    display: none;
}

.gov-ribbon-text {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--navy-300);
}

/* ══════════════════════════════════════════════════════════════
   4. TOPBAR — Azul vivo, mayor contraste
   ══════════════════════════════════════════════════════════════ */
.topbar {
    flex-shrink: 0;
    height: var(--topbar-height);
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 0 12px;
    background: linear-gradient(135deg, var(--topbar-from) 0%, var(--topbar-to) 100%);
    box-shadow: var(--shadow-topbar);
}

    .topbar::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, var(--accent-400) 0%, var(--accent-300) 50%, transparent 100%);
        pointer-events: none;
    }

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 7px;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    transition: background 0.2s var(--ease), transform 0.2s var(--ease-spring);
}

    .btn-sidebar-toggle:hover {
        background: rgba(255,255,255,0.22);
        transform: scale(1.05);
    }

    .btn-sidebar-toggle:active {
        transform: scale(0.95);
    }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.brand-shield {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--accent-300);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

    .brand-text .brand-name {
        font-size: 13px;
        font-weight: 700;
        color: #ffffff;
        letter-spacing: 0.2px;
        white-space: nowrap;
    }

    .brand-text .brand-sub {
        font-size: 10px;
        color: rgba(255,255,255,0.6);
        font-weight: 400;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* Reloj */
.topbar-clock {
    font-family: 'Cascadia Mono', 'JetBrains Mono', monospace;
    font-size: 11.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
    background: rgba(0,0,0,0.18);
    padding: 3px 9px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.14);
    min-width: 64px;
    text-align: center;
}

/* User chip */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 50px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    transition: background 0.2s var(--ease);
    cursor: default;
}

    .user-chip:hover {
        background: rgba(255,255,255,0.18);
    }

.user-chip--guest {
    opacity: 0.7;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-500), var(--gold-500));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-chip .user-name {
    font-size: 11.5px;
    font-weight: 600;
    color: white;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip .user-role {
    font-size: 9px;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74,222,128,0.25);
    animation: pulse-dot 2.2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(74,222,128,0.05);
    }
}

/* ══════════════════════════════════════════════════════════════
   5. MAIN WRAPPER
   ══════════════════════════════════════════════════════════════ */
.main-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   6. SIDEBAR — Azul marino más profundo y saturado
   ══════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100%;
    background: var(--navy-800);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-sidebar);
    transition: width 0.28s var(--ease), min-width 0.28s var(--ease);
}

    /* Línea acento derecha */
    .sidebar::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 1.5px;
        background: linear-gradient(180deg, var(--accent-500) 0%, var(--accent-400) 40%, var(--navy-600) 100%);
        pointer-events: none;
    }

    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
        min-width: var(--sidebar-collapsed);
    }

/* Header del sidebar */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 14px 12px 11px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-400));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
    color: white;
    box-shadow: 0 3px 12px rgba(10, 92, 224, 0.5);
}

.sidebar-title {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s var(--ease);
}

    .sidebar-title .s-title {
        font-size: 12.5px;
        font-weight: 700;
        color: #fff;
    }

    .sidebar-title .s-sub {
        font-size: 9.5px;
        font-weight: 400;
        color: var(--navy-300);
    }

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    pointer-events: none;
}

/* Badge MINSA */
.sidebar-minsa-badge {
    padding: 5px 9px;
    overflow: hidden;
    transition: opacity 0.2s var(--ease);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar.collapsed .sidebar-minsa-badge {
    opacity: 0;
    pointer-events: none;
}

.minsa-badge-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(80, 140, 240, 0.14);
    border: 1px solid rgba(80, 140, 240, 0.28);
    border-radius: 5px;
    padding: 3px 7px;
}

.minsa-flag-mini {
    display: none;
}

.minsa-badge-inner > span {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--navy-300);
    white-space: nowrap;
}

/* ── Navegación ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 7px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 3px;
    }

    .sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.1);
        border-radius: 2px;
    }

/* Etiqueta de sección */
.sidebar-section-label {
    display: block;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--navy-400);
    padding: 10px 10px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s var(--ease);
    user-select: none;
}

.sidebar.collapsed .sidebar-section-label {
    opacity: 0;
    pointer-events: none;
}

.sidebar-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Nav items */
.nav-item a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px;
    border-radius: 7px;
    color: var(--navy-200);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

/* Ícono */
.nav-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: background 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s var(--ease);
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Hover */
.nav-item a:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}

    .nav-item a:hover .nav-icon {
        background: rgba(80, 140, 240, 0.22);
        color: var(--accent-300);
    }

/* Activo — más contraste y saturación */
.nav-item a.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(30, 120, 245, 0.4) 0%, rgba(30, 120, 245, 0.14) 100%);
    box-shadow: inset 0 0 0 1px rgba(80, 140, 240, 0.35);
}

    .nav-item a.active .nav-icon {
        background: var(--accent-600);
        color: #ffffff;
        box-shadow: 0 3px 12px rgba(10, 92, 224, 0.5);
    }

    .nav-item a.active::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 55%;
        border-radius: 0 3px 3px 0;
        background: linear-gradient(180deg, var(--accent-400), var(--accent-300));
    }

/* Peligro (logout) */
.nav-item--danger a {
    color: var(--danger-text);
}

    .nav-item--danger a .nav-icon {
        background: var(--danger-bg);
        color: #f87171;
    }

    .nav-item--danger a:hover {
        background: var(--danger-hover);
        color: #fca5a5;
    }

        .nav-item--danger a:hover .nav-icon {
            background: rgba(220,38,38,0.25);
            color: #fca5a5;
        }

/* Divisor */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 6px 4px;
    border-radius: 1px;
}

/* Footer */
.sidebar-footer {
    padding: 7px 9px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}

.sidebar-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.2s var(--ease);
}

.sidebar.collapsed .sidebar-footer-inner {
    opacity: 0;
}

.sidebar-version {
    font-family: 'Cascadia Mono', 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--navy-400);
    text-align: center;
    white-space: nowrap;
    letter-spacing: 0.4px;
}

/* ══════════════════════════════════════════════════════════════
       7. CONTENIDO PRINCIPAL
       ══════════════════════════════════════════════════════════════ */
main.content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--off-white);
    background-image: radial-gradient(circle at 100% 0%, rgba(20,90,220,0.05) 0%, transparent 50%), radial-gradient(circle at 0% 100%, rgba(10,92,224,0.035) 0%, transparent 50%);
}

/* ══════════════════════════════════════════════════════════════
       8. TOOLTIP SIDEBAR (modo colapsado)
       ══════════════════════════════════════════════════════════════ */
.sidebar-tooltip {
    position: fixed;
    z-index: 9000;
    background: var(--navy-700);
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 500;
    font-family: Calibri, sans-serif;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid rgba(80,140,240,0.3);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%) translateX(-4px);
    transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
    white-space: nowrap;
}

    .sidebar-tooltip::before {
        content: '';
        position: absolute;
        right: 100%;
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-right-color: var(--navy-700);
    }

    .sidebar-tooltip.visible {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }

/* ══════════════════════════════════════════════════════════════
       9. SCROLLBARS GLOBALES
       ══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--gray-400);
    }

/* ══════════════════════════════════════════════════════════════
       10. UTILIDADES
       ══════════════════════════════════════════════════════════════ */
.minsa-card {
    background: var(--white);
    border-radius: 10px;
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

.minsa-section-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--navy-50), var(--white));
}

    .minsa-section-header::before {
        content: '';
        width: 3px;
        height: 18px;
        border-radius: 2px;
        background: linear-gradient(180deg, var(--accent-600), var(--accent-300));
        flex-shrink: 0;
    }

.minsa-section-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--navy-800);
    letter-spacing: 0.2px;
}

.btn-minsa {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: white;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s var(--ease-spring);
    box-shadow: 0 2px 10px rgba(10,92,224,0.35);
}

    .btn-minsa:hover {
        background: linear-gradient(135deg, var(--accent-500), var(--accent-400));
        box-shadow: 0 4px 16px rgba(10,92,224,0.45);
        transform: translateY(-1px);
        color: white;
        text-decoration: none;
    }

/* ══════════════════════════════════════════════════════════════
       11. RESPONSIVE
       ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 999;
        box-shadow: 4px 0 22px rgba(0,0,0,0.35);
    }

        .sidebar.collapsed {
            transform: translateX(calc(-1 * var(--sidebar-width)));
            width: var(--sidebar-width);
            min-width: var(--sidebar-width);
        }

    .topbar-clock {
        display: none;
    }

    .brand-text .brand-sub {
        display: none;
    }

    main.content {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .gov-ribbon-text {
        display: none;
    }

    .user-info .user-role {
        display: none;
    }
}
