/* Casa Fenk — tokens y piezas base compartidas por web, CRM y presupuesto.
   Decisiones en DESIGN.md. Archivo se carga desde Google Fonts en cada página:
   https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,300..900&display=swap */

:root {
  /* marca */
  --fenk-red: #e3000f;
  --fenk-red-press: #b8000c;
  --fenk-red-wash: #fdecec;
  --carbon: #26292e;
  --carbon-2: #31353b;
  --carbon-3: #3d424a;
  --shop-orange: #f07c1a;

  /* neutros (misma temperatura, levemente fría) */
  --ink: #1c1f23;
  --ink-2: #4a4f57;
  --ink-3: #737a84;
  --line: #d9dcdf;
  --line-soft: #e6e8ea;
  --steel: #e8eaec;
  --paper: #f5f6f6;
  --plate: #fcfcfb;
  --on-dark: #f3f4f5;
  --on-dark-2: #aeb4bc;

  /* estado (siempre con ícono + texto) */
  --ok: #1b8a3a;
  --ok-wash: #e6f4ea;
  --warn: #b86e00;
  --warn-wash: #fdf1dc;
  --bad: #c62828;
  --bad-wash: #fbe9e9;
  --info: #2a62b8;
  --info-wash: #e7eef9;

  /* tipo */
  --font: "Archivo", "Segoe UI", system-ui, sans-serif;
  --t-xs: 0.8125rem;   /* 13 */
  --t-sm: 0.9375rem;   /* 15 */
  --t-md: 1.125rem;    /* 18 */
  --t-lg: 1.5rem;      /* 24 */
  --t-xl: 2.5rem;      /* 40 */
  --t-xxl: clamp(2.75rem, 1.6rem + 4.6vw, 4.5rem); /* 44 a 72 */

  /* espacio (base 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* radios por jerarquía */
  --r-lg: 12px;
  --r-md: 6px;
  --r-sm: 3px;

  /* elevación: solo lo que flota */
  --float: 0 1px 2px rgba(28, 31, 35, 0.06), 0 8px 24px rgba(28, 31, 35, 0.12);
  --float-lg: 0 2px 4px rgba(28, 31, 35, 0.06), 0 24px 48px rgba(28, 31, 35, 0.18);

  /* movimiento */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --fast: 140ms;
  --base: 200ms;

  /* capas (escala única) */
  --z-sticky: 10;
  --z-drawer: 30;
  --z-chat: 40;
  --z-toast: 50;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-sm);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

/* los tres anchos de Archivo */
.t-brand {
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: -0.02em;
  line-height: 1.02;
}
.t-data {
  font-weight: 600;
  font-variation-settings: "wdth" 75;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.muted { color: var(--ink-3); }

:focus-visible {
  outline: 2px solid var(--fenk-red);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------- botones ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--t-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease, transform var(--fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--fenk-red); color: #fff; }
.btn-primary:hover { background: var(--fenk-red-press); }

.btn-dark { background: var(--carbon); color: var(--on-dark); }
.btn-dark:hover { background: var(--carbon-3); }

.btn-line { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-line:hover { border-color: var(--ink-3); background: var(--plate); }

.btn-ghost { background: transparent; color: var(--ink-2); padding: 0 var(--s3); }
.btn-ghost:hover { background: var(--steel); color: var(--ink); }

.btn-sm { min-height: 34px; padding: 0 var(--s3); font-size: var(--t-xs); }

/* ---------------------------- campos ---------------------------- */

.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--plate);
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}
.textarea { min-height: 96px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.14);
}
.input[aria-invalid="true"] { border-color: var(--bad); }
.hint { font-size: var(--t-xs); color: var(--ink-3); }
.error-text { font-size: var(--t-xs); color: var(--bad); }

/* --------------- placa de características (specs) --------------- */

.plate {
  position: relative;
  isolation: isolate;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s5) var(--s5) var(--s4);
}
.plate::before, .plate::after,
.plate > .rivets::before, .plate > .rivets::after {
  content: "";
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--steel);
  box-shadow: inset 0 0 0 1px var(--line);
}
.plate::before { top: 8px; left: 8px; }
.plate::after { top: 8px; right: 8px; }
.plate > .rivets::before { bottom: 8px; left: 8px; }
.plate > .rivets::after { bottom: 8px; right: 8px; }

.plate-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s3);
  padding: 0 var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
}
.plate-title { font-weight: 700; font-size: var(--t-sm); }
.plate-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  margin: 0;
  padding: var(--s2) var(--s2) 0;
}
.plate-grid dt, .plate-grid dd {
  margin: 0;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}
.plate-grid dt { color: var(--ink-3); font-size: var(--t-xs); padding-right: var(--s3); }
.plate-grid dd {
  font-weight: 600;
  font-variation-settings: "wdth" 75;
  font-variant-numeric: tabular-nums;
}
.plate-grid dt:nth-last-of-type(1), .plate-grid dd:nth-last-of-type(1) { border-bottom: 0; }

/* ------------------------ estados / chips ------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  font-weight: 600;
  line-height: 1.6;
  background: var(--steel);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; flex: none; }
.chip-ok { background: var(--ok-wash); color: var(--ok); }
.chip-warn { background: var(--warn-wash); color: var(--warn); }
.chip-bad { background: var(--bad-wash); color: var(--bad); }
.chip-info { background: var(--info-wash); color: var(--info); }
.chip-red { background: var(--fenk-red-wash); color: var(--fenk-red-press); }

.dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.22);
  flex: none;
}
.dot-ai { background: var(--shop-orange); box-shadow: 0 0 0 3px rgba(240, 124, 26, 0.22); }

/* ---------------------------- toast ---------------------------- */

.toast-zone {
  position: fixed;
  left: 50%;
  bottom: var(--s5);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: grid;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--carbon);
  color: var(--on-dark);
  padding: 12px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--float);
  font-size: var(--t-sm);
  animation: toast-in var(--base) var(--ease-out);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
