/*
  Wiki Integral — capa propia sobre Tabler.
  Analogía GeneXus: Tabler es el template base (como el del Wizard de WWP);
  este archivo solo aplica la marca: paleta del logo, menú de EGESIS y detalles de grilla.
*/

/* ---------- Común a los dos modos ---------- */
:root {
  --wi-verde: #00A859;          /* logo */
  --wi-celeste: #01A5FD;        /* logo */
  --wi-azul: #004080;           /* botones y encabezados, como EGESIS */
  --wi-menu: #0E3164;           /* menú lateral */
}
html[data-bs-theme], html[data-bs-theme] body { --tblr-font-sans-serif: "Poppins", "Segoe UI", system-ui, sans-serif; }

/* Tamaño de letra elegido por el usuario (Preferencias). Todo lo que está en rem escala con esto. */
html[data-tamano="chica"] { font-size: 87.5%; }
html[data-tamano="grande"] { font-size: 112.5%; }

/* ---------- Modo claro (solo cuando el tema es claro) ---------- */
html[data-bs-theme="light"] {
  --tblr-primary: #004080;
  --tblr-primary-rgb: 0, 64, 128;
  --tblr-primary-darken: #0E3164;
  --tblr-success: #00A859;
  --tblr-success-rgb: 0, 168, 89;
  --tblr-link-color: #004080;
  --tblr-link-color-rgb: 0, 64, 128;
  --tblr-body-color: #373435;   /* gris del logo */
  --tblr-body-bg: #EEF1F5;
}

/* ---------- Modo oscuro: se usan los colores de Tabler y solo se aclara el azul ---------- */
html[data-bs-theme="dark"] {
  --tblr-primary: #4FA3FF;
  --tblr-primary-rgb: 79, 163, 255;
  --tblr-link-color: #7CC8FF;
  --tblr-link-color-rgb: 124, 200, 255;
  --tblr-success: #2FCB7E;
  --tblr-success-rgb: 47, 203, 126;
}

/* ---------- Menú lateral (estructura de EGESIS) ---------- */
.navbar-vertical.wi-lateral { background: var(--wi-menu) !important; }
[data-bs-theme="dark"] .navbar-vertical.wi-lateral { background: #0B1220 !important; }
.wi-marca { display: flex; align-items: center; gap: 10px; }
.wi-marca .cabeza { width: 30px; height: auto; }
.wi-marca .titulo { height: 22px; width: auto; }
.wi-lema { font-size: 0.75rem; color: #A9BEDD; padding: 0 1rem 0.5rem; }
.wi-lateral .nav-link { font-size: 0.875rem; }
.wi-lateral .dropdown-item { font-size: 0.8125rem; }
.wi-lateral .nav-link.active, .wi-lateral .dropdown-item.active { background: rgba(255, 255, 255, 0.14); font-weight: 600; }
.wi-lateral .cantidad { margin-left: auto; font-size: 0.75rem; color: #A9BEDD; }
.wi-buscar-menu { background: rgba(255, 255, 255, 0.08); border: none; color: #FFFFFF; }
.wi-buscar-menu::placeholder { color: #A9BEDD; }
.wi-buscar-menu:focus { background: rgba(255, 255, 255, 0.14); color: #FFFFFF; }
.wi-titulo-pantalla { font-size: 1rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }

/* ---------- Home ---------- */
.wi-buscador .form-control { height: 3.25rem; font-size: 1rem; }
.wi-buscador .btn { height: 3.25rem; padding: 0 1.75rem; }
.wi-resultado { position: relative; }
.wi-resultado.active, .wi-resultado[aria-current="true"] { background: rgba(var(--tblr-primary-rgb), 0.07); box-shadow: inset 3px 0 0 var(--wi-celeste); }
.wi-resumen-corto { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wi-texto-articulo { font-size: 0.9375rem; line-height: 1.7; max-width: 78ch; overflow-wrap: anywhere; }
.wi-texto-articulo img { max-width: 100%; height: auto; }
.wi-visor { padding: 0.5rem; text-align: center; }
/* Organización: árbol de U.O. (sangría por nivel en el HTML) y logo */
.wi-codigo-uo { font-family: ui-monospace, monospace; font-size: 0.75rem; min-width: 2.6rem; text-align: center;
  padding: 0.1rem 0.35rem; border-radius: 4px; background: var(--tblr-primary-lt); color: var(--tblr-primary); }
.wi-arbol-uo .list-group-item.active .wi-codigo-uo { background: var(--tblr-bg-surface); }
.wi-logo-uo { width: 9.5rem; height: 4rem; border: 1px dashed var(--tblr-border-color); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.wi-logo-uo img { max-width: 100%; max-height: 100%; }
.wi-visor img { max-width: 100%; max-height: 78vh; height: auto; }
.wi-visor iframe { width: 100%; height: 78vh; border: 0; }
.wi-texto-articulo table { border-collapse: collapse; display: block; overflow-x: auto; }
.wi-texto-articulo td, .wi-texto-articulo th { border: 1px solid var(--tblr-border-color); padding: 6px 10px; }

/* ---------- Grillas tipo WorkWith ---------- */
.wi-grilla td, .wi-grilla th { padding-top: 0.45rem; padding-bottom: 0.45rem; }
.wi-grilla th a { color: inherit; text-decoration: none; white-space: nowrap; }
.wi-grilla th a .ti { font-size: 0.75rem; opacity: 0.55; }
.wi-grilla th a.ordenada .ti { opacity: 1; color: var(--tblr-primary); }
.wi-grilla .numero { text-align: right; font-variant-numeric: tabular-nums; }
.wi-grilla .col-menu { width: 1%; }
.btn-menu-fila { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Ficha ---------- */
.wi-dual .list-group { height: 210px; overflow-y: auto; }
.wi-dual .list-group-item { cursor: pointer; }
.wi-linea-tiempo .list-timeline-icon { color: #FFFFFF; }
.wi-importar { border: 1.5px dashed var(--wi-celeste); background: rgba(1, 165, 253, 0.06); }
details.wi-auditoria > summary { cursor: pointer; list-style: none; }
details.wi-auditoria > summary::-webkit-details-marker { display: none; }

/* ---------- Etiquetas de paramétricas (paleta fija: models.ColorEtiqueta) ----------
   Cada color define solo --wi-c; fondo y texto se derivan de él, con contraste en modo claro y oscuro. */
.badge.wi-param { --wi-c: #6B7280; background: color-mix(in oklab, var(--wi-c) 16%, transparent);
                  color: color-mix(in oklab, var(--wi-c) 72%, black); }
[data-bs-theme="dark"] .badge.wi-param { background: color-mix(in oklab, var(--wi-c) 26%, transparent);
                                         color: color-mix(in oklab, var(--wi-c) 55%, white); }
.badge.wi-color-azul { --wi-c: #066FD1; }
.badge.wi-color-celeste { --wi-c: #01A5FD; }
.badge.wi-color-indigo { --wi-c: #4263EB; }
.badge.wi-color-violeta { --wi-c: #AE3EC9; }
.badge.wi-color-rosa { --wi-c: #D6336C; }
.badge.wi-color-rojo { --wi-c: #D63939; }
.badge.wi-color-naranja { --wi-c: #F76707; }
.badge.wi-color-amarillo { --wi-c: #F59F00; }
.badge.wi-color-lima { --wi-c: #74B816; }
.badge.wi-color-verde { --wi-c: #2FB344; }
.badge.wi-color-verde_integral { --wi-c: #00A859; }
.badge.wi-color-turquesa { --wi-c: #0CA678; }
.badge.wi-color-cian { --wi-c: #17A2B8; }
.badge.wi-color-marron { --wi-c: #8B5A2B; }
.badge.wi-color-gris { --wi-c: #6B7280; }
.badge.wi-color-grafito { --wi-c: #373435; }
[data-bs-theme="dark"] .badge.wi-color-grafito { --wi-c: #9AA0A6; }

/* ---------- Ingreso ---------- */
.wi-ingreso { background: var(--wi-menu); }
.wi-ingreso .logo { width: 100%; max-width: 320px; }

/* ---------- Impresión ---------- */
@media print {
  .navbar, .navbar-vertical, .d-print-none, .footer { display: none !important; }
  .page-wrapper { margin: 0 !important; }
  body { background: #FFFFFF !important; }
  .card { box-shadow: none !important; border: none !important; }
}

/* ===== Encabezado al imprimir (E5b, pantalla 5): medidas del diseño, siempre en colores de papel ===== */
.wi-encabezado { display: grid; grid-template-columns: 2fr 3fr 2fr 5.75rem; max-width: 47.5rem;
  border: 1px solid #373435; background: #FFFFFF; color: #1D273B; font-size: .78rem; line-height: 1.4; }
.wi-encabezado > div { min-width: 0; padding: .5rem .625rem; display: flex; flex-direction: column; justify-content: center; }
.wi-encabezado > div + div { border-left: 1px solid #373435; }
.wi-enc-uo { gap: .25rem; }
.wi-enc-logo { height: 2.5rem; display: flex; align-items: center; justify-content: center; }
.wi-enc-logo img { display: block; max-height: 2.5rem; max-width: 100%; width: auto; height: auto; object-fit: contain; }
.wi-enc-uo span { font-size: .72rem; color: #5B6575; text-align: center; }
.wi-enc-titulo { font-weight: 500; }
.wi-enc-datos { display: block !important; line-height: 1.6; }
.wi-enc-qr { align-items: center; gap: .25rem; padding: .5rem !important; }
.wi-enc-qr-img { width: 3.625rem; height: 3.625rem; }
.wi-enc-qr-img svg { display: block; width: 3.625rem; height: 3.625rem; }
.wi-enc-qr span { font-size: .6rem; color: #5B6575; text-align: center; line-height: 1.2; }

/* Página de impresión: el thead repite el encabezado en cada hoja; el pie queda fijo abajo */
.wi-impresion { background: #FFFFFF; color: #1D273B; }
.wi-impresion-barra { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem 1rem; background: #E8F2FF; border-bottom: 1px solid #A9B6C8; font-size: .875rem; }
.wi-impresion-hoja { width: 100%; max-width: 50rem; margin: 1rem auto; border-collapse: collapse; }
.wi-impresion-hoja > thead td { padding-bottom: 1rem; }
.wi-impresion-hoja .wi-encabezado { max-width: none; }
.wi-impresion-logo { width: 13.75rem; margin-bottom: .75rem; }
.wi-impresion-titulo { font-size: 1.5rem; margin-bottom: .25rem; }
.wi-impresion-datos { color: #5B6575; font-size: .875rem; }
.wi-impresion-resumen { font-style: italic; color: #5B6575; }
.wi-impresion-pie { text-align: center; font-size: .75rem; color: #5B6575; border-top: 1px solid #A9B6C8;
  padding-top: .25rem; margin: 1rem auto; max-width: 50rem; }
.wi-impresion-pie-lugar { height: 0; }
@media print {
  @page { margin: 12mm 12mm 16mm; }
  .wi-impresion-hoja { margin: 0; max-width: none; }
  .wi-impresion-pie { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; max-width: none; background: #FFFFFF; }
  .wi-impresion-pie-lugar { height: 1.5rem; }
  .wi-encabezado, .wi-impresion-pie { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Ficha de usuario (rediseño E2): grupos de roles y resumen de alcance */
.wi-grupo-roles { font-size: .6875rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--tblr-secondary); margin: .75rem 0 .5rem; }
.wi-grupo-roles:first-of-type { margin-top: 0; }
.wi-alcance .fw-bold { font-size: .875rem; }

/* ===== Ayuda por campo (E6): "?" junto a la etiqueta y panel debajo ===== */
.wi-campo-encabezado { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .375rem; margin-bottom: .5rem; }
.wi-ayuda { flex: none; width: 1.25rem; height: 1.25rem; padding: 0; border: 1px solid var(--wi-celeste); border-radius: 50%;
            background: transparent; color: #0077B6; font-size: .75rem; line-height: 1; cursor: pointer; }
[data-bs-theme="dark"] .wi-ayuda { color: var(--wi-celeste); }
.wi-ayuda:hover, .wi-ayuda[aria-expanded="true"] { background: var(--wi-celeste); color: #fff; }
.wi-ayuda-vacia { border-style: dashed; border-color: var(--tblr-secondary); color: var(--tblr-secondary); opacity: .75; }
.wi-ayuda-panel { flex-basis: 100%; padding: .5rem .75rem; border-left: 3px solid var(--wi-celeste); border-radius: 4px;
                  background: rgba(1, 165, 253, .07); font-size: .8125rem; font-weight: 400; }
.wi-ayuda-panel p { margin-bottom: .375rem; }
.wi-ayuda-titulo { font-weight: 600; margin-bottom: .25rem; }

/* ---------- Manual del usuario (menú Ayuda) ---------- */
.wi-manual-indice .list-group-item { padding: .45rem .75rem; font-size: .875rem; }
.wi-manual-indice .wi-manual-secciones { list-style: none; padding: 0 0 .25rem 2rem; margin: 0; font-size: .8125rem; }
.wi-manual-indice .wi-manual-secciones a { display: block; padding: .15rem 0; color: var(--tblr-secondary); }
.wi-manual { font-size: .9375rem; line-height: 1.7; max-width: 82ch; }
.wi-manual h2 { font-size: 1.25rem; color: #004080; border-bottom: 2px solid #01A5FD; padding-bottom: .25rem;
                margin: 2rem 0 .75rem; scroll-margin-top: 1rem; }
.wi-manual > section:first-of-type h2 { margin-top: 0; }
[data-bs-theme="dark"] .wi-manual h2 { color: #6CB8FF; }
.wi-manual h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.wi-manual ol, .wi-manual ul { padding-left: 1.5rem; }
.wi-manual li { margin-bottom: .25rem; }
.wi-manual table { width: 100%; margin: .5rem 0 1rem; border-collapse: collapse; font-size: .875rem; }
.wi-manual th, .wi-manual td { border: 1px solid var(--tblr-border-color); padding: .35rem .5rem; vertical-align: top; }
.wi-manual th { background: var(--tblr-bg-surface-secondary); }
.wi-ui { display: inline-block; padding: 0 .4rem; border: 1px solid var(--tblr-border-color); border-radius: 4px;
         background: var(--tblr-bg-surface-secondary); font-size: .85em; font-weight: 500; white-space: nowrap; }
.wi-nota { border-left: 4px solid #01A5FD; background: rgba(1, 165, 253, .08); padding: .6rem .9rem; margin: .75rem 0;
           border-radius: 0 4px 4px 0; }
.wi-nota-cuidado { border-left-color: #F59F00; background: rgba(245, 159, 0, .1); }
.wi-nota-prohibido { border-left-color: #D63939; background: rgba(214, 57, 57, .08); }
.wi-nota > strong:first-child { display: block; }
.wi-flujo { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .5rem 0 1rem; }
.wi-flujo .badge { font-size: .8125rem; }
.wi-manual-portada { text-align: center; padding: 30vh 0 0; }
.wi-manual-portada img { width: 16rem; margin-bottom: 2rem; }
.wi-manual-portada h1 { font-size: 2rem; margin-bottom: .5rem; }
.wi-manual-toc ol { font-size: 1rem; line-height: 2; }
@media print {
  .wi-manual { max-width: none; font-size: 10.5pt; }
  .wi-manual-capitulo, .wi-manual-toc { break-before: page; }
  /* Tabler no corta las tarjetas al imprimir: un capítulo más largo que una hoja saltaba a la segunda y
     dejaba la primera en blanco (v35) */
  .card.wi-manual-pagina { break-inside: auto; }
  .wi-manual h2, .wi-manual h3 { break-after: avoid; }
  .wi-manual table, .wi-nota, .wi-flujo { break-inside: avoid; }
  .wi-nota, .wi-ui, .wi-manual th, .wi-flujo .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .wi-manual a { color: inherit; text-decoration: none; }
}
