/**
 * El kit compartido de las zonas interactivas.
 *
 * Lo usan PESV, Dotación y EPP y Riesgo Químico: magIA llenando un paso a la
 * vista, la fila de magIA con el botón de pasar al siguiente elemento, el
 * informe final por secciones en el panel y la ventana con la vista previa
 * sobre el membrete de PRL. Prefijo zi- (zona interactiva). Lo arma
 * public/assets/js/pages/module-zone.js.
 *
 * Mobile-first. Los @keyframes viven en animations.css.
 */

/* ══════════════════ magIA llena el paso ══════════════════ */
.zi-foot--stack { flex-direction: column; align-items: stretch; gap: 8px; }
.zi-foot--stack .pi-go { width: 100%; justify-content: center; text-align: center; }
.zi-foot--stack .pi-block { text-align: center; }

.zi-go--magia { display: inline-flex; align-items: center; gap: 10px; padding-left: 14px; }
.zi-go--magia:disabled { opacity: 1; }

.zi-magia {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
    object-fit: cover;
}

.zi-go--magia.is-working {
    background-image: linear-gradient(110deg, #1E7BFF 0%, #22D3EE 30%, #7FE7FF 45%, #22D3EE 60%, #1E7BFF 100%);
    background-size: 260% 100%;
    cursor: progress;
    animation: sgShimmer 1.6s linear infinite;
}

.zi-go--magia.is-working:hover { transform: none; }
.zi-go--magia.is-working .zi-magia { animation: sgMagiaPulse 0.9s var(--ease-in-out) infinite; }

/* El plan de magIA mientras trabaja: una línea por elemento */
.zi-sug { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }

.zi-sug__k {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background-image: var(--gradient-text);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.zi-magia--sm { width: 20px; height: 20px; box-shadow: none; }

.zi-sug__i { display: flex; align-items: flex-start; gap: 10px; transition: opacity var(--duration-normal) var(--ease-smooth); }
.zi-sug__i.is-wait { opacity: 0.5; }

.zi-sug__dot {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 0.85rem;
    height: 0.85rem;
    margin-top: 3px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px rgba(250, 250, 250, 0.3);
    color: #060610;
}

.zi-sug__i.is-now .zi-sug__dot { background: #22D3EE; box-shadow: none; animation: sgMagiaPulse 0.9s var(--ease-in-out) infinite; }
.zi-sug__i.is-done .zi-sug__dot { background: #22c55e; box-shadow: none; }

.zi-sug__t { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.zi-sug__name { font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--pi-ink); }
.zi-sug__m { font-size: 12px; font-weight: 700; color: var(--pi-ink-3); }
.zi-sug__i.is-now .zi-sug__m { color: #22D3EE; animation: sgMagiaText 1s var(--ease-in-out) infinite; }
.zi-sug__i.is-done .zi-sug__m { color: #86efac; }

/* Lo que magIA está leyendo o por marcar brilla antes de cambiar */
.pi .is-magia { animation: dpMagiaFoco 0.9s var(--ease-in-out) infinite; }
/* La fila señalada toma el aire de la elegida: el borde no pasa pegado al círculo */
.pi .pi-ans__row.is-magia { padding-left: 14px; margin-left: -14px; }

/* Dentro del mismo paso el panel se redibuja sin volver a entrar */
.pi-panel.is-quieto { animation: none; }

/* El pie con el elemento listo: magIA a la izquierda, del mismo alto y
   solo con su avatar, y el siguiente a lo ancho */
.pi-panel__foot.zi-foot {
    display: grid;
    grid-template-columns: 3.1rem minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
}

.zi-next {
    display: flex;
    position: relative;
    isolation: isolate;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.zi-next__t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* La cuenta de los dos segundos: el botón se llena antes de pasar solo */
.zi-next.is-cuenta::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    transform-origin: left center;
    animation: ziCuenta 2s linear forwards;
}

.zi-magia-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 3.1rem;
    padding: 0;
    background-image: none;
    background-color: color-mix(in srgb, #22D3EE 12%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #22D3EE 45%, transparent);
}

.zi-magia-mini:hover { background-color: color-mix(in srgb, #22D3EE 20%, transparent); }

/* ══════════════════ El informe final ══════════════════
   Secciones separadas por aire y su título, sin cajas: las etiquetas
   impresas, dónde quedó cada envase, la valoración, la línea de tiempo del
   derrame, el inventario y el registro fotográfico. */
.zi-rep { display: flex; flex-direction: column; gap: 26px; }
.zi-rep__sec { display: flex; flex-direction: column; gap: 8px; }
.zi-rep__saved {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--pi-ink-3);
}

.zi-rep__saved svg { flex: none; margin-top: 3px; color: #9ceab6; }
.zi-rep__meta { margin: 0; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--pi-ink-3); }

.zi-rep__h {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--pi-ink);
}

.zi-rep__labels { display: grid; grid-template-columns: repeat(var(--zi-cols, 2), minmax(0, 1fr)); gap: 14px 12px; }
.zi-rep__photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.zi-rep__fig { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.zi-rep__fig img { display: block; width: 100%; border-radius: 8px; }
.zi-rep__fig figcaption { display: flex; flex-direction: column; gap: 1px; }

.zi-rep__name { font-size: 12.5px; font-weight: 700; line-height: 1.3; color: var(--pi-ink); }
.zi-rep__st { font-size: 11.5px; line-height: 1.35; color: var(--pi-ink-3); }
.zi-rep__p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--pi-ink-2); }
.zi-rep__ok { font-weight: 700; color: #9ceab6; }

.zi-rep__sub {
    margin: 10px 0 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--pi-ink-2);
}

.zi-rep__sub:first-of-type { margin-top: 2px; }

.zi-rep__line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 12px;
    padding: 2px 0;
}

.zi-rep__line .zi-rep__st { text-align: right; }
.zi-rep__t { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.zi-rep__det { font-size: 12px; color: var(--pi-ink-2); }
.zi-rep__det--color { display: inline-flex; align-items: center; gap: 8px; }

.zi-rep__det--color::before {
    content: '';
    flex: none;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
    background: var(--zi-color);
}

/* La línea de tiempo: minuto y segundo, y qué pasó */
.zi-rep__time { display: grid; grid-template-columns: 2.8rem minmax(0, 1fr); gap: 8px; font-size: 12.5px; line-height: 1.4; color: var(--pi-ink-2); }
.zi-rep__clock { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--pi-ink); }
.zi-rep__time.is-ok { color: #9ceab6; }
.zi-rep__time.is-mal { color: #ffb4b4; }
.zi-rep__time.is-temprano { color: #fcd9a0; }

/* La acción secundaria del informe: empezar de nuevo */
.zi-ghost {
    background-image: none;
    background-color: color-mix(in srgb, #22D3EE 12%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #22D3EE 45%, transparent);
    color: var(--pi-ink);
}

.zi-ghost:hover { background-color: color-mix(in srgb, #22D3EE 20%, transparent); }

/* Descargar y empezar de nuevo: una fila, dos columnas iguales */
.pi-panel__foot.zi-foot-rep {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
}

.zi-foot-rep .pi-go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    padding-right: 12px;
    padding-left: 12px;
    white-space: nowrap;
}

/* ══════════════════ La ventana del informe ══════════════════
   Vista previa de las páginas con el membrete de PRL, el aviso de demo y
   las dos acciones en una fila. Va directo en el body, por encima de todo. */
html.zi-bloqueo { overflow: hidden; }

.zi-modal {
    display: flex;
    position: fixed;
    z-index: var(--z-max);
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
}

.zi-modal__veil {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 15, 0.72);
    -webkit-backdrop-filter: blur(var(--glass-blur-soft));
    backdrop-filter: blur(var(--glass-blur-soft));
    animation: dcFadeUp var(--duration-normal) var(--ease-smooth) both;
}

.zi-modal__box {
    display: flex;
    position: relative;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 46rem;
    max-height: calc(100dvh - 1.5rem);
    padding: 18px;
    border-radius: 22px;
    background: #0b1020;
    box-shadow: inset 0 0 0 1px rgba(250, 250, 250, 0.08), 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 64px rgba(0, 0, 0, 0.55);
    animation: dcFadeUp var(--duration-slow) var(--ease-spring) both;
}

.zi-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.zi-modal__t { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.zi-modal__h { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; color: var(--pi-ink); }

.zi-modal__x {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: rgba(250, 250, 250, 0.06);
    color: var(--pi-ink);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-smooth);
}

.zi-modal__x:hover { background: rgba(250, 250, 250, 0.12); }

.zi-modal__demo {
    display: flex;
    gap: 10px;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #fcd9a0;
}

.zi-modal__demo svg { flex: none; margin-top: 2px; }

.zi-modal__pages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-height: 14rem;
    margin: 0 -6px;
    padding: 6px;
    overflow: auto;
}

.zi-modal__page {
    display: block;
    width: 100%;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.35);
}

.zi-modal__wait { margin: auto; font-size: 13px; color: var(--pi-ink-3); }

.zi-modal__foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.zi-modal__foot .pi-go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    padding-right: 12px;
    padding-left: 12px;
    white-space: nowrap;
}

/* La hoja de Excel antes de bajarla: blanca, con su cuadrícula, como se abre */
.zi-sheet { gap: 10px; }

.zi-sheet__file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--pi-ink-2);
}

.zi-sheet__wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.35);
}

.zi-sheet__grid {
    min-width: 100%;
    border-collapse: collapse;
    color: #111827;
    font-size: 12px;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.zi-sheet__grid th,
.zi-sheet__grid td {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.zi-sheet__grid thead th,
.zi-sheet__grid tbody th {
    position: sticky;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.zi-sheet__grid thead th { top: 0; z-index: 1; }
.zi-sheet__grid tbody th { left: 0; }
.zi-sheet__grid .zi-sheet__corner { left: 0; z-index: 2; }
.zi-sheet__grid tr.is-head td { background: #eef2ff; font-weight: 700; }

@media (min-width: 640px) {
    .zi-modal { padding: var(--space-6); }
    .zi-modal__box { gap: 16px; padding: 24px; }
}
