/* ==========================================================================
   stock.css — Módulo Control de Stock Visual
   Paleta: logística — azul noche, cian, blanco limpio
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --stk-bg:      #080e18;
  --stk-surface: #0d1421;
  --stk-card:    rgba(13, 20, 33, 0.9);
  --stk-border:  rgba(6,182,212,0.15);
  --stk-cyan:    #06b6d4;
  --stk-blue:    #3b82f6;
  --stk-green:   #22c55e;
  --stk-yellow:  #f59e0b;
  --stk-red:     #ef4444;
  --stk-text:    #f0f9ff;
  --stk-muted:   #94a3b8;
  --r-sm: 8px; --r-md: 14px; --r-lg: 20px; --r-xl: 26px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; background: var(--stk-bg); color: var(--stk-text);
  font-family: 'Inter', sans-serif; font-size: 15px;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}

.stk-app { display: flex; flex-direction: column; min-height: 100dvh; max-width: 480px; margin: 0 auto; }

/* ── Header ── */
.stk-header {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 100;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(8,14,24,0.98) 70%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.stk-back-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(6,182,212,0.1); border: 1px solid rgba(6,182,212,0.25);
  color: var(--stk-cyan); cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all 0.2s;
}
.stk-back-btn:hover { background: rgba(6,182,212,0.2); }
.stk-title-wrap { flex: 1; }
.stk-title { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.stk-subtitle { font-size: 0.72rem; color: var(--stk-muted); margin-top: 1px; }

.stk-location-input {
  flex: 0 0 auto; max-width: 120px;
  background: rgba(6,182,212,0.08); border: 1px solid rgba(6,182,212,0.2);
  border-radius: var(--r-sm); color: var(--stk-cyan); padding: 5px 8px;
  font-size: 0.72rem; font-family: 'Inter', sans-serif; outline: none;
}
.stk-location-input::placeholder { color: rgba(6,182,212,0.4); }

/* ── Cámara ── */
.stk-camera-section {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #040910; overflow: hidden; margin-top: 70px; flex-shrink: 0;
}
#stkVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
#stkCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; cursor: crosshair; }

.stk-cam-status {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 10; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em;
  padding: 4px 12px; border-radius: 20px; backdrop-filter: blur(8px);
  white-space: nowrap; transition: all 0.3s;
  background: rgba(6,182,212,0.15); border: 1px solid rgba(6,182,212,0.3); color: var(--stk-cyan);
}
.stk-cam-status.scanning::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--stk-cyan); margin-right: 6px;
  vertical-align: middle; animation: stkPulse 1.4s infinite;
}
@keyframes stkPulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.7); } }

/* ── Controles ── */
.stk-controls {
  display: flex; gap: 8px; padding: 10px 14px;
  background: var(--stk-surface); border-bottom: 1px solid var(--stk-border); align-items: center;
}
.stk-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: var(--r-md); border: 1px solid; font-size: 0.8rem; font-weight: 600;
  font-family: 'Inter', sans-serif; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.stk-btn.primary { background: rgba(6,182,212,0.1); border-color: rgba(6,182,212,0.25); color: var(--stk-cyan); }
.stk-btn.primary:hover { background: rgba(6,182,212,0.2); }
.stk-btn.freeze { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.25); color: var(--stk-yellow); }
.stk-btn.freeze:hover, .stk-btn.freeze.active { background: rgba(245,158,11,0.2); }
.stk-btn.export { margin-left:auto; background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.25); color: var(--stk-green); }
.stk-btn.export:hover { background: rgba(34,197,94,0.2); }
.stk-btn.secondary { background: rgba(156,163,175,0.1); border-color: rgba(156,163,175,0.25); color: var(--stk-muted); }
.stk-btn.secondary:hover { background: rgba(156,163,175,0.2); }
.stk-btn.danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); color: var(--stk-red); }

/* ── Resumen de stock ── */
.stk-summary-bar {
  display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto;
  background: var(--stk-surface); border-bottom: 1px solid var(--stk-border);
  scrollbar-width: none;
}
.stk-summary-bar::-webkit-scrollbar { display: none; }
.stk-stat { flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px; border-radius: var(--r-md); border: 1px solid; }
.stk-stat.items  { background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.2); }
.stk-stat.units  { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); }
.stk-stat.alerts { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.2); }
.stk-stat-num  { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; line-height: 1; }
.stk-stat.items .stk-stat-num  { color: var(--stk-cyan); }
.stk-stat.units .stk-stat-num  { color: var(--stk-blue); }
.stk-stat.alerts .stk-stat-num { color: var(--stk-red); }
.stk-stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--stk-muted); margin-top: 3px; font-weight: 600; }

/* ── Tabla de inventario ── */
.stk-inventory-section { flex: 1; padding: 14px 14px 80px; display: flex; flex-direction: column; gap: 10px; }

.stk-section-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--stk-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 2px;
}
.stk-section-title i { color: var(--stk-cyan); }

/* Estado inicial */
.stk-empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 20px; text-align: center;
  border: 1px dashed rgba(6,182,212,0.2); border-radius: var(--r-xl); margin-top: 10px;
}
.stk-empty-icon { font-size: 3.5rem; }
.stk-empty-title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1rem; }
.stk-empty-text { font-size: 0.83rem; color: var(--stk-muted); line-height: 1.5; }

/* Fila de ítem de inventario */
.stk-item-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--stk-card); border: 1px solid var(--stk-border);
  animation: stkIn 0.3s ease both;
}
@keyframes stkIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.stk-item-info { min-width: 0; }
.stk-item-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stk-item-pos  { font-size: 0.72rem; color: var(--stk-muted); margin-top: 2px; }
.stk-item-brand { font-size: 0.72rem; color: rgba(6,182,212,0.7); margin-top: 1px; }

.stk-item-qty { text-align: center; flex-shrink: 0; }
.stk-qty-num { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; color: var(--stk-cyan); line-height: 1; }
.stk-qty-label { font-size: 0.62rem; text-transform: uppercase; color: var(--stk-muted); letter-spacing: 0.06em; }

.stk-item-status { flex-shrink: 0; }
.stk-status-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid; white-space: nowrap;
}
.stk-status-badge.ordenado    { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.25);  color: var(--stk-green); }
.stk-status-badge.bajo        { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3);  color: var(--stk-yellow); }
.stk-status-badge.faltante    { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.3);   color: var(--stk-red); }
.stk-status-badge.vencido     { background: rgba(239,68,68,0.18);  border-color: rgba(239,68,68,0.4);   color: var(--stk-red); animation: dangerPulse 1s infinite; }
.stk-status-badge.desorganiz  { background: rgba(245,158,11,0.1);  border-color: rgba(245,158,11,0.25); color: var(--stk-yellow); }
.stk-status-badge.default     { background: rgba(148,163,184,0.1); border-color: rgba(148,163,184,0.2); color: var(--stk-muted); }
@keyframes dangerPulse { from { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } to { box-shadow: 0 0 0 6px rgba(239,68,68,0); } }

/* Resumen general (al final del análisis) */
.stk-summary-card {
  padding: 16px; border-radius: var(--r-lg); background: var(--stk-card);
  border: 1px solid var(--stk-border); display: flex; flex-direction: column; gap: 8px;
}
.stk-summary-title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.95rem; color: var(--stk-cyan); }
.stk-summary-row { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 4px 0; border-bottom: 1px solid rgba(6,182,212,0.08); }
.stk-summary-row:last-child { border-bottom: none; }
.stk-summary-row span:first-child { color: var(--stk-muted); }
.stk-summary-row span:last-child  { font-weight: 600; }

/* Spinner */
.stk-spinner { width: 44px; height: 44px; border: 3px solid rgba(6,182,212,0.15); border-top-color: var(--stk-cyan); border-radius: 50%; animation: stkspin 0.9s linear infinite; margin: 0 auto; }
@keyframes stkspin { to { transform: rotate(360deg); } }

/* Toast */
.stk-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 200; padding: 10px 20px; border-radius: var(--r-md);
  background: rgba(13,20,33,0.95); border: 1px solid var(--stk-cyan);
  color: var(--stk-text); font-size: 0.85rem; font-weight: 600;
  pointer-events: none; opacity: 0; transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap; backdrop-filter: blur(10px);
}
.stk-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(6,182,212,0.25); border-radius: 2px; }
