/* Tokens de diseño LogiPaq. Importar antes que cualquier otro CSS. */

:root {
  color-scheme: light;

  /* Fondo iOS/Sonoma: degradado pastel multicolor */
  --bg-base: #eef1f6;
  --bg-page-from: #f5f7fb;
  --bg-page-to: #eaf0f8;
  --bg-page-glow: rgba(120, 160, 220, 0.08);

  /* Blobs iOS (light) */
  --blob-1: rgba(125, 166, 255, 0.35); /* azul */
  --blob-2: rgba(255, 153, 204, 0.28); /* rosa */
  --blob-3: rgba(168, 139, 250, 0.28); /* violeta */
  --blob-4: rgba(134, 239, 172, 0.22); /* verde menta */
  --blob-5: rgba(253, 224, 71, 0.2); /* amarillo suave */

  --bg-surface: rgba(255, 255, 255, 0.78);
  --bg-elevated: #ffffff;
  --bg-muted: #eef2f7;
  --bg-input: #ffffff;

  --text-primary: #0f172a;
  --text-soft: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  --border-subtle: rgba(148, 163, 184, 0.28);
  --border-strong: rgba(148, 163, 184, 0.55);
  --border-input: #d1d5db;

  --accent: #2f6fec;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(47, 111, 236, 0.12);
  --accent-contrast: #ffffff;

  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.12);
  --shadow-card:
    0 18px 40px rgba(15, 23, 42, 0.1),
    0 0 0 0.5px rgba(255, 255, 255, 0.7) inset;

  --font-ui:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
}

/* Dark mode: ÚNICAMENTE cambia el fondo de la página. Navbar y footer
   manejan su dark por su propia cuenta (hardcoded en navbar.css / footer.css).
   El contenido (form, inputs, cards, cotizaciones, etc.) NO se oscurece. */
[data-theme="dark"] {
  --bg-base: #0b1120;
  --bg-page-from: #0b1120;
  --bg-page-to: #0f172a;
  --bg-page-glow: rgba(80, 120, 220, 0.14);

  --blob-1: rgba(56, 114, 255, 0.3);
  --blob-2: rgba(236, 72, 153, 0.22);
  --blob-3: rgba(139, 92, 246, 0.28);
  --blob-4: rgba(20, 184, 166, 0.18);
  --blob-5: rgba(251, 146, 60, 0.15);
}

/* El background del body está en styles.css para que sea la fuente única
   (evita duplicación y conflictos). Aquí solo color y transición. */
html {
  background: var(--bg-page-from);
  min-height: 100%;
}

body {
  color: var(--text-primary);
  font-family: var(--font-ui);
  min-height: 100vh;
  transition: color var(--transition-base);
}

/* Scrollbar fina consistente con el tema */
* {
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* Selección de texto */
::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* ===== Contenedor glass iOS global =====
   Aplica a cualquier <form>, <main> o elemento .lpq-container de cualquier página.
   Reemplaza el background blanco sólido que styles.css ponía a <form>. */

form,
main,
.lpq-container {
  background: rgba(255, 255, 255, 0.45) !important;
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  box-shadow:
    0 20px 60px rgba(15, 23, 42, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset !important;
  border-radius: 22px !important;
  width: 100%;
  max-width: 1280px;
  margin: 1.2rem auto 2rem !important;
  padding: 1.4rem 1.5rem 2.5rem !important;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  form,
  main,
  .lpq-container {
    border-radius: 16px !important;
    margin: 0.6rem 0.6rem 1.5rem !important;
    padding: 1rem 0.85rem 2rem !important;
    max-width: calc(100% - 1.2rem);
  }
}

/* Inter como fuente base en todas las páginas */
body,
body * {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

body .bi::before,
body [class*="bi-"]::before {
  font-family: "bootstrap-icons" !important;
}

body .fa::before,
body .fas::before,
body .far::before,
body .fab::before,
body [class*="fa-"]::before {
  font-family: "Font Awesome 5 Free", "Font Awesome 5 Brands" !important;
}

/* Flechas laterales scroll — dark mode */
[data-theme="dark"] .scroll-ios-btn {
  background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow:
    0 10px 28px rgba(59, 130, 246, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .scroll-ios-btn:hover,
[data-theme="dark"] .scroll-ios-btn:focus {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  box-shadow:
    0 14px 32px rgba(96, 165, 250, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .scroll-ios-btn:active {
  box-shadow:
    0 6px 18px rgba(59, 130, 246, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Historial toolbar — dark mode */
[data-theme="dark"] .historial-index-filter-transportes {
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* Encabezado del formulario — dark mode */
[data-theme="dark"] #andesmarForm-header-index .andesmarForm-badge-index {
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
}

[data-theme="dark"] #andesmarForm-header-index .andesmarForm-title-index {
  color: #f8fafc;
}

[data-theme="dark"] #andesmarForm-header-index .andesmarForm-subtitle-index {
  color: #cbd5e1;
}

/* Historial — nombre del transporte dentro del logo-pill en dark */
[data-theme="dark"] .historial-index-card .cotizacion-logo-pill span {
  color: grey;
}

/* Historial — paginación: info + botones en dark */
[data-theme="dark"] .historial-index-page-info {
  color: #cbd5e1;
}

[data-theme="dark"] .historial-index-page-buttons .btn {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(71, 85, 105, 0.7);
  color: #e2e8f0;
}

[data-theme="dark"] .historial-index-page-buttons .btn:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(96, 165, 250, 0.6);
  color: #ffffff;
}

[data-theme="dark"] .historial-index-page-buttons .btn:disabled,
[data-theme="dark"] .historial-index-page-buttons .btn.disabled {
  background: rgba(30, 41, 59, 0.45);
  border-color: rgba(71, 85, 105, 0.35);
  color: #64748b;
  opacity: 1;
}

[data-theme="dark"] .historial-index-search {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(71, 85, 105, 0.55);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .historial-index-search-input {
  color: #e2e8f0;
}

[data-theme="dark"] .historial-index-search:focus-within {
  border-color: rgba(96, 165, 250, 0.65);
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* Cotización cards — dark mode */
[data-theme="dark"] .cotizacion-card-macos {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .cotizacion-card-macos:hover {
  border-color: #475569;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .cotizacion-card-macos::after {
  opacity: 0.15;
}

[data-theme="dark"] .cotizacion-card-macos:hover::after {
  opacity: 0.3;
}

[data-theme="dark"] .cotizacion-logo-pill span {
  color: #f1f5f9;
}

[data-theme="dark"] .cotizacion-tag {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(71, 85, 105, 0.8);
  color: #94a3b8;
}

[data-theme="dark"] .cotizacion-monto {
  color: #f8fafc;
}

[data-theme="dark"] .cotizacion-monto::after {
  color: #64748b;
}

[data-theme="dark"] .valor-cotizacion:empty,
[data-theme="dark"] .valor-cotizacion:has(.cotizacion-typing-text),
[data-theme="dark"] .valor-cotizacion:has(.cotizacion-placeholder) {
  background: linear-gradient(
    90deg,
    #334155 0%,
    #475569 50%,
    #334155 100%
  );
  background-size: 200% 100%;
}

[data-theme="dark"] .valor-cotizacion.cotizacion-error {
  color: #fca5a5;
}

[data-theme="dark"] .cotizacion-card-macos .cotizacion-plazo-badge {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(71, 85, 105, 0.7);
  color: #cbd5e1;
}

[data-theme="dark"] .cotizacion-card-macos .cotizacion-plazo-badge i,
[data-theme="dark"] .cotizacion-card-macos .cotizacion-plazo-badge .bi-clock-history {
  color: #94a3b8;
}

[data-theme="dark"] .cotizacion-card-macos .cotizacion-plazo-badge strong {
  color: #f1f5f9;
}

[data-theme="dark"] .cotizacion-plazo-badge .cruz-ver-sucursal-btn {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(71, 85, 105, 0.8);
  color: #93c5fd;
}

[data-theme="dark"] .cotizacion-plazo-badge .cruz-ver-sucursal-btn:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(96, 165, 250, 0.6);
}

/* Cruz del Sur — pills partidas (plazo + Ver sucursal) en dark */
[data-theme="dark"]
  .cotizacion-card-cruz
  .cotizacion-plazo-badge:has(.cruz-ver-sucursal-btn)
  > span {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(71, 85, 105, 0.7);
  color: #cbd5e1;
}

[data-theme="dark"]
  .cotizacion-card-cruz
  .cotizacion-plazo-badge:has(.cruz-ver-sucursal-btn)
  > span::before {
  color: #94a3b8;
}

/* ===== MEJOR PRECIO — dark mode ===== */
[data-theme="dark"] .cotizacion-card-macos.cotizacion-card-best {
  background: linear-gradient(
    180deg,
    rgba(16, 185, 129, 0.08) 0%,
    rgba(6, 78, 59, 0.18) 100%
  ),
  #1e293b;
  border-color: #10b981;
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.35),
    0 10px 26px rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .cotizacion-card-macos.cotizacion-card-best:hover {
  border-color: #34d399;
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.55),
    0 14px 32px rgba(16, 185, 129, 0.3);
}

/* Nombre de la marca (Andesmar, etc.) dentro de la best-price en dark */
[data-theme="dark"] .cotizacion-card-best .cotizacion-logo-pill span {
  color: #ecfdf5;
}

[data-theme="dark"] .cotizacion-best-badge {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow:
    0 2px 8px rgba(16, 185, 129, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
