/* =============================================================================
   scan.css — app de escaneo (tema oscuro, portado del prototipo).
   Mobile-first, layout vertical celular. Depende de app.css (tokens + .conn/.dot).
   ============================================================================= */

html, body.tz-scan-body {
    height: 100%;
    margin: 0;
    background: #0f1117;
    overscroll-behavior: none;
}

.tz-view {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Login / overlays centran un "phone" */
#view-login { justify-content: center; align-items: center; padding: 2rem 1rem; }
.tz-phone { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; }

.tz-scan-header { background: var(--card); color: var(--text); }
.tz-scan-sticky { position: sticky; top: 0; z-index: 20; }

/* ── Cámara con retícula ──────────────────────────────────────────────────── */
.tz-cam-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 45vh;
    background: linear-gradient(160deg, #080e1a 0%, #0c1523 100%);
    overflow: hidden;
}
.tz-scan-reader { position: absolute; inset: 0; }
.tz-scan-reader video { width: 100% !important; height: 100% !important; object-fit: cover; }

.tz-reticle-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.tz-reticle-overlay::after {
    content: ''; position: absolute; inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,255,255,.012) 3px, rgba(255,255,255,.012) 4px);
}
.reticle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -52%); width: 220px; height: 150px; }
.reticle::before { content: ''; position: absolute; inset: 0; border: 1.5px solid rgba(59,130,246,.45); border-radius: 4px; }
.tk { position: absolute; width: 16px; height: 16px; border-color: var(--blue); border-style: solid; }
.tk.tl { top: 0; left: 0; border-width: 3px 0 0 3px; }
.tk.tr { top: 0; right: 0; border-width: 3px 3px 0 0; }
.tk.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.tk.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; }
@keyframes scanline { 0% { top: 8%; } 50% { top: 87%; } 100% { top: 8%; } }
.scan-line { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, rgba(59,130,246,.9), transparent); animation: scanline 2.2s ease-in-out infinite; }

/* Controles de cámara (linterna / cambiar / beep) */
.tz-cam-controls { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 14px; z-index: 6; }
.tz-cam-btn {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.18);
    color: #fff; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.tz-cam-btn.active { background: var(--yellow); color: #000; border-color: var(--yellow); }
.tz-cam-btn:disabled { opacity: .4; }

/* ── Feedback de escaneo ──────────────────────────────────────────────────── */
.tz-scan-feedback {
    height: 36px; display: flex; align-items: center; justify-content: center;
    font-weight: 600; color: #fff; transition: background-color .15s ease;
    background: var(--card); flex-shrink: 0;
}
.tz-scan-feedback.ok { background: #198754; }
.tz-scan-feedback.dup { background: var(--yellow); color: #000; }
.tz-scan-feedback.error { background: var(--red); }

/* ── Lista de escaneos ────────────────────────────────────────────────────── */
.tz-scan-list { flex: 0 0 auto; max-height: 26vh; overflow-y: auto; background: var(--bg); }
.si { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.si.new { animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.tz-scan-footer { background: var(--card); position: sticky; bottom: 0; flex-shrink: 0; border-top: 1px solid var(--border); }

/* ── Overlay de carga ─────────────────────────────────────────────────────── */
.tz-overlay {
    position: fixed; inset: 0; background: rgba(15,17,23,.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1080;
}

/* Flash de borde al escanear (verde = ok, amarillo = ya escaneado) */
.tz-cam-wrap.flash-ok::before,
.tz-cam-wrap.flash-dup::before {
    content: ''; position: absolute; inset: 0; z-index: 8; pointer-events: none;
    border: 8px solid transparent; border-radius: 4px;
    animation: tzFlash .5s ease-out;
}
.tz-cam-wrap.flash-ok::before  { border-color: var(--green); box-shadow: inset 0 0 30px rgba(34,197,94,.6); }
.tz-cam-wrap.flash-dup::before { border-color: var(--yellow); box-shadow: inset 0 0 30px rgba(234,179,8,.6); }
@keyframes tzFlash { from { opacity: 1; } to { opacity: 0; } }

/* Overlay de lectura pausada por inactividad */
.tz-cam-paused {
    position: absolute; inset: 0; z-index: 9;
    background: rgba(8,14,26,.88);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    color: #fff; text-align: center; padding: 1rem;
}

/* Toast (mensaje breve que se cierra solo) */
.tz-toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--card); border: 1px solid var(--border); color: var(--text);
    padding: 12px 18px; border-radius: 10px; z-index: 1090;
    box-shadow: 0 8px 30px rgba(0,0,0,.5); font-weight: 600; max-width: 90%;
    display: flex; align-items: center; gap: 10px;
    animation: tzToastIn .2s ease;
}
.tz-toast.ok { border-color: rgba(34,197,94,.5); }
@keyframes tzToastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Items de la cola en el modal */
#colaLista .tz-cola-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }

/* ── Tipografía ampliada (legibilidad en depósito, a distancia) ─────────────── */
.tz-scan-body .form-label { font-size: 17px; font-weight: 600; margin-bottom: .35rem; }
.tz-scan-body .form-control,
.tz-scan-body .form-select { font-size: 18px; padding: .6rem .75rem; }
.tz-scan-body textarea.form-control { font-size: 17px; }
.tz-scan-body .btn { font-size: 18px; }
.tz-scan-body .badge { font-size: 15px; padding: 5px 10px; }
.tz-scan-body .si { font-size: 17px; }
/* Barra de feedback bien grande: se lee de lejos, en movimiento, en el depósito. */
.tz-scan-feedback { font-size: 2.6rem; font-weight: 800; height: 136px; letter-spacing: .3px; line-height: 1.1; text-align: center; padding: 0 12px; }
/* Indicador de operación (Ingreso / Salida a reparto / Entrega…): bien grande. */
#scanTipo { font-size: 1.45rem; font-weight: 800; padding: 6px 16px; border-radius: 9px; }
#scanContador { font-size: 18px; }

/* ── Modales de alerta del scan: grandes e invasivos ────────────────────────
   Ocupan toda la pantalla, con ícono y texto grandes, para que en el depósito
   no pasen desapercibidos. Se marcan con .tz-alert-dialog en el modal-dialog. */
.tz-alert-dialog {
    max-width: 100%;
    width: 100%;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: stretch;
}
.tz-alert-dialog .modal-content {
    border: 0;
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
}
.tz-alert-dialog .modal-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .4rem;
    padding: 1.75rem 1.25rem;
    border-bottom: 0;
}
.tz-alert-dialog .modal-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.15;
}
.tz-alert-dialog .modal-title i {
    font-size: 3.75rem;
    line-height: 1;
    margin: 0 !important;
}
.tz-alert-dialog .modal-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    overflow-y: auto;
    text-align: center;
    padding: 1rem 1.5rem;
    font-size: 1.5rem;
    line-height: 1.4;
}
.tz-alert-dialog .modal-body > * { max-width: 100%; margin-bottom: 0; }
.tz-alert-dialog .modal-body p { font-size: 1.5rem; }
.tz-alert-dialog .modal-body .mono { font-size: 1.7rem; }
.tz-alert-dialog .modal-body ul,
.tz-alert-dialog .modal-body textarea,
.tz-alert-dialog .modal-body .form-check {
    width: 100%;
    text-align: left;
    font-size: 1.35rem;
}
.tz-alert-dialog .modal-body .form-label { font-size: 1.3rem; }
.tz-alert-dialog .modal-body .form-check-input { width: 1.5em; height: 1.5em; margin-top: .15em; }
.tz-alert-dialog .modal-footer {
    flex-direction: column-reverse;
    flex-wrap: nowrap;
    gap: .75rem;
    border-top: 0;
    padding: 1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
}
.tz-alert-dialog .modal-footer > .btn {
    width: 100%;
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    padding: .9rem 1rem;
}
