/* base.css — variables compartidas (colores, tipografía, radios, sombras) y componentes comunes.
   REDISEÑO "estilo app" (demo, 2026-11-05): los valores salen de AppMovil/app/www/css/app.css para que portal y app se vean como un solo ecosistema.
   Los NOMBRES de las variables no cambian (todo el portal las usa); solo sus valores. Modo oscuro AUTOMÁTICO: sigue al equipo (prefers-color-scheme)
   y js/tema.js puede fijar Claro u Oscuro con data-tema en <html> (mismos bloques que la app). */

:root {
  color-scheme: light dark;

  /* Sidebar / superficies oscuras — azul marino de la marca (igual en claro y oscuro) */
  --color-sidebar-bg: #0f1829;      /* marino de la app */
  --color-sidebar-hover: rgba(255, 255, 255, 0.07);   /* un paso más claro (hover) */
  --color-sidebar-border: rgba(160, 175, 205, 0.16);  /* borde sutil sobre el marino */
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-text-muted: #94a3b8;

  /* Marca / acciones — azul catalítico */
  --color-brand: #1877f2;
  --color-brand-hover: #1565d8;
  --color-brand-active: #1257bd;
  --color-brand-soft: rgba(24, 119, 242, 0.14);
  --color-brand-text: #1257bd;      /* azul legible sobre fondos suaves (badges, enlaces) */

  /* Contenido */
  --color-bg: #f2f2f7;              /* fondo de pantalla */
  --color-surface: #ffffff;         /* tarjetas, tablas, diálogos */
  --color-surface-2: #f2f2f7;       /* segundo nivel dentro de una tarjeta */
  --color-border: rgba(60, 60, 67, 0.14);        /* separadores */
  --color-border-strong: rgba(60, 60, 67, 0.29);
  --color-text: #111318;
  --color-text-muted: #6b7280;
  --color-text-faint: #7b8494;
  --color-campo: rgba(118, 118, 128, 0.12);      /* fondo de campos y botones secundarios */
  --color-vidrio: rgba(255, 255, 255, 0.78);     /* barras flotantes con desenfoque */
  --color-vidrio-borde: rgba(0, 0, 0, 0.06);

  /* Estado (los textos son más oscuros que el relleno para leerse bien) */
  --color-success: #16a34a;
  --color-success-soft: rgba(52, 199, 89, 0.16);
  --color-success-text: #166534;
  --color-danger: #ef4444;
  --color-danger-soft: rgba(255, 59, 48, 0.12);
  --color-danger-text: #991b1b;
  --color-warning: #f59e0b;
  --color-warning-soft: rgba(245, 158, 11, 0.16);
  --color-warning-text: #92400e;

  /* Formas: radios grandes como la app (campos 14, tarjetas 22, hojas 28) */
  --radio-sm: 14px;
  --radio-md: 22px;
  --radio-lg: 28px;
  --radio-pildora: 999px;
  --sombra-sm: 0 1px 2px rgba(15, 24, 41, 0.05);
  --sombra-md: 0 4px 14px rgba(15, 24, 41, 0.08);
  --sombra-lg: 0 8px 28px rgba(15, 24, 41, 0.14);

  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
/* Modo oscuro: automático (el equipo está en oscuro y no se eligió "Claro") o elegido a mano (data-tema="oscuro"). Mismos valores en los dos sitios. */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --color-bg: #05080f;
    --color-surface: #121a2a;
    --color-surface-2: #1b2438;
    --color-border: rgba(160, 175, 205, 0.16);
    --color-border-strong: rgba(160, 175, 205, 0.32);
    --color-text: #f5f7fb;
    --color-text-muted: rgba(235, 240, 250, 0.62);
    --color-text-faint: rgba(235, 240, 250, 0.38);
    --color-campo: rgba(118, 128, 160, 0.22);
    --color-vidrio: rgba(30, 40, 62, 0.72);
    --color-vidrio-borde: rgba(255, 255, 255, 0.1);
    --color-brand-soft: rgba(24, 119, 242, 0.24);
    --color-brand-text: #7fb2ff;
    --color-success-soft: rgba(52, 199, 89, 0.18);
    --color-success-text: #5fd68a;
    --color-danger-soft: rgba(255, 105, 97, 0.16);
    --color-danger-text: #ff8a84;
    --color-warning-soft: rgba(245, 158, 11, 0.2);
    --color-warning-text: #fbbf24;
    --sombra-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sombra-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --sombra-lg: 0 10px 30px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-tema="claro"] { color-scheme: light; }
:root[data-tema="oscuro"] {
  --color-bg: #05080f;
  --color-surface: #121a2a;
  --color-surface-2: #1b2438;
  --color-border: rgba(160, 175, 205, 0.16);
  --color-border-strong: rgba(160, 175, 205, 0.32);
  --color-text: #f5f7fb;
  --color-text-muted: rgba(235, 240, 250, 0.62);
  --color-text-faint: rgba(235, 240, 250, 0.38);
  --color-campo: rgba(118, 128, 160, 0.22);
  --color-vidrio: rgba(30, 40, 62, 0.72);
  --color-vidrio-borde: rgba(255, 255, 255, 0.1);
  --color-brand-soft: rgba(24, 119, 242, 0.24);
  --color-brand-text: #7fb2ff;
  --color-success-soft: rgba(52, 199, 89, 0.18);
  --color-success-text: #5fd68a;
  --color-danger-soft: rgba(255, 105, 97, 0.16);
  --color-danger-text: #ff8a84;
  --color-warning-soft: rgba(245, 158, 11, 0.2);
  --color-warning-text: #fbbf24;
  --sombra-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sombra-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --sombra-lg: 0 10px 30px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--fuente);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }

/* Anti-copia para usuarios cliente (solo disuasión; lo activa partials/header.php +
   js/anti_copia.js). No se puede seleccionar texto en ningún lado, incluidos los campos
   de búsqueda; escribir y pegar ahí siguen funcionando (el caret funciona con
   user-select:none). */
body[data-anti-copia] {
  -webkit-user-select: none;
  user-select: none;
}

a { color: inherit; text-decoration: none; }

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* Campos: relleno gris suave sin borde, como en la app; al enfocar, anillo azul */
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radio-sm);
  background: var(--color-campo);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--color-text-faint); }
/* Lista desplegable de un <select> (Chrome/Edge de Windows y Linux, Firefox): el panel de opciones NO usa el fondo translúcido del campo (--color-campo),
   se pinta sobre blanco y en oscuro quedaba gris claro con letras casi blancas. Con colores OPACOS de los tokens (cambian con el tema) se lee en claro y oscuro. */
select option, select optgroup { background-color: var(--color-surface-2); color: var(--color-text); }
/* Relleno automático del navegador (usuario/contraseña guardados): Chrome lo pinta con fondo claro y texto oscuro dentro de campos oscuros.
   El texto toma el color del tema y el fondo del relleno no se aplica (transición larguísima), igual que en la app (.login__campo). */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--color-text);
  caret-color: var(--color-text);
  transition: background-color 9999s ease-in-out 0s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-soft);
}
/* Casillas y radios: color de marca */
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-brand); }

label.etiqueta {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

/* Botones: píldora; al presionar se hunden un instante (como en la app) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radio-pildora);
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.1s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); opacity: 0.85; }
.btn:focus-visible { outline: 3px solid var(--color-brand-soft); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primario { background: var(--color-brand); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--color-brand-hover); }
.btn-primario:active:not(:disabled) { background: var(--color-brand-active); }

.btn-secundario { background: var(--color-campo); color: var(--color-text); }
.btn-secundario:hover:not(:disabled) { background: var(--color-border-strong); }

.aviso { border-radius: var(--radio-sm); padding: 12px 16px; font-size: 13px; }
.aviso-error { background: var(--color-danger-soft); color: var(--color-danger-text); }
.aviso-ok { background: var(--color-success-soft); color: var(--color-success-text); }
.aviso-advertencia { background: var(--color-warning-soft); color: var(--color-warning-text); }

.btn-peligro { background: var(--color-danger-soft); color: var(--color-danger-text); }
.btn-peligro:hover:not(:disabled) { background: var(--color-danger); color: #fff; }

.fila-acciones {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Tarjeta: esquinas de 22 px y sin borde (el contraste lo da la superficie sobre el fondo) */
.tarjeta {
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radio-md);
  box-shadow: var(--sombra-sm);
  padding: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-verde  { background: var(--color-success-soft); color: var(--color-success-text); }
.badge-rojo   { background: var(--color-danger-soft);  color: var(--color-danger-text); }
.badge-ambar  { background: var(--color-warning-soft); color: var(--color-warning-text); }
.badge-azul   { background: var(--color-brand-soft);   color: var(--color-brand-text); }

/* Etiqueta "Coincidencia exacta" de los buscadores del administrador (el código que escribió, tal cual) */
.badge-exacta {
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  vertical-align: middle;
}

/* En tablas de pantallas angostas la etiqueta larga empujaba columnas fuera de pantalla: se acorta a "Exacta"
   (el texto completo sigue ahí para lectores de pantalla). */
@media (max-width: 600px) {
  .listas-tabla .badge-exacta,
  .grupo-catalogo .badge-exacta {
    display: block;
    width: max-content;
    margin: 4px 0 0;
    padding: 1px 7px;
    font-size: 0;
  }
  .listas-tabla .badge-exacta::after,
  .grupo-catalogo .badge-exacta::after {
    content: "Exacta";
    font-size: 10px;
  }
}

/* Visor de fotos a pantalla completa con zoom (lo maneja js/layout.js).
   Es un <dialog>: se abre con showModal() y así queda SIEMPRE encima, incluso
   sobre otro <dialog> abierto (el modal de detalle del catálogo). */
.foto-visor {
  position: fixed;
  inset: 0;
  z-index: 1000;
  /* reset del user-agent para <dialog> */
  margin: 0;
  padding: 0;
  border: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  color: inherit;
  align-items: center;
  justify-content: center;
}
.foto-visor[open] { display: flex; }
.foto-visor:not([open]) { display: none; }
.foto-visor::backdrop { background: rgba(0, 0, 0, 0.92); }
.foto-visor__lienzo {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.foto-visor__img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  transform-origin: center center;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}
.foto-visor__img:active { cursor: grabbing; }
.foto-visor__cerrar {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.foto-visor__cerrar:hover { background: rgba(255, 255, 255, 0.3); }
/* Flechas ‹ › y contador para recorrer varias fotos (los crea js/layout.js solo cuando hay 2 o más) */
.foto-visor__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  padding: 0 0 4px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.foto-visor__nav:hover { background: rgba(255, 255, 255, 0.3); }
.foto-visor__nav:focus-visible, .foto-visor__cerrar:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.foto-visor__nav--ant { left: 14px; }
.foto-visor__nav--sig { right: 14px; }
.foto-visor__nav[hidden], .foto-visor__contador[hidden] { display: none; }
.foto-visor__contador {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
@media (max-width: 600px) {
  .foto-visor__nav { width: 42px; height: 42px; margin-top: -21px; font-size: 30px; }
  .foto-visor__nav--ant { left: 6px; }
  .foto-visor__nav--sig { right: 6px; }
}
.foto-visor__ayuda {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  pointer-events: none;
}

/* Modo PAR del visor (js/layout.js): las dos fotos lado a lado (delantera | trasera), cada una COMPLETA (contain, nunca recortada).
   Tocar una foto la abre sola con zoom; "Ver juntas" regresa. En celular vertical se apilan una sobre otra. */
.foto-visor__par { display: none; width: 100%; height: 100%; align-items: center; justify-content: center; gap: 12px; padding: 56px 12px 40px; box-sizing: border-box; }
.foto-visor--par .foto-visor__lienzo { display: none; }
.foto-visor--par .foto-visor__par { display: flex; }
.foto-visor__par-img { flex: 1 1 0; min-width: 0; max-width: 46vw; max-height: 100%; width: auto; height: auto; object-fit: contain; cursor: zoom-in; user-select: none; -webkit-user-drag: none; }
.foto-visor__par-img[hidden] { display: none; }
.foto-visor__par--una .foto-visor__par-img { max-width: 92vw; }
.foto-visor__juntas { position: absolute; top: 14px; left: 14px; z-index: 2; min-height: 44px; padding: 0 16px; border: none; border-radius: 22px; background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.foto-visor__juntas:hover { background: rgba(255, 255, 255, 0.3); }
.foto-visor__juntas[hidden] { display: none; }
@media (max-width: 700px) and (orientation: portrait) {
  .foto-visor__par { flex-direction: column; gap: 10px; }
  .foto-visor__par-img { flex: 0 1 auto; max-width: 94vw; max-height: 42vh; }
  .foto-visor__par--una .foto-visor__par-img { max-height: 84vh; }
}

/* Carrusel de fotos (lo arma js/layout.js -> window.hidroCarrusel) */
.carrusel {
  position: relative;
  width: 100%;
  background: var(--color-bg);
  overflow: hidden;
}
.carrusel__img {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  line-height: 0;
}
.carrusel__img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* llena el marco 4:3 (el visor con zoom sí la muestra completa) */
}
.carrusel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 44px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.carrusel__nav--prev { left: 0; border-radius: 0 6px 6px 0; }
.carrusel__nav--next { right: 0; border-radius: 6px 0 0 6px; }
.carrusel__nav:hover { background: rgba(0, 0, 0, 0.65); }
.carrusel__puntos {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.carrusel__punto {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}
.carrusel__punto--activo { background: #fff; }

/* Celular/tablet: áreas de toque cómodas (botones y campos de al menos ~40 px de alto). Solo presentación. */
@media (max-width: 899px) {
  .btn { min-height: 40px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  select { min-height: 42px; }
}

/* ── Piezas compartidas con la app (mismo aspecto y mismas animaciones) ── */
@keyframes entra-arriba { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes hoja-fondo { from { opacity: 0; } to { opacity: 1; } }
@keyframes hoja-sube { from { transform: translateY(100%); } to { transform: none; } }
@keyframes dialogo-entra { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
/* Control segmentado tipo iOS (filtros, pestañas, apariencia) */
.segmentado { display: flex; padding: 3px; border-radius: 12px; background: var(--color-campo); gap: 2px; }
.segmentado > button, .segmentado > a { flex: 1; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--color-text); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.18s ease, box-shadow 0.18s ease; }
.segmentado .segmentado--activo { background: var(--color-surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
/* Chips (filtros rápidos) */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--color-surface); color: var(--color-text-muted); font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--sombra-sm); transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease; }
.chip:active { transform: scale(0.95); }
.chip--activo { background: var(--color-brand-soft); color: var(--color-brand-text); box-shadow: inset 0 0 0 1.5px var(--color-brand); }

/* Diálogos (<dialog>) como en la app: esquinas grandes, entrada con escala y fondo desenfocado. El visor de fotos tiene lo suyo (.foto-visor). */
dialog:not(.foto-visor) { border: 0; border-radius: var(--radio-md); background: var(--color-surface); color: var(--color-text); box-shadow: var(--sombra-lg); }
dialog:not(.foto-visor)[open] { animation: dialogo-entra 0.2s ease; }
dialog:not(.foto-visor)::backdrop { background: rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: hoja-fondo 0.2s ease; }
/* Tablas: filas con separador fino y pulso suave al pasar el cursor (como las listas de la app) */
table { font-variant-numeric: tabular-nums; }

/* ── Visor de fotos estilo app: fondo de vidrio oscuro, control segmentado Juntas | Delantera | Trasera, entrada con escala ── */
.foto-visor { background: rgba(5, 8, 15, 0.84); -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%); }
.foto-visor::backdrop { background: rgba(5, 8, 15, 0.6); }
.foto-visor[open] { animation: dialogo-entra 0.22s ease; }
.foto-visor__cerrar, .foto-visor__nav { background: rgba(255, 255, 255, 0.14); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: background 0.15s ease, transform 0.1s ease; }
.foto-visor__cerrar:active, .foto-visor__nav:active { transform: scale(0.92); }
.foto-visor__juntas { display: none !important; } /* lo reemplaza el control segmentado de arriba */
.foto-visor__seg { position: absolute; top: 14px; left: 50%; z-index: 3; transform: translateX(-50%); width: min(340px, calc(100% - 140px)); background: rgba(255, 255, 255, 0.14); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.foto-visor__seg > button { color: #fff; min-height: 34px; padding: 0 6px; font-size: 13px; }
.foto-visor__seg > button:disabled { opacity: 0.4; cursor: default; }
.foto-visor__seg .segmentado--activo { background: rgba(255, 255, 255, 0.92); color: #0f1829; box-shadow: none; }
.foto-visor__seg[hidden] { display: none; }
.foto-visor__contador { top: auto; bottom: 40px; }
.foto-visor__par-img { border-radius: 16px; }

/* Carrusel (Catálogo agrupado): flechas redondas de vidrio y puntos tipo píldora, como la app. Solo presentación. */
.carrusel__nav { width: 34px; height: 34px; border-radius: 50% !important; left: auto; right: auto; background: rgba(15, 24, 41, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 20px; padding: 0; transition: transform .15s, background .15s; }
.carrusel__nav:active { transform: translateY(-50%) scale(.92); }
.carrusel__nav--prev { left: 8px; }
.carrusel__nav--next { right: 8px; }
.carrusel__puntos { bottom: 8px; }
.carrusel__punto { width: 6px; height: 6px; transition: width .2s, background .2s; }
.carrusel__punto--activo { width: 18px; border-radius: 99px; }
