/* Barra lateral (Components/Layout/NavMenu.razor). Hoja global (los .razor.css no se cargan).
   Fondo azul de siempre (gris azulado en la edición salud); ítems con prefijo nv-. */

/* ── Overlay del menú en el celular ─────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 9998;
}
.sidebar-overlay.show { display: block; }

/* ── Barra ─────────────────────────────────────────────────────────────── */
.sidebar {
    --nv-fondo: #23548f;
    --nv-hover: rgba(255, 255, 255, .09);
    --nv-activo: rgba(255, 255, 255, .17);
    --nv-texto: rgba(255, 255, 255, .82);
    --nv-tenue: rgba(255, 255, 255, .55);
    --nv-linea: rgba(255, 255, 255, .12);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    background: var(--nv-fondo);
    box-shadow: 2px 0 10px rgba(0, 0, 0, .15);
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 9999;
    transition: width .25s ease, transform .25s ease;
    color: #fff;
}
.sidebar.sidebar-salud { --nv-fondo: #37474F; }
.sidebar.collapsed { width: 70px; }

/* ── Cabecera: logo y nombre ───────────────────────────────────────────── */
.nv-cab {
    position: relative;
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 1rem;
    flex-shrink: 0;
}
.nv-marca { display: flex; align-items: center; gap: .65rem; min-width: 0; color: #fff; text-decoration: none; }
.nv-marca:hover { color: #fff; }
.nv-logo {
    flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; color: var(--nv-fondo); font-weight: 800; font-size: .85rem; letter-spacing: -.02em;
}
.nv-nombre { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.sidebar.collapsed .nv-cab { justify-content: center; padding: 0; }
.sidebar.collapsed .nv-nombre { display: none; }

/* Botón redondo para compactar, a caballo del borde */
.toggle-btn {
    position: absolute;
    right: -13px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    cursor: pointer;
    z-index: 10001;
    transition: transform .15s ease, box-shadow .15s ease;
}
.toggle-btn:hover { background: #eff6ff; transform: translateY(-50%) scale(1.12); box-shadow: 0 4px 14px rgba(30, 58, 138, .25); }

/* ── Buscador "Buscar o ir a…" ─────────────────────────────────────────── */
.nv-buscar-zona { position: relative; padding: .25rem .75rem .5rem; flex-shrink: 0; }
.sidebar.collapsed .nv-buscar-zona { padding: .25rem .6rem .5rem; }
.nv-buscar { position: relative; display: flex; align-items: center; }
.nv-buscar > i { position: absolute; left: .75rem; color: var(--nv-tenue); font-size: .85rem; pointer-events: none; }
.nv-buscar-input {
    width: 100%; height: 38px; padding: 0 3.6rem 0 2.15rem;
    border: 1px solid var(--nv-linea); border-radius: 10px;
    background: rgba(255, 255, 255, .08); color: #fff; font-size: .86rem;
}
.nv-buscar-input::placeholder { color: var(--nv-tenue); }
.nv-buscar-input:focus { outline: none; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .35); }
.nv-buscar kbd {
    position: absolute; right: .5rem; padding: .1rem .35rem; border-radius: 5px;
    background: rgba(255, 255, 255, .12); color: var(--nv-tenue); font-size: .68rem; font-family: inherit; box-shadow: none;
}
.nv-resultados {
    position: absolute; left: .75rem; right: .75rem; top: calc(100% - .2rem); z-index: 10003;
    padding: .3rem; background: #fff; border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .25);
    max-height: 60vh; overflow-y: auto;
}
.nv-resultado {
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .6rem;
    border: 0; border-radius: 7px; background: none; color: #1f2328; font-size: .86rem; text-align: left;
}
.nv-resultado i { color: #6b7280; width: 16px; text-align: center; }
.nv-resultado span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-resultado small { color: #9ca3af; font-size: .75rem; white-space: nowrap; }
.nv-resultado.activo { background: #eaf1fa; color: #1b4375; }
.nv-sin-resultados { padding: .6rem; color: #6b7280; font-size: .85rem; }

/* ── Lista ─────────────────────────────────────────────────────────────── */
.nv-cuerpo {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .15rem 0 .75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.nv-lista { list-style: none; margin: 0; padding: 0 .75rem; }
.nv-lista > li { margin: 1px 0; }
.nv-pie { flex-shrink: 0; padding-top: .5rem; padding-bottom: .75rem; border-top: 1px solid var(--nv-linea); }

.nv-link {
    display: flex; align-items: center; gap: .75rem; width: 100%;
    padding: .55rem .7rem; border: 0; border-radius: 9px; background: none;
    color: var(--nv-texto); font-size: .9rem; text-align: left; text-decoration: none; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.nv-link:hover { background: var(--nv-hover); color: #fff; }
.nv-link.active { background: var(--nv-activo); color: #fff; font-weight: 600; }
.nv-icono { flex: 0 0 20px; width: 20px; text-align: center; font-size: 1.05rem; }
.nv-texto { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-flecha { font-size: .7rem; color: var(--nv-tenue); transition: transform .2s ease; }
.nv-grupo.abierto > .nv-link-grupo { color: #fff; font-weight: 600; }
.nv-grupo.abierto > .nv-link-grupo .nv-flecha { transform: rotate(180deg); }
.nv-grupo.con-activo:not(.abierto) > .nv-link-grupo { color: #fff; }
.nv-cargando { opacity: .5; cursor: default; }

/* Submenú del grupo abierto, alineado con el texto del grupo */
.nv-sub { list-style: none; margin: .1rem 0 .35rem; padding: 0 0 0 2.05rem; }
.nv-sub > li { margin: 1px 0; }
.nv-sublink {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%;
    padding: .42rem .7rem; border: 0; border-radius: 8px; background: none;
    color: var(--nv-texto); font-size: .86rem; text-align: left; text-decoration: none; cursor: pointer;
}
.nv-sublink:hover { background: var(--nv-hover); color: #fff; }
.nv-sublink.active { background: #fff; color: var(--nv-fondo); font-weight: 600; }
.nv-subgrupo.abierto > .nv-sublink-grupo .nv-flecha { transform: rotate(180deg); }
.nv-sub2 { padding-left: .75rem; margin: 0 0 .2rem; border-left: 1px solid var(--nv-linea); margin-left: .7rem; }

/* ── Compacta: solo íconos ─────────────────────────────────────────────── */
.sidebar.collapsed .nv-lista { padding: 0 .6rem; }
.sidebar.collapsed .nv-link { justify-content: center; padding: .6rem 0; }
.sidebar.collapsed .nv-texto,
.sidebar.collapsed .nv-flecha { display: none; }
.sidebar.collapsed .nv-icono { font-size: 1.15rem; }
.sidebar.collapsed .nv-grupo.con-activo > .nv-link-grupo,
.sidebar.collapsed .nv-link-grupo.flotando { background: var(--nv-activo); color: #fff; }

@media (min-width: 769px) {
    /* Nombre al pasar el mouse por un ícono sin submenú */
    .sidebar.collapsed .nv-link[data-tooltip] { position: relative; }
    .sidebar.collapsed .nv-link[data-tooltip]::after {
        content: attr(data-tooltip);
        position: fixed;
        left: 78px;
        padding: .35rem .75rem;
        border-radius: 7px;
        background: #1f2937;
        color: #fff;
        font-size: .8rem;
        font-weight: 500;
        white-space: nowrap;
        box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
        opacity: 0;
        pointer-events: none;
        transition: opacity .12s ease;
        z-index: 10002;
    }
    .sidebar.collapsed .nv-link[data-tooltip]:hover::after { opacity: 1; }
}

/* ── Panel flotante del modo compacto ─────────────────────────────────── */
.nv-flyout-fondo { position: fixed; inset: 0; z-index: 10004; border: 0; background: transparent; cursor: default; }
.nv-flyout {
    position: fixed;
    left: 80px;
    z-index: 10005;
    width: 250px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: .55rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
    color: #1f2328;
    animation: nv-aparecer .12s ease;
}
.nv-flyout-titulo { padding: .35rem .6rem .45rem; font-size: .86rem; font-weight: 700; color: #111827; }
.nv-flyout-seccion { padding: .55rem .6rem .2rem; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #9ca3af; }
.nv-flyout-link {
    display: block; padding: .5rem .6rem; border-radius: 8px;
    color: #374151; font-size: .88rem; text-decoration: none;
}
.nv-flyout-link:hover { background: #f3f4f6; color: #111827; }
.nv-flyout-link.active { background: #eaf1fa; color: #23548f; font-weight: 600; }
.nv-flyout.salud .nv-flyout-link.active { background: #eceff1; color: #37474F; }
/* Buscador dentro del panel: sobre fondo blanco */
.nv-flyout .nv-buscar > i { color: #9ca3af; }
.nv-flyout .nv-buscar-input { background: #f9fafb; border-color: #e5e7eb; color: #1f2328; padding-right: .75rem; }
.nv-flyout .nv-buscar-input::placeholder { color: #9ca3af; }
.nv-flyout .nv-buscar-input:focus { background: #fff; border-color: #23548f; box-shadow: 0 0 0 3px rgba(35, 84, 143, .15); }
.nv-flyout .nv-resultados { position: static; margin-top: .4rem; padding: 0; box-shadow: none; max-height: 50vh; }
@keyframes nv-aparecer { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

/* ── Notebooks (1366 x 768 y similares): barra más angosta ─────────────── */
@media (min-width: 769px) and (max-width: 1439.98px) {
    .sidebar, .sidebar.expanded { width: 230px; }
    .sidebar.collapsed { width: 70px; }
    .nv-lista { padding: 0 .55rem; }
    .nv-buscar-zona { padding: .25rem .55rem .5rem; }
    .nv-link { gap: .6rem; padding: .5rem .6rem; font-size: .87rem; }
    .nv-sub { padding-left: 1.75rem; }
    .nv-sublink { padding: .4rem .55rem; font-size: .84rem; }
    .sidebar.expanded .nv-sublink { white-space: normal; line-height: 1.2; }
}

/* ── Celular: la barra entra desde la izquierda, siempre completa ─────── */
@media (max-width: 768px) {
    .toggle-btn { display: none; }
    .nv-buscar kbd { display: none; }
    .sidebar, .sidebar.collapsed { width: 280px !important; transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.collapsed .nv-cab { justify-content: flex-start; padding: 0 1rem; }
    .sidebar.collapsed .nv-nombre,
    .sidebar.collapsed .nv-texto,
    .sidebar.collapsed .nv-flecha { display: initial; }
    .sidebar.collapsed .nv-link { justify-content: flex-start; padding: .55rem .7rem; }
    .sidebar.collapsed .nv-lista { padding: 0 .75rem; }
}
