/* custom.css — estilos específicos de la terminal que Tailwind no cubre */

/* Fuente mínima industrial */
body {
  font-size: 18px;
}

/* Bloqueo global de selección/long-press en planta (guantes, tablet Redmi):
   un tap accidental a veces dispara selección de texto en vez de la acción.
   Re-habilitar en inputs/textareas para que el numpad PIN y los buscadores funcionen. */
html, body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select, [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Cámara de reconocimiento facial */
#camera-preview {
  width: 100%;
  max-height: 55vh;
  object-fit: cover;
  border-radius: 0.75rem;
  background: #000;
  display: block;
}

/* Canvas oculto para captura */
#capture-canvas {
  display: none;
}

/* Numpad PIN */
.pin-btn {
  min-height: clamp(52px, 9vh, 72px);
  font-size: clamp(1.25rem, 3.5vh, 1.75rem);
  font-weight: 700;
  touch-action: manipulation;
}

/* Puntos PIN */
.pin-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.15s;
}
.pin-dot.filled {
  background: #1d4ed8;
}

/* Tarjeta de dashboard */
.action-card {
  min-height: 140px;
  touch-action: manipulation;
}

/* Estado de fichaje */
.status-badge {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.35rem 1rem;
  border-radius: 9999px;
}

/* Botones "mantener apretado": evitan disparos accidentales (fat fingers/guantes).
   Multi-feedback (los operarios en planta no veían bien el indicador anterior):
     1. Border glow inmediato al presionar (saber que arrancó el hold)
     2. Fill progresivo amarillo brillante (alto contraste vs luz industrial)
     3. Anillo SVG circular con stroke-dashoffset animado
     4. Contador 3→2→1 que pulsa con cada segundo
     5. Vibración cada 1s (manejada en JS) */
.hold-btn {
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: box-shadow 0.1s ease-out, transform 0.1s ease-out;
}
.hold-btn:has(.hold-fill.holding),
.hold-btn.hold-active {
  /* Glow exterior + leve scale para confirmar que el hold está activo.
     hold-active es fallback JS para Chrome viejo (MIUI/Redmi) sin :has(). */
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.9), 0 0 20px 6px rgba(251, 191, 36, 0.5);
  transform: scale(0.97);
}
.hold-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  /* Capa negra semi-transparente: oscurece el color original del botón
     en vez de pintarlo de amarillo (no compite con el anillo y el glow). */
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  border-radius: inherit;
  z-index: 5;
}
.hold-fill.holding {
  width: 100%;
  transition: width 3s linear;   /* debe coincidir con HOLD_MS en workorder.js */
}
/* Anillo SVG circular de progreso (otra capa de feedback) */
.hold-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transform: rotate(-90deg); /* arrancar desde las 12 en punto */
}
.hold-ring.holding {
  opacity: 1;
}
.hold-ring .hr-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 6;
}
.hold-ring .hr-fill {
  fill: none;
  stroke: #fff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 276.46;       /* 2 * π * 44 (radio) */
  stroke-dashoffset: 276.46;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.7));
}
.hold-ring.holding .hr-fill {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 3s linear;
}
/* Contador 3 → 2 → 1 sobre el botón mientras se sostiene */
.hold-counter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85), 0 0 12px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 20;
  line-height: 1;
  animation: hold-counter-pulse 1s ease-in-out infinite;
}
@keyframes hold-counter-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.25); }
}

/* Animación de escaneo QR */
@keyframes scan-line {
  0%   { top: 10%; }
  50%  { top: 85%; }
  100% { top: 10%; }
}
.qr-scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #22c55e;
  animation: scan-line 2s linear infinite;
  box-shadow: 0 0 8px #22c55e;
}

/* Spinner de carga */
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #e5e7eb;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
#toast {
  transition: opacity 0.3s, transform 0.3s;
}

/* Safe area para iPhone — status bar en PWA standalone (viewport-fit=cover) */
.safe-bottom {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Safe area: ver <style> en index.html (carga después de Tailwind CDN = prioridad garantizada) */

/* Drag-and-drop de tarjetas del dashboard (SortableJS) */
.sortable-ghost {
  opacity: 0.25;
}
.sortable-chosen {
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  z-index: 50;
  position: relative;
}
[data-card-id] {
  touch-action: pan-y;
  cursor: grab;
}

/* dvh = dynamic viewport height: excluye la toolbar del browser en iOS Safari. */
.h-dvh {
  height: 100vh;
  height: 100dvh;
}
.min-h-dvh {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── INDUSTRIAL HMI STYLES ─────────────────────────────────────────────────── */

/* Reloj digital en el dashboard */
.pac-clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  font-feature-settings: "tnum";
}

/* Indicador de estado pulsante (para OTs en curso, fichaje activo) */
.status-pulse {
  animation: status-pulse-anim 2s ease-in-out infinite;
}
@keyframes status-pulse-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}

/* Indicador de alarma (urgente / vencido) */
.alarm-pulse {
  animation: alarm-pulse-anim 0.8s ease-in-out infinite;
}
@keyframes alarm-pulse-anim {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Métricas del dashboard: panel de datos denso */
.metrics-strip {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 2px solid rgba(255,255,255,0.08);
}

.metric-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.4rem;
  min-width: 0;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-top: 0.2rem;
  white-space: nowrap;
}

/* Tarjeta de WO con indicador de estado industrial */
.wo-card {
  position: relative;
  overflow: hidden;
}
.wo-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.wo-card.state-progress::before { background: #2563eb; }
.wo-card.state-ready::before    { background: #16a34a; }
.wo-card.state-pending::before  { background: #d97706; }
.wo-card.state-waiting::before  { background: #9333ea; }
.wo-card.state-paused::before   { background: #dc2626; animation: alarm-pulse-anim 1.2s ease-in-out infinite; }

/* Badge de tiempo (timer en OT activa) */
.timer-badge {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.75rem;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Progress bar de producción */
.prod-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}
.prod-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* Botón flotante QR */
.fab-qr {
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.5), 0 2px 6px rgba(0,0,0,0.3);
  transition: all 0.15s ease;
}
.fab-qr:active {
  transform: scale(0.92);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Calculadora display HMI-style */
.calc-display {
  background: #0f172a;
  font-family: "SF Mono", "Courier New", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* Separador de sección en listas */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #9ca3af;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* Componente de cantidad industrial (grande, fat-finger friendly) */
.qty-display {
  font-size: 2.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Color coding de stock */
.stock-ok      { color: #16a34a; }
.stock-low     { color: #d97706; }
.stock-zero    { color: #dc2626; }
.stock-ok-bg   { background: #f0fdf4; border-color: #bbf7d0; }
.stock-low-bg  { background: #fffbeb; border-color: #fde68a; }
.stock-zero-bg { background: #fef2f2; border-color: #fecaca; }

/* Historial de calculadora */
.history-item {
  font-size: 0.8rem;
  border-left: 3px solid #e5e7eb;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: background 0.1s;
}
.history-item:active { background: #f3f4f6; }
.history-result {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #1e40af;
}

/* ── Manual de Producción (render de Odoo Knowledge) ──────────────────────── */
/* El contenido lo estila /api/sop/knowledge.css (motor compartido con buscar, clases kn-*);
   acá van solo los tokens de la tablet: letra grande para leer de parado, acento ámbar de la sección. */
.sop-prose {
  --kn-text: #1f2937;
  --kn-muted: #6b7280;
  --kn-accent: #d97706;
  --kn-link: #1d4ed8;
  --kn-line: #e5e7eb;
  --kn-soft: #f9fafb;
  --kn-font: inherit;
  --kn-display: inherit;
}
.sop-prose.kn-doc { font-size: 1.05rem; line-height: 1.7; }
.sop-prose.kn-doc h1 { color: #92400e; }
.sop-prose.kn-doc h2 { color: #b45309; }
.sop-prose.kn-doc img.kn-img { cursor: zoom-in; border: 1px solid #f3f4f6; }
.sop-prose.kn-doc .kn-file, .sop-prose.kn-doc .kn-video { padding: 0.7em 1em; font-size: 1.05rem; }

/* line-clamp helper para previews de memos */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Documento controlado (Manual de Producción): membrete e historial dibujados por Odoo ─────────────────
   Tipografías de marca (Kanit / DM Sans, licencia OFL en /fonts/OFL.txt) para que el membrete se vea igual
   que en Odoo y en buscar. La tabla del membrete no entra en una pantalla angosta: desliza dentro de su caja. */
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/kanit-500.woff2") format("woff2"); }
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/kanit-600.woff2") format("woff2"); }
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/kanit-700.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/dmsans-400.woff2") format("woff2"); }
.sop-membrete { margin: 0 0 20px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.sop-membrete table { min-width: 760px; }
.sop-historial { margin: 28px 0 8px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.sop-historial table { min-width: 640px; }
.sop-prose.kn-doc .sop-membrete table, .sop-prose.kn-doc .sop-historial table { font-size: 12px; line-height: 1.3; }

