/* NexoRH · interfaz A — capa de diseño compartida por todas las pantallas del sistema (las que extienden base.html).
 *
 * Las plantillas usan clases de Tailwind escritas a mano (Tailwind CDN); en vez de reescribir cada pantalla, esta hoja les da una sola
 * forma, color y movimiento: tarjetas, botones, tablas, formularios, ventanas emergentes, menú lateral y animaciones.
 * Los selectores van con `main`, `body[class]`, etc. para ganarle en especificidad a las utilidades de Tailwind, que se inyectan después.
 *
 * Reglas de la casa (para pantallas nuevas):
 *  - Tarjeta = `bg-white rounded-xl border border-gray-100 shadow-sm`; sale sola con el estilo de aquí. No inventar otra.
 *  - Acción principal = `bg-brand text-white`; secundaria = `bg-white border border-slate-300`. Un solo botón principal por zona.
 *  - Color como señal: azul de marca para lo normal; ámbar = necesita atención; rojo = riesgo o acción destructiva; verde = correcto.
 *  - Todo movimiento dura 150-500 ms y se apaga con «reducir movimiento» del sistema operativo.
 */

:root {
    --nx-brand: #355886;
    --nx-brand-dark: #2B4568;
    --nx-brand-tint: #E8EFF8;
    --nx-accent: #DA9E75;
    --nx-bg: #F4F6FA;
    --nx-ink: #1E293B;
    --nx-muted: #5B677A;
    --nx-line: #E3E9F1;
    --nx-radius: 16px;
    --nx-radius-sm: 10px;
    --nx-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    --nx-shadow-hover: 0 14px 30px -16px rgba(53, 88, 134, .4);
    --nx-ease: cubic-bezier(.2, .7, .2, 1);
}

@keyframes nx-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes nx-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes nx-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes nx-load { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes nx-pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, .45); } 70% { box-shadow: 0 0 0 7px rgba(217, 119, 6, 0); } 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); } }

html { scroll-behavior: smooth; }
body[class] { background-color: var(--nx-bg); color: var(--nx-ink); -webkit-font-smoothing: antialiased; }
div.bg-slate-50.flex-col { background-color: var(--nx-bg); }
::selection { background: #D7E3F4; }
main { scrollbar-width: thin; scrollbar-color: #CBD5E1 transparent; }

/* ---- Foco visible: el mismo anillo en todo el sistema ------------------------------------------------------------------------------- */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid #8FB2E0; outline-offset: 2px; }

/* ---- Títulos ------------------------------------------------------------------------------------------------------------------------ */
:is(main, .nx-publica) :is(h1, h2) { letter-spacing: -.02em; }
:is(main, .nx-publica) h1 { font-weight: 800; }

/* ---- Tarjetas ----------------------------------------------------------------------------------------------------------------------- */
:is(main, .nx-publica) :is(.rounded-xl, .rounded-2xl).bg-white {
    border-radius: var(--nx-radius);
    border-color: var(--nx-line);
    box-shadow: var(--nx-shadow);
    transition: box-shadow .25s, border-color .25s, transform .25s var(--nx-ease);
}
:is(main, .nx-publica) a:is(.rounded-xl, .rounded-2xl).bg-white:hover {
    transform: translateY(-2px);
    box-shadow: var(--nx-shadow-hover);
    border-color: #C7D6E8;
}

/* ---- Botones ------------------------------------------------------------------------------------------------------------------------ */
:is(button, a).rounded-lg[class*="px-"] {
    transition: background-color .2s, border-color .2s, color .2s, box-shadow .2s, transform .15s var(--nx-ease);
}
:is(button, a).rounded-lg[class*="px-"]:active { transform: scale(.97); }
:is(button, a).bg-brand:hover { box-shadow: 0 8px 18px -8px rgba(53, 88, 134, .65); }
:is(button, a).rounded-lg[class*="px-"]:disabled { transform: none; box-shadow: none; }

/* ---- Formularios -------------------------------------------------------------------------------------------------------------------- */
:is(main, .nx-publica) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), select, textarea) {
    border-radius: var(--nx-radius-sm);
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}
:is(main, .nx-publica) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), select, textarea):focus {
    outline: none;
    border-color: var(--nx-brand);
    box-shadow: 0 0 0 4px rgba(53, 88, 134, .16);
}
:is(main, .nx-publica) :is(input, select, textarea)::placeholder { color: #94A3B8; }
:is(main, .nx-publica) :is(input[type=checkbox], input[type=radio]) { accent-color: var(--nx-brand); }

/* ---- Tablas ------------------------------------------------------------------------------------------------------------------------- */
:is(main, .nx-publica) thead th {
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #64748B;
    background-color: #F8FAFC;
}
:is(main, .nx-publica) tbody tr { transition: background-color .15s; }
:is(main, .nx-publica) tbody tr:not([class*="bg-"]):hover { background-color: #F6F9FD; }

/* ---- Ventanas emergentes ------------------------------------------------------------------------------------------------------------ */
.fixed.inset-0 :is(.rounded-xl, .rounded-2xl).bg-white {
    box-shadow: 0 28px 64px -24px rgba(15, 23, 42, .5);
    animation: nx-pop .25s var(--nx-ease) backwards;
}

/* ---- Entrada de cada pantalla: sus bloques suben en cascada ------------------------------------------------------------------------- */
main > div:not(.fixed) > *:nth-child(-n + 8) { animation: nx-up .5s var(--nx-ease) backwards; }
main > div:not(.fixed) > *:nth-child(2) { animation-delay: .05s; }
main > div:not(.fixed) > *:nth-child(3) { animation-delay: .1s; }
main > div:not(.fixed) > *:nth-child(4) { animation-delay: .15s; }
main > div:not(.fixed) > *:nth-child(5) { animation-delay: .2s; }
main > div:not(.fixed) > *:nth-child(6) { animation-delay: .25s; }
main > div:not(.fixed) > *:nth-child(7) { animation-delay: .3s; }
main > div:not(.fixed) > *:nth-child(8) { animation-delay: .35s; }

/* ---- Barra superior: una línea de marca que se dibuja al entrar --------------------------------------------------------------------- */
.nx-header { position: relative; box-shadow: none; }
.nx-header::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: var(--nx-brand);
    transform-origin: left;
    animation: nx-load 1.1s .1s var(--nx-ease) backwards;
}

/* ---- Menú lateral ------------------------------------------------------------------------------------------------------------------- */
[data-menu] > a, [data-menu] > div > a, [data-menu] > div > button { transition: background-color .15s, color .15s, transform .15s var(--nx-ease); }
[data-menu] a, [data-menu] button { border-radius: 10px; }
[data-menu] a:not([aria-current]):hover { transform: translateX(2px); }
[data-menu] a[aria-current="page"] { position: relative; background-color: rgba(53, 88, 134, .1); color: var(--nx-brand); }
[data-menu] a[aria-current="page"]::before {
    content: "";
    position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--nx-brand);
    animation: nx-grow .45s .2s var(--nx-ease) backwards;
}
[data-badge]:not(:empty), [data-badge-grupo]:not(:empty) { animation: nx-pulse 2.2s infinite; }

/* ---- Piezas reutilizables ----------------------------------------------------------------------------------------------------------- */
.nx-eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--nx-brand); }
.nx-chip { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--nx-brand-tint); color: var(--nx-brand); }
.nx-chip svg { width: 22px; height: 22px; }
.nx-chip.alerta { background: #FEF3C7; color: #92400E; }
.nx-chip.ok { background: #DCFCE7; color: #166534; }
.nx-chip.riesgo { background: #FEE2E2; color: #991B1B; }
.nx-kpi { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nx-kpi .valor { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.nx-entrada { animation: nx-pop .5s var(--nx-ease) backwards; }
.nx-linea { height: 3px; border-radius: 3px; background: var(--nx-brand); transform-origin: left; animation: nx-load .9s .3s var(--nx-ease) backwards; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ================================================================================================================================== */
/* Filosofía de la interfaz.                                       */
/* Ayudar a DECIDIR con menos esfuerzo. Blancos de 44 px (Fitts), texto un punto más grande,*/
/* filas con aire, búsqueda con Ctrl K, el tablero parte de «Para decidir hoy» y las aprobaciones se pueden deshacer unos segundos.   */
/* ================================================================================================================================== */
@keyframes nx-sale { to { opacity: 0; transform: translateX(24px); max-height: 0; padding-top: 0; padding-bottom: 0; } }
@keyframes nx-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Aviso «Deshacer» (lo crea nxDeshacer en ui.js) */
.nx-aviso { position: fixed; left: 0; right: 0; bottom: 24px; margin: auto; width: max-content; max-width: 92vw; z-index: 70; display: flex; align-items: center; gap: 16px; padding: 12px 18px; border-radius: 12px; background: #1E293B; color: #fff; font-size: .9375rem; box-shadow: 0 18px 40px -16px rgba(15, 23, 42, .6); overflow: hidden; animation: nx-pop .25s var(--nx-ease); }
.nx-aviso button { min-height: 36px; padding: 0 14px; border: 1px solid #DA9E75; border-radius: 8px; background: transparent; color: #fff; font-weight: 600; cursor: pointer; transition: background-color .15s; }
.nx-aviso button:hover { background: rgba(218, 158, 117, .25); }
.nx-aviso .vida { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: #DA9E75; transform-origin: left; animation: nx-drain linear forwards; }

/* «Para decidir hoy» (tablero S) */
.nx-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 16px; padding: 16px 24px; border-top: 1px solid #EEF2F7; max-height: 170px; overflow: hidden; animation: nx-up .4s var(--nx-ease) backwards; transition: background-color .15s; }
.nx-fila:hover { background-color: #F8FAFD; }
.nx-fila.nx-sale { animation: nx-sale .28s cubic-bezier(.4, 0, 1, 1) forwards; }
.nx-avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; font-size: .875rem; font-weight: 700; background: var(--nx-brand-tint); color: var(--nx-brand-dark); }
.nx-barra { height: 8px; border-radius: 999px; background: var(--nx-line); overflow: hidden; }
.nx-barra > div { height: 100%; border-radius: 999px; background: var(--nx-brand); transition: width .5s var(--nx-ease); }
.nx-hecho { padding: 36px 24px 40px; text-align: center; animation: nx-up .5s var(--nx-ease) backwards; }
.nx-hecho .aro { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: #DCFCE7; color: #166534; }

/* Búsqueda con Ctrl K (botón de la barra superior) */
.nx-buscar { display: inline-flex; align-items: center; gap: 10px; min-width: 280px; height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px; background: var(--nx-bg); color: #64748B; font-size: .9375rem; cursor: pointer; transition: border-color .15s, background-color .15s; }
.nx-buscar:hover { border-color: #CBD5E1; background: #fff; }
.nx-buscar svg { width: 18px; height: 18px; }
.nx-buscar kbd { margin-left: auto; padding: 1px 7px; border: 1px solid #CBD5E1; border-bottom-width: 2px; border-radius: 6px; font: 600 .75rem 'Inter', sans-serif; color: #64748B; background: #F8FAFC; }

/* ---- Tamaños y aire de TODAS las pantallas --------------------------------------------------------- */
:is(main, .nx-publica) .text-sm { font-size: .9375rem; line-height: 1.5rem; }
:is(main, .nx-publica) .text-xs { font-size: .8125rem; line-height: 1.25rem; }
:is(main, .nx-publica) h1 { font-size: 2rem; line-height: 2.25rem; }
:is(main, .nx-publica) :is(button, a).rounded-lg[class*="px-"]:not(.block):not(.flex):not(.grid):not(.hidden):not(.inline-flex) {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
}
:is(main, .nx-publica) :is(button, a).rounded-lg[class*="px-"]:is(.block, .flex, .grid, .inline-flex) { min-height: 44px; }
:is(main, .nx-publica) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), select) { min-height: 44px; }
:is(main, .nx-publica) tbody td { padding-top: .875rem; padding-bottom: .875rem; }
[data-menu] :is(a, button) { min-height: 44px; }
[data-menu] a { font-size: .9375rem; }
:is(main, .nx-publica) :is(button, a).rounded-lg.w-full { min-height: 44px; }

/* Diálogos propios (nxConfirmar / nxPedirTexto, en ui.js) */
.nx-dialogo-fondo { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .5); animation: nx-fundir .15s ease-out; }
.nx-dialogo { width: 100%; max-width: 440px; padding: 24px; border-radius: 16px; background: #fff; color: #0F172A; box-shadow: 0 30px 70px -20px rgba(15, 23, 42, .55); animation: nx-pop .22s var(--nx-ease); }
.nx-dialogo h2 { margin: 0 0 8px; font-size: 1.125rem; font-weight: 700; }
.nx-dialogo p { margin: 0 0 16px; font-size: .9375rem; line-height: 1.5; color: #475569; }
.nx-dialogo label { display: block; margin: 0 0 16px; font-size: .8125rem; font-weight: 600; color: #334155; }
.nx-dialogo textarea, .nx-dialogo input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #CBD5E1; border-radius: 10px; font: inherit; font-weight: 400; color: #0F172A; resize: vertical; }
.nx-dialogo textarea:focus, .nx-dialogo input:focus { outline: 2px solid #4E74A6; outline-offset: 0; border-color: #4E74A6; }
.nx-dialogo .invalido { border-color: #E11D48; outline-color: #E11D48; }
.nx-dialogo-pie { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.nx-dialogo-pie button { min-height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background-color .15s; }
.nx-dialogo-pie .secundario { background: #fff; border-color: #CBD5E1; color: #334155; }
.nx-dialogo-pie .secundario:hover { background: #F1F5F9; }
.nx-dialogo-pie .principal { background: #355886; color: #fff; }
.nx-dialogo-pie .principal:hover { background: #2B4568; }
.nx-dialogo.peligro .principal { background: #BE123C; }
.nx-dialogo.peligro .principal:hover { background: #9F1239; }
@keyframes nx-fundir { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .nx-dialogo, .nx-dialogo-fondo { animation: none; } }
