/* ===================================================================
   Tema B - Estructura del layout (fidelidad con el mockup)
   Menú lateral con marca, buscador, árbol y usuario abajo; sin header
   superior en pantallas anchas. Scopeado a body.skin-b.is-auth.
   Se carga después de design-tokens.css y skin-b-controls.css.
   =================================================================== */

/* Fuera de pantallas anchas se ve el header original. */
body.skin-b .ms-brand,
body.skin-b .ms-userbox {
    display: none;
}

@media (min-width: 992px) {

    body.skin-b.is-auth {
        --ms-header-h: 0px;
    }

    /* El header sale del flujo: sus botones siguen en el DOM (ocultos)
       y el menú los invoca (sesión, configuración, logout). */
    body.skin-b.is-auth #navheader {
        display: none !important;
    }

    /* ---------- Menú como columna flex ---------- */

    body.skin-b.is-auth #sidebar {
        top: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    body.skin-b.is-auth .ms-brand {
        display: flex;
        float: none;
        align-items: center;
        gap: 10px;
        height: auto;
        padding: 18px 18px 10px;
    }

    body.skin-b.is-auth #menutreecontainer {
        flex: 1 1 0;
        height: auto !important;
        min-height: 0;
    }

    body.skin-b.is-auth #expandnodes,
    body.skin-b.is-auth #colapsenodes {
        top: 72px;
    }

    /* ---------- Usuario abajo ---------- */

    body.skin-b.is-auth .ms-userbox {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 8px;
        padding: 14px 8px 16px;
        border-top: 1px solid var(--ms-border);
    }

    body.skin-b.is-auth .ms-avatar {
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: var(--ms-primary-soft);
        color: var(--ms-primary-ink);
        font-family: var(--ms-font);
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body.skin-b.is-auth .ms-avatar:focus-visible,
    body.skin-b.is-auth .ms-cfgbtn:focus-visible,
    body.skin-b.is-auth .ms-usertext a:focus-visible {
        outline: 3px solid var(--ms-primary);
        outline-offset: 2px;
    }

    body.skin-b.is-auth .ms-usertext {
        flex: 1;
        min-width: 0;
        line-height: 1.3;
    }

    body.skin-b.is-auth .ms-usertext strong {
        display: block;
        font-size: 13.5px;
        font-weight: 600;
        color: var(--ms-text);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.skin-b.is-auth .ms-usertext a {
        font-size: 12px;
        font-weight: 600;
        color: var(--ms-primary-ink);
        text-decoration: underline;
        text-decoration-color: rgba(10, 95, 94, .35);
        text-underline-offset: 2px;
    }

    body.skin-b.is-auth .ms-usertext a:hover {
        color: var(--ms-primary);
        text-decoration-color: currentColor;
    }

    body.skin-b.is-auth .ms-cfgbtn {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: var(--ms-muted);
        cursor: pointer;
    }

    body.skin-b.is-auth .ms-cfgbtn:hover {
        background: var(--ms-surface-2);
        color: var(--ms-text);
    }

    /* ---------- Paneles de sesión y configuración: junto al usuario ---------- */

    body.skin-b.is-auth .headersesiondropdown,
    body.skin-b.is-auth .headerconfigdropdown {
        left: 12px;
        right: auto;
        top: auto !important;
        bottom: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        border-radius: 12px;
        box-shadow: var(--ms-shadow);
        z-index: 1000;
    }
}

/* ---------- Ítem activo y íconos del árbol ---------- */

body.skin-b #menutreeview .k-sprite {
    color: var(--ms-muted);
}

body.skin-b #menutreeview .k-in.ms-activo,
body.skin-b #menutreeview .k-in.ms-activo:hover {
    background: var(--ms-primary-soft);
    color: var(--ms-primary-ink) !important;
    font-weight: 600;
}

body.skin-b #menutreeview .k-in.ms-activo .k-sprite {
    color: var(--ms-primary);
}

/* ===================================================================
   Árbol del menú como en el mockup: filas completas, íconos de línea
   en los módulos, sin íconos en las opciones hijas y chevron a la
   derecha en lugar del triángulo de Kendo.
   =================================================================== */

body.skin-b #menutreeview .k-top,
body.skin-b #menutreeview .k-mid,
body.skin-b #menutreeview .k-bot {
    position: relative;
    padding: 0;
}

body.skin-b #menutreeview .k-in {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 40px 9px 12px;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

body.skin-b #menutreeview .k-group {
    margin-left: 0;
}

/* (el ul raíz del árbol también es .k-group: lo hijo es "ul ul") */
body.skin-b #menutreeview > ul {
    padding-left: 0;
}

/* Opciones hijas: con sangría respecto del módulo */
body.skin-b #menutreeview ul ul .k-in {
    padding: 8px 10px 8px 14px;
    gap: 10px;
    font-weight: 400;
    font-size: 13.5px;
}

/* Textos largos: se parten en varias líneas en vez de cortarse
   (Kendo fuerza nowrap); el ícono queda alineado con la primera línea. */
body.skin-b #menutreeview .k-in {
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.3;
}

/* Centrado vertical: el ícono es un cuadro de 28px, más alto que una línea de texto
   (con flex-start el texto quedaba pegado arriba). Si el texto se parte, el ícono queda al medio. */
body.skin-b #menutreeview ul ul .k-in {
    align-items: center;
}

body.skin-b #menutreeview ul ul .k-sprite {
    margin-top: 1px;
}

/* El tema de Kendo agranda el glifo (::before a 18px) dentro de una caja
   con overflow hidden: el ícono quedaba recortado. */
body.skin-b #menutreeview ul ul .k-sprite {
    overflow: visible;
}

body.skin-b #menutreeview ul ul .k-sprite::before {
    font-size: inherit;
    line-height: 1;
}

body.skin-b #menutreeview ul ul {
    padding-left: 14px;
}

/* Menú un poco más ancho para que los nombres largos entren mejor */
body.skin-b.is-auth {
    --ms-sidebar-w: 288px;
}

/* Aire entre el buscador y la primera opción; sin cortar el resaltado */
body.skin-b #menutreecontainer {
    padding: 8px 10px 8px;
    overflow-x: hidden;
}

body.skin-b #menutreeview {
    padding: 0;
    overflow: visible;
}

/* Hover: misma pastilla que el estado activo pero más suave; reemplaza el
   estilo de hover del tema Kendo (borde, degradado y sombra). */
body.skin-b #menutreeview .k-in,
body.skin-b #menutreeview .k-in.k-state-hover {
    border: none;
    box-shadow: none;
    background-image: none;
    border-radius: 8px;
    transition: background .12s;
}

body.skin-b #menutreeview .k-in:hover,
body.skin-b #menutreeview .k-in.k-state-hover {
    background: var(--ms-surface-2);
    color: var(--ms-text) !important;
}

body.skin-b #menutreeview .k-in.ms-activo:hover,
body.skin-b #menutreeview .k-in.k-state-selected:hover {
    background: var(--ms-primary-soft);
    color: var(--ms-primary-ink) !important;
}

/* Al hacer clic: mismo efecto que el ítem activo (pastilla suave), sin
   la sombra/borde de Kendo que se recortaba. */
body.skin-b #menutreeview .k-in.k-state-selected,
body.skin-b #menutreeview .k-in.k-state-selected:hover,
body.skin-b #menutreeview .k-in.k-state-focused,
body.skin-b #menutreeview .k-in:active {
    background: var(--ms-primary-soft);
    color: var(--ms-primary-ink) !important;
    font-weight: 600;
    border: none;
    border-color: transparent;
    box-shadow: none;
    outline: none;
}

body.skin-b #menutreeview .k-in.k-state-selected .k-sprite,
body.skin-b #menutreeview .k-in.k-state-focused .k-sprite,
body.skin-b #menutreeview .k-in:active .k-sprite {
    color: var(--ms-primary);
}

body.skin-b #menutreeview .k-item,
body.skin-b #menutreeview .k-top,
body.skin-b #menutreeview .k-mid,
body.skin-b #menutreeview .k-bot {
    box-shadow: none;
    outline: none;
}

/* Módulos con hijos: padre del ítem activo */
body.skin-b #menutreeview .k-in.ms-padre {
    color: var(--ms-primary-ink);
    font-weight: 600;
}

/* Chevron a la derecha (reemplaza el triángulo) */
body.skin-b #menutreeview .k-icon.k-i-expand,
body.skin-b #menutreeview .k-icon.k-i-collapse {
    position: absolute;
    right: 12px;
    left: auto;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0;
    font-size: 0;
    z-index: 2;
    background: var(--ms-muted);
    -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") center / 16px no-repeat;
    mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") center / 16px no-repeat;
    transition: transform .15s;
}

body.skin-b #menutreeview .k-icon.k-i-expand {
    transform: none !important;
}

body.skin-b #menutreeview .k-icon.k-i-collapse {
    transform: rotate(90deg) !important;
}

body.skin-b #menutreeview .k-icon.k-i-expand::before,
body.skin-b #menutreeview .k-icon.k-i-collapse::before {
    content: none;
}

/* Íconos de línea de los módulos (reemplazan a los de Font Awesome sólido) */
body.skin-b #menutreeview > ul > li > div .k-sprite {
    display: inline-block;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin: 0;
    font-size: 0;
    background: currentColor;
    -webkit-mask: var(--ms-ic, none) center / 20px no-repeat;
    mask: var(--ms-ic, none) center / 20px no-repeat;
}

body.skin-b #menutreeview > ul > li > div .k-sprite::before {
    content: none;
}

/* Opciones hijas: conservan su ícono (Font Awesome), chico y discreto */
body.skin-b #menutreeview ul ul .k-sprite {
    display: inline-block;
    flex: 0 0 18px;
    width: 18px;
    height: auto;
    margin: 0;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    color: var(--ms-muted);
}

/* Si alguna variante le pinta un fondo al ícono (placa/baldosa), que sea
   un cuadrado con esquinas redondeadas y no un óvalo estirado — algunas
   variantes de color (oscuras) le dan al ícono un ancho/alto fijo de
   30px vía una regla más específica (ver skin-b-app.css), pero el resto
   de las reglas de acá arriba (flex/width/height) seguían peleando el
   layout y a veces ganaban solo en una dimensión, estirando la placa.
   Mismo selector (doble id) para asegurar que esta gane siempre. */
body.skin-b #sidebar #menutreeview ul ul .k-sprite {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

body.skin-b #menutreeview .fa-clinic-medical { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-balance-scale { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.3-4.3'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-wheelchair { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-file-invoice { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M8 13h8M8 17h8'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-align-justify { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2 2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-handshake { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-chart-bar { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 20V10M12 20V4M6 20v-6'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-book-medical { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15zM20 17v5H6.5A2.5 2.5 0 0 1 4 19.5'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-list-alt { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3h18v18H3zM3 9h18M3 15h18M9 3v18'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-pills { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.5 20.5 3.5 13.5a4.95 4.95 0 0 1 7-7l7 7a4.95 4.95 0 0 1-7 7zM8.5 8.5l7 7'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-notes-medical { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2M9 2h6v4H9zM12 11v6M9 14h6'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-cog { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-key { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-sitemap { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='4' rx='1'/%3E%3Crect x='2' y='17' width='6' height='4' rx='1'/%3E%3Crect x='16' y='17' width='6' height='4' rx='1'/%3E%3Cpath d='M12 7v4M5 17v-3h14v3'/%3E%3C/svg%3E"); }
body.skin-b #menutreeview .fa-mobile-alt { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='2' width='12' height='20' rx='2'/%3E%3Cline x1='11' y1='18' x2='13' y2='18'/%3E%3C/svg%3E"); }

/* ===================================================================
   Cabecera de página y tarjetas (patrón #rootwizard > #Abm, usado en
   ~40 pantallas): sin tarjeta contenedora; título grande arriba a la
   izquierda, acciones arriba a la derecha y filtros en su propia tarjeta.
   =================================================================== */

body.skin-b #rootwizard {
    position: relative;
}

body.skin-b #Abm {
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

body.skin-b #Abm > .row:first-child {
    margin-bottom: 0 !important;
}

body.skin-b #Abm h3 {
    margin: 0 0 18px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--ms-text);
}

/* Botones Agregar / Modificar / ...: arriba a la derecha, alineados con el título */
body.skin-b #rootwizard .col-md-12:has(> #butAgregar) {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    padding: 0;
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
}

body.skin-b #rootwizard .col-md-12:has(> #butAgregar) > .k-button {
    margin: 0 !important;
}

/* La fila de título también puede traer el chevron de "Ocultar/Mostrar filtros"
   (col-md-9 h3 + col-md-3 botón). En las pantallas donde además el botón
   Agregar vive en un .col-md-12 (ver regla de arriba, "arriba a la derecha"),
   ese grupo queda con position:absolute en el mismo rincón superior derecho,
   así que hay que reservarle el espacio al chevron para que no se superpongan.
   En pantallas SIN ese grupo arriba (ej. Carrusel, que deja Agregar/Modificar/
   Eliminar abajo de la grilla) no hay nada que evitar — si igual reservamos
   el espacio, el chevron queda flotando lejos del borde derecho real. */
body.skin-b #rootwizard:has(.col-md-12 > #butAgregar) #Abm .row:has(> div > #butOcultarMostrar) {
    padding-right: 360px;
}
body.skin-b #Abm .row:has(> div > #butOcultarMostrar) > div:has(> #butOcultarMostrar) {
    display: flex;
    justify-content: flex-end;
}

body.skin-b #rootwizard #butAgregar {
    background: var(--ms-primary);
    border-color: var(--ms-primary);
    color: #fff;
}

body.skin-b #rootwizard #butAgregar:hover {
    background: var(--ms-primary-hover);
    border-color: var(--ms-primary-hover);
}

/* Separadores vacíos entre el título y los filtros (br y pestañas ocultas) */
body.skin-b #Abm > br,
body.skin-b #Abm > .nav-pills {
    display: none;
}

/* Filtros en tarjeta */
body.skin-b #rootwizard #PanelParametros {
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-lg);
    padding: 20px 24px 8px;
    margin-bottom: 16px;
}
body.skin-b #menutreeview .fa-tags { --ms-ic: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41 13.42 20.58a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82zM7 7h.01'/%3E%3C/svg%3E"); }
