/* ==========================================================================
   Arteria — Components
   Every interactive component ships default / hover / focus / active /
   disabled states per the product register. Shared by app + admin.
   ========================================================================== */

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 48px; padding: 0 var(--space-6); border-radius: var(--radius-full);
  font-weight: 600; font-size: 0.9375rem; white-space: nowrap;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-sm) var(--ease-out), box-shadow var(--dur-sm) var(--ease-out), opacity var(--dur-sm) var(--ease-out);
  cursor: pointer; border: 1px solid transparent; min-width: 44px;
}
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn.is-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-sm { height: 38px; padding: 0 var(--space-4); font-size: 0.8125rem; border-radius: var(--radius-full); }
.btn-lg { height: 56px; padding: 0 var(--space-8); font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius-full); flex-shrink: 0; }
.btn-icon.btn-sm { width: 36px; height: 36px; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary { background: var(--brand); color: var(--text-on-brand); box-shadow: 0 1px 0 oklch(0 0 0 / 0.1); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { background: var(--brand-active); }

.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-raised); border-color: var(--text-faint); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

.btn-live { background: var(--live-subtle); color: var(--live); border-color: color-mix(in oklch, var(--live) 35%, transparent); }
.btn-live:hover { background: color-mix(in oklch, var(--live) 22%, var(--live-subtle)); }

.btn-danger { background: transparent; color: var(--crimson); border-color: color-mix(in oklch, var(--crimson) 40%, transparent); }
.btn-danger:hover { background: var(--crimson-subtle); }

.btn-glass {
  background: color-mix(in oklch, var(--ink-1) 55%, transparent);
  backdrop-filter: blur(16px);
  color: var(--text); border-color: oklch(1 0 0 / 0.12);
}
.btn-glass:hover { background: color-mix(in oklch, var(--ink-1) 72%, transparent); }

/* ---- Chips / pills / tags ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 var(--space-4); border-radius: var(--radius-full);
  font-size: 0.8125rem; font-weight: 500; background: var(--surface-3); color: var(--text-secondary);
  border: 1px solid var(--border); transition: all var(--dur-sm) var(--ease-out); cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--brand-subtle); color: var(--brand); border-color: color-mix(in oklch, var(--brand) 40%, transparent); }
.chip-row { display: flex; gap: var(--space-2); overflow-x: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 var(--space-3); border-radius: var(--radius-full);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.01em;
}
.badge-verde { background: var(--verde-subtle); color: var(--verde); }
.badge-ambar { background: var(--ambar-subtle); color: var(--ambar); }
.badge-crimson { background: var(--crimson-subtle); color: var(--crimson); }
.badge-live { background: var(--live-subtle); color: var(--live); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-dot.pulse { animation: dot-pulse 2s var(--ease-in-out) infinite; }
@keyframes dot-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---- Cards ---- */
.card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; transition: border-color var(--dur-sm) var(--ease-out), transform var(--dur-sm) var(--ease-out);
}
.card.is-pressable { cursor: pointer; }
.card.is-pressable:active { transform: scale(0.98); }
.card-media { aspect-ratio: 4/3; overflow: hidden; position: relative; background: var(--surface-3); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: var(--space-4); }
.card-pad { padding: var(--space-5); }

/* ---- Stop / list row ---- */
.list-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0; cursor: pointer; transition: opacity var(--dur-sm) var(--ease-out);
}
.list-row:active { opacity: 0.7; }
.list-row-thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; background: var(--surface-3); }
.list-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-row-body { min-width: 0; flex: 1; }
.list-row-chevron { flex-shrink: 0; color: var(--text-faint); width: 18px; height: 18px; }

/* ---- Stat / metric tile ---- */
.stat {
  display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.01em; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); }
.stat-delta { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; }
.stat-delta.is-up { color: var(--verde); }
.stat-delta.is-down { color: var(--crimson); }

/* ---- Rating stars ---- */
.stars { display: inline-flex; gap: 2px; color: var(--ambar); }
.stars svg { width: 14px; height: 14px; }
.stars.stars-lg svg { width: 20px; height: 20px; }

/* ---- Avatar ---- */
.avatar { border-radius: 50%; overflow: hidden; flex-shrink: 0; background: var(--surface-3); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Sheet (bottom drawer) ---- */
.sheet-scrim {
  position: fixed; inset: 0; background: oklch(0 0 0 / 0.55); z-index: var(--z-overlay);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-md) var(--ease-out);
}
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-modal);
  background: var(--surface-2); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border); border-bottom: none;
  padding: var(--space-3) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform var(--dur-lg) var(--ease-drawer);
  max-height: 85%; overflow-y: auto;
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: var(--radius-full); background: var(--border-strong); margin: 0 auto var(--space-4); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 100px; z-index: var(--z-toast);
  transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--ink-1); color: var(--ink-9); border: 1px solid var(--ink-3);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg); font-size: 0.875rem; font-weight: 500;
  transition: transform var(--dur-md) var(--ease-out), opacity var(--dur-md) var(--ease-out);
  display: flex; align-items: center; gap: var(--space-2); white-space: nowrap;
}
.toast.is-open { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---- Form controls ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.input, .select, .textarea {
  height: 48px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  font-size: 0.9375rem; transition: border-color var(--dur-sm) var(--ease-out), background-color var(--dur-sm) var(--ease-out);
  width: 100%;
}
.input::placeholder { color: var(--text-faint); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-ring); }
.textarea { height: auto; min-height: 96px; padding: var(--space-3) var(--space-4); resize: vertical; }
.field-hint { font-size: 0.75rem; color: var(--text-muted); }
.field-error { font-size: 0.75rem; color: var(--crimson); }
.input.has-error { border-color: var(--crimson); }

.toggle { position: relative; width: 44px; height: 26px; border-radius: var(--radius-full); background: var(--surface-3); border: 1px solid var(--border); flex-shrink: 0; cursor: pointer; transition: background-color var(--dur-sm) var(--ease-out); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-faint); transition: transform var(--dur-sm) var(--ease-out), background-color var(--dur-sm) var(--ease-out); }
.toggle.is-on { background: var(--brand); border-color: var(--brand); }
.toggle.is-on::after { transform: translateX(18px); background: var(--text-on-brand); }

.checkbox { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--dur-sm) var(--ease-out); flex-shrink: 0; }
.checkbox.is-checked { background: var(--brand); border-color: var(--brand); }
.checkbox svg { width: 13px; height: 13px; color: var(--text-on-brand); opacity: 0; transform: scale(0.6); transition: all var(--dur-sm) var(--ease-out); }
.checkbox.is-checked svg { opacity: 1; transform: scale(1); }

.radio { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.radio.is-checked { border-color: var(--brand); }
.radio::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); transform: scale(0); transition: transform var(--dur-sm) var(--ease-out); }
.radio.is-checked::after { transform: scale(1); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: var(--radius-full); border: 1px solid var(--border); }
.segmented-item { padding: 7px 16px; border-radius: var(--radius-full); font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all var(--dur-sm) var(--ease-out); }
.segmented-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---- Empty / loading states ---- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-16) var(--space-6); gap: var(--space-3); }
.empty-state-icon { width: 56px; height: 56px; border-radius: var(--radius-lg); background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-faint); margin-bottom: var(--space-2); }
.empty-state-icon svg { width: 26px; height: 26px; }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-raised) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: skeleton-sweep 1.6s ease-in-out infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Progress bar ---- */
.progress { height: 4px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: var(--radius-full); transition: width var(--dur-lg) var(--ease-out); }

/* ---- Table (admin) ---- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 0.75rem; letter-spacing: 0.02em; text-transform: uppercase; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.is-hoverable:hover td { background: var(--surface-2); }

/* ---- Sidebar nav (admin) ---- */
.sidebar-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  transition: background-color var(--dur-sm) var(--ease-out), color var(--dur-sm) var(--ease-out); cursor: pointer;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link:hover { background: var(--surface-3); color: var(--text); }
.sidebar-link.is-active { background: var(--brand-subtle); color: var(--brand); }
.sidebar-group-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); padding: var(--space-4) var(--space-3) var(--space-2); }

/* ---- Tooltip ---- */
.tooltip {
  position: absolute; background: var(--ink-2); color: var(--ink-9); font-size: 0.75rem; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-xs); box-shadow: var(--shadow-md);
  opacity: 0; transform: scale(0.95); pointer-events: none; transition: opacity 125ms var(--ease-out), transform 125ms var(--ease-out);
  z-index: var(--z-tooltip); white-space: nowrap;
}
.tooltip.is-visible { opacity: 1; transform: scale(1); }

/* ---- Scan reticle (AR) ---- */
.reticle { position: relative; width: 220px; height: 220px; }
.reticle-corner { position: absolute; width: 32px; height: 32px; border-color: var(--live); }
.reticle-corner.tl { top: 0; left: 0; border-top: 3px solid; border-left: 3px solid; border-radius: 14px 0 0 0; }
.reticle-corner.tr { top: 0; right: 0; border-top: 3px solid; border-right: 3px solid; border-radius: 0 14px 0 0; }
.reticle-corner.bl { bottom: 0; left: 0; border-bottom: 3px solid; border-left: 3px solid; border-radius: 0 0 0 14px; }
.reticle-corner.br { bottom: 0; right: 0; border-bottom: 3px solid; border-right: 3px solid; border-radius: 0 0 14px 0; }
.reticle.is-locked .reticle-corner { border-color: var(--verde); transition: border-color var(--dur-ar) var(--ease-out); }
.scan-line {
  position: absolute; left: 8px; right: 8px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--live), transparent);
  box-shadow: 0 0 12px var(--live);
  animation: scan-sweep 2.2s var(--ease-in-out) infinite;
}
@keyframes scan-sweep { 0% { top: 8px; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { top: calc(100% - 10px); opacity: 0; } }

/* ---- Passport stamp ---- */
.stamp {
  border: 2px solid var(--brand); border-radius: var(--radius-lg);
  color: var(--brand); display: inline-flex; flex-direction: column; align-items: center;
  padding: var(--space-4) var(--space-6); transform: rotate(-4deg);
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---- Reveal-on-load (staggered) ----
   Runs as a plain autoplaying CSS animation (fill-mode both), NOT gated
   behind a JS-added class. JS (initReveal) only sets --reveal-delay for
   stagger; if JS never runs, animation-delay defaults to 0 and the element
   still fades in on its own. This guarantees content is never invisible
   in headless renders, hidden tabs, or if the script fails. ---- */
@media (prefers-reduced-motion: no-preference) {
  .reveal-init {
    animation: reveal-up var(--dur-lg) var(--ease-out) both;
    animation-delay: var(--reveal-delay, 0ms);
  }
}
@keyframes reveal-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
