/* =============================================
   NAV — Red de Salud Aguaytía
   Sidebar vertical · Blanco glass
   ============================================= */

:root {
    --nav-text: #374151;
    --nav-text-hover: #111827;
    --nav-accent: #1e3a5f;
    --nav-accent-light: #2563eb;
    --nav-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== Sidebar ===== */
.main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* ===== Logo ===== */
.sidebar-logo {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar-logo img {
    height: 40px;
    width: auto;
}

/* ===== Navegación ===== */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-nav > ul > li {
    margin: 0;
}

.sidebar-nav > ul > li > a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1.5rem;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--nav-text);
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}

.sidebar-nav > ul > li > a:hover {
    color: var(--nav-text-hover);
    background: rgba(0, 0, 0, 0.04);
}

.sidebar-nav > ul > li > a.active {
    color: var(--nav-accent);
    background: rgba(30, 58, 95, 0.08);
    font-weight: 600;
}

/* Icono */
.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

.sidebar-nav > ul > li > a:hover .nav-icon,
.sidebar-nav > ul > li > a.active .nav-icon {
    opacity: 1;
}

/* ===== Dropdown ===== */
.dropdown {
    position: relative;
}

.dropdown > a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    cursor: pointer;
}

/* Flecha */
.dropdown > a::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.3s;
    opacity: 0.5;
    margin-left: auto;
}

.dropdown.is-open > a::after {
    transform: rotate(225deg) translateY(1px);
}

/* ===== Submenu ===== */
.submenu {
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
    transition: max-height 0.3s var(--nav-ease);
}

.dropdown.is-open > .submenu {
    max-height: 500px;
}

.submenu li a {
    display: flex;
    align-items: center;
    padding: 0.55rem 1.5rem 0.55rem 3.5rem;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--nav-text);
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}

.submenu li a:hover {
    color: var(--nav-text-hover);
    background: rgba(0, 0, 0, 0.04);
}

/* =============================================
   Sesión (sidebar) — botones a juego con login.css
   ============================================= */

.sidebar-sesion {
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sesion-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-bottom: 0.6rem;
}

.sesion-nombre {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--nav-accent);
    line-height: 1.3;
}

.sesion-rol {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Botones */
.btn-sesion {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.btn-sesion .nav-icon {
    width: 15px;
    height: 15px;
    opacity: 1;
}

/* Entrar (sin sesión) */
.btn-entrar {
    background: linear-gradient(135deg, var(--nav-accent), var(--nav-accent-light));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.18);
}

.btn-entrar:hover {
    background: var(--nav-accent-light);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

/* Salir (con sesión) */
.btn-salir {
    background: #ffffff;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.btn-salir:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

/* ===== Contenido principal ===== */
.main-content {
    margin-left: 200px;
    min-height: 100vh;
}

/* ===== Acceso denegado (his-acceso) ===== */
.his-denegado {
    max-width: 640px;
    margin: 4rem auto;
    padding: 2rem 2.2rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-left: 4px solid #b91c1c;
    border-radius: 14px;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    box-sizing: border-box;
}

.his-denegado h1 {
    margin: 0 0 0.6rem;
    font-size: 1.3rem;
    color: #b91c1c;
}

.his-denegado p {
    margin: 0 0 1rem;
    font-size: 0.92rem;
    color: #374151;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.his-volver {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    background: #1e3a5f;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    /* Barra superior movil */
    .nav-mobile-header {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        position: sticky;
        top: 0;
        z-index: 900;
        height: 56px;
        padding: 0 0.9rem;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-mobile-logo-link {
        display: inline-flex;
        align-items: center;
    }

    .nav-mobile-logo {
        height: 34px;
        width: auto;
        max-width: 70vw;
        object-fit: contain;
    }

    /* Hamburguesa */
    .nav-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-right: 0.2rem;
        padding: 0;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--nav-accent);
        cursor: pointer;
        flex-shrink: 0;
    }

    .nav-hamburger:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .nav-hamburger svg {
        width: 24px;
        height: 24px;
    }

    /* Sidebar como drawer deslizante */
    .main-sidebar {
        width: 260px;
        max-width: 82vw;
        transform: translateX(-105%);
        transition: transform 0.3s var(--nav-ease);
        box-shadow: none;
    }

    body.nav-abierto .main-sidebar {
        transform: translateX(0);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
    }

    /* Overlay oscuro de fondo */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 990;
    }

    body.nav-abierto .nav-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-abierto {
        overflow: hidden;
    }
}

/* La barra y el overlay no existen en escritorio */
@media (min-width: 769px) {
    .nav-mobile-header,
    .nav-overlay {
        display: none;
    }
}
