/* =========================================================
   base.css — Tokens de DESIGN.md, reset y componentes compartidos
   Inventario Tecnológico · ISTSGA
   ========================================================= */

:root {
  /* Marca San Gabriel */
  --navy: #1e3453;
  --navy-900: #121e30;
  --navy-700: #2b4a72;
  --gold: #d2a648;
  --gold-700: #9c7424;
  --gold-50: #fbf6ea;
  --blue: #004c82;
  --blue-700: #003a63;

  /* Superficies y texto */
  --ground: #ebedef;
  --panel: #ffffff;
  --ink: #1d3744;
  --ink-2: #4b5d69;
  --ink-on-navy: #d9e1ec;
  --line: #d6dbe0;
  --line-2: #e6e9ec;

  /* Estados (esquema: estado_operativo / estado_inventario) */
  --ok: #1d6b42;
  --ok-50: #e6f2eb;
  --warn: #8a4f00;
  --warn-50: #fbf0dc;
  --maint: #004c82;
  --maint-50: #e3eef7;
  --bad: #b3261e;
  --bad-50: #f8e5e3;

  /* Tipografía */
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Espaciado y forma */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(18, 30, 48, 0.06), 0 6px 18px -8px rgba(18, 30, 48, 0.18);
  --shadow-lift: 0 2px 4px rgba(18, 30, 48, 0.08), 0 16px 32px -12px rgba(18, 30, 48, 0.32);
  --wrap: 1200px;

  /* Movimiento: curvas propias, duraciones cortas y solo transform/opacity.
     Las salidas van más rápido que las entradas. */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);      /* entrar, salir y responder al usuario */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); /* lo que se mueve o gira dentro de la pantalla */
  --dur-rapida: 160ms; /* color, borde, presión de botón */
  --dur-media: 220ms;  /* menús, ventanas, desplazamientos */
  --dur-salida: 160ms; /* cierre de menús y ventanas */
  --mov-presion: 0.97;           /* escala del botón al presionarlo */
  --mov-elevar: -4px;            /* etiqueta señalada desde un chip */
  --mov-zoom: 1.04;              /* foto bajo el puntero */
  --mov-entrada-y: 8px;          /* ventanas: suben un poco al abrir */
  --mov-entrada-escala: 0.97;    /* ventanas: nunca desde 0 */
  --mov-menu-y: -6px;            /* menú del encabezado: baja al abrir */
}

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

html { scroll-behavior: smooth; scroll-padding-top: 96px; scrollbar-color: #a9b3bd var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0; text-wrap: balance; color: var(--navy); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: var(--blue); text-underline-offset: 3px; text-decoration-thickness: 1px; }
@media (hover: hover) and (pointer: fine) { a:hover { color: var(--blue-700); } }
strong { font-weight: 700; }
[hidden] { display: none !important; }

::selection { background: var(--gold); color: var(--navy-900); }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: #a9b3bd; border: 3px solid var(--ground); border-radius: 12px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--s-5);
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--gold);
  color: var(--navy-900);
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--s-3); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 600 1rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-rapida) var(--ease-out), border-color var(--dur-rapida) var(--ease-out), color var(--dur-rapida) var(--ease-out), transform var(--dur-rapida) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(var(--mov-presion)); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }

.btn-primary { background: var(--blue); color: #fff; }
@media (hover: hover) and (pointer: fine) { .btn-primary:hover:not(:disabled) { background: var(--blue-700); color: #fff; } }

.btn-gold { background: var(--gold); color: var(--navy-900); }
@media (hover: hover) and (pointer: fine) { .btn-gold:hover { background: #dcb35a; } }

.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
@media (hover: hover) and (pointer: fine) { .btn-ghost-light:hover { background: rgba(255, 255, 255, 0.1); border-color: #fff; } }

.btn-outline { background: var(--panel); color: var(--blue); border-color: var(--blue); }
@media (hover: hover) and (pointer: fine) { .btn-outline:hover { background: var(--maint-50); } }

.btn-text { background: transparent; color: var(--ink-2); padding-inline: var(--s-3); }
@media (hover: hover) and (pointer: fine) { .btn-text:hover { color: var(--ink); text-decoration: underline; } }

/* ---------- Títulos de sección (barra oro 56 × 3px) ---------- */
.section-title {
  font-size: clamp(1.5rem, 1.25rem + 0.8vw, 1.875rem);
  letter-spacing: -0.01em;
}
.section-title::after {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin-top: var(--s-2);
  background: var(--gold);
  border-radius: 2px;
}
.section-note { margin-top: var(--s-3); color: var(--ink-2); }

/* Texto solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s-6);
}
.panel:focus { outline: none; }

/* ---------- Campos de formulario ---------- */
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label,
.field legend { font-weight: 700; color: var(--ink); padding: 0; }
.field legend { margin-bottom: 6px; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px var(--s-3);
  border: 1px solid #a9b4be;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: 400 1rem/1.45 var(--sans);
  caret-color: var(--blue);
  transition: border-color var(--dur-rapida) var(--ease-out), box-shadow var(--dur-rapida) var(--ease-out);
}
input[type="text"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
select { min-height: 46px; }
/* El selector de fecha de Chrome suma 1 px: misma altura que los demás controles para que las filas queden parejas */
input[type="date"],
input[type="datetime-local"] { height: 46px; }
textarea { resize: vertical; min-height: 112px; }
input::placeholder,
textarea::placeholder { color: #6b7681; }
input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 76, 130, 0.2); }
input:disabled { background: #f1f3f5; cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--bad) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.2) !important; }

.field-help { font-size: 0.875rem; color: var(--ink-2); }

/* Casilla con su texto al lado (campo 'casilla') */
.casilla { display: flex; align-items: flex-start; gap: var(--s-2); min-height: 44px; cursor: pointer; }
.casilla input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--blue); cursor: pointer; }
.casilla-ayuda { margin-top: -12px; padding-left: calc(20px + var(--s-2)); }
.field-accion { justify-self: start; margin-left: calc(var(--s-2) * -1); }
.field-error { font-size: 0.875rem; color: var(--bad); font-weight: 600; }

/* Dato que se muestra en el formulario pero no se edita (p. ej. la persona de una cuenta) */
.field-label { font-weight: 700; color: var(--ink); }
.field-fijo {
  padding: 10px var(--s-3);
  background: var(--ground);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

/* ---------- Formulario armado desde la definición de campos ---------- */
.form { display: grid; gap: var(--s-5); max-width: 640px; }
.req { color: var(--bad); font-weight: 700; }
.opcional { color: var(--ink-2); font-weight: 400; font-size: 0.875rem; }
.form-acciones { display: grid; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--line-2); }
@media (min-width: 600px) {
  .form-acciones { display: flex; justify-content: flex-start; }
}

/* ---------- Avisos ---------- */
.notice {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-sm);
}
.notice .icon { margin-top: 2px; }
.notice--ok { background: var(--ok-50); color: #134a2e; }
.notice--ok .icon { color: var(--ok); }
.notice--error { background: var(--bad-50); color: #7d1a14; }
.notice--error .icon { color: var(--bad); }
.notice--warn { background: var(--warn-50); color: #5c3500; }
.notice--warn .icon { color: var(--warn); }
.notice--info { background: var(--maint-50); color: var(--blue-700); }
.notice--info .icon { color: var(--blue); }

/* ---------- Estado vacío ---------- */
.empty {
  display: flex;
  gap: var(--s-4);
  padding: var(--s-5);
  background: var(--panel);
  border: 1px dashed #b9c1c8;
  border-radius: var(--radius);
  color: var(--ink-2);
}
.empty > .icon { width: 28px; height: 28px; color: var(--navy-700); }
.empty > div { min-width: 0; }
.empty-title { color: var(--ink); font-weight: 700; margin-bottom: var(--s-1); }
.empty .btn { margin-top: var(--s-4); }

/* ---------- Chip de código (enlace a la etiqueta) ---------- */
.tag-ref {
  display: inline-block;
  padding: 1px var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--navy);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: border-color var(--dur-rapida) var(--ease-out), background-color var(--dur-rapida) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .tag-ref:hover { border-color: var(--gold); background: var(--gold-50); color: var(--navy); } }

@media (max-width: 560px) {
  .wrap { padding-inline: var(--s-4); }
  .panel { padding: var(--s-5) var(--s-4); }

  /* Estado vacío: el icono pasa arriba para dar todo el ancho al texto */
  .empty { flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
  .empty .btn { width: 100%; white-space: normal; line-height: 1.2; padding-block: var(--s-2); }
}

/* ---------- Ventanas (dialog): entran y salen con transición interrumpible ----------
   Sin soporte de @starting-style simplemente aparecen, como antes. */
dialog {
  opacity: 0;
  transform: translateY(var(--mov-entrada-y)) scale(var(--mov-entrada-escala));
  transition-property: opacity, transform, overlay, display;
  transition-duration: var(--dur-salida);
  transition-timing-function: var(--ease-out);
  transition-behavior: allow-discrete;
}
dialog[open] { opacity: 1; transform: none; transition-duration: var(--dur-media); }
dialog::backdrop {
  opacity: 0;
  transition-property: opacity, overlay, display;
  transition-duration: var(--dur-salida);
  transition-timing-function: var(--ease-out);
  transition-behavior: allow-discrete;
}
dialog[open]::backdrop { opacity: 1; transition-duration: var(--dur-media); }
@starting-style {
  dialog[open] { opacity: 0; transform: translateY(var(--mov-entrada-y)) scale(var(--mov-entrada-escala)); }
  dialog[open]::backdrop { opacity: 0; }
}

/* Movimiento reducido no es "sin movimiento": se quitan desplazamientos, escalas
   y zoom, pero se conservan los fundidos y cambios de color que explican qué cambió. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  :root {
    --mov-presion: 1;
    --mov-elevar: 0px;
    --mov-zoom: 1;
    --mov-entrada-y: 0px;
    --mov-entrada-escala: 1;
    --mov-menu-y: 0px;
  }
}

/* Logo institucional (azul y dorado): sobre fondos navy va en una placa blanca */
.brand-crest, .side-brand img, .login-crest {
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
}
