/* ==========================================================================
   NAVCALC PRO — SISTEMA VISUAL Y TOKENS DE DISEÑO NÁUTICO
   Soporte universal: Día (Day), Noche (Night) y Táctico Rojo (Tactical Red).
   ========================================================================== */

:root {
  /* Modo Noche (predeterminado / marina náutica profunda) */
  --surface-page: #081b29;
  --surface-card: #102c3c;
  --surface-raised: #173b4b;
  --surface-field: #0b2230;
  --visual-ink: #ecf6f7;
  --visual-secondary: #c1d5db;
  --visual-border: #365966;
  --visual-accent: #63dac6;
  --visual-focus: #7be5f2;
  --visual-shadow: 0 8px 24px rgba(0, 0, 0, .17);
  --visual-radius: 12px;
}

/* Modo Día (fondo claro, tarjetas blancas, texto oscuro de alto contraste) */
html[data-theme="day"] {
  color-scheme: light;
  --surface-page: #edf5f7;
  --surface-card: #ffffff;
  --surface-raised: #f1f7f9;
  --surface-field: #ffffff;
  --visual-ink: #102a36;
  --visual-secondary: #3b5a68;
  --visual-border: #b8d1d9;
  --visual-accent: #006e64;
  --visual-focus: #006f86;
  --visual-shadow: 0 4px 16px rgba(16, 42, 54, .08);
}

/* Modo Táctico (preservación visual nocturna en puente, rojo de baja emisión) */
html[data-theme="red"] {
  color-scheme: dark;
  --surface-page: #150607;
  --surface-card: #260c0e;
  --surface-raised: #3b1316;
  --surface-field: #1c0809;
  --visual-ink: #ffdada;
  --visual-secondary: #e6b8b8;
  --visual-border: #733537;
  --visual-accent: #ff8882;
  --visual-focus: #ffa6a0;
  --visual-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

/* Radar & Wind temático */
html[data-theme="red"] #navc-radar-calc {
  --bg: #150607;
  --panel: #260c0e;
  --panel-2: #3b1316;
  --field: #1c0809;
  --ink: #ffdada;
  --muted: #e6b8b8;
  --line: #733537;
  --mint: #ff8882;
  --cyan: #ffb8b0;
  --amber: #ffcc99;
  --violet: #f89fb0;
  --bad: #ff9990;
  --ring: #944848;
}

html[data-theme="day"] #navc-radar-calc {
  --bg: #edf5f7;
  --panel: #ffffff;
  --panel-2: #f1f7f9;
  --field: #ffffff;
  --ink: #102a36;
  --muted: #4b6877;
  --line: #b8d1d9;
  --mint: #007367;
  --cyan: #0277bd;
  --amber: #b45309;
  --violet: #6b21a8;
  --bad: #b91c1c;
  --ring: #a2c2cc;
}

/* Tipografía global */
html body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: normal;
}

/* Aplicación global de superficies en Modo Día */
html[data-theme="day"] body,
html[data-theme="day"] .view,
html[data-theme="day"] .module-shell,
html[data-theme="day"] #app-content,
html[data-theme="day"] #guard-view,
html[data-theme="day"] #calc-view,
html[data-theme="day"] #content-chequeo,
html[data-theme="day"] #content-emergencias,
html[data-theme="day"] #content-bitacora,
html[data-theme="day"] #content-referencias,
html[data-theme="day"] #content-glosario,
html[data-theme="day"] #content-radar,
html[data-theme="day"] #content-comunicaciones,
html[data-theme="day"] #content-asesores,
html[data-theme="day"] #content-meteorologia,
html[data-theme="day"] #content-estabilidad,
html[data-theme="day"] #content-mapa,
html[data-theme="day"] #content-ambiental {
  background-color: var(--surface-page);
  color: var(--visual-ink);
}

/* Tarjetas y paneles en Modo Día */
html[data-theme="day"] .card,
html[data-theme="day"] .reference-section,
html[data-theme="day"] .reference-panel,
html[data-theme="day"] .phase-card,
html[data-theme="day"] .navc-card,
html[data-theme="day"] .navc-bitacora-card,
html[data-theme="day"] .app-container,
html[data-theme="day"] .meteo-panel,
html[data-theme="day"] .eco-card,
html[data-theme="day"] .emergencia-card,
html[data-theme="day"] .asesor-card,
html[data-theme="day"] .rdm-card,
html[data-theme="day"] .rdm-map-panel {
  background-color: var(--surface-card) !important;
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
  box-shadow: var(--visual-shadow) !important;
}

/* Superficies secundarias elevadas en Modo Día */
html[data-theme="day"] .phase-header,
html[data-theme="day"] .tab-content.active,
html[data-theme="day"] .res-box,
html[data-theme="day"] .pasos-box {
  background-color: var(--surface-raised) !important;
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
}

/* Inputs, selects y textareas globales en Modo Día */
html[data-theme="day"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
html[data-theme="day"] select,
html[data-theme="day"] textarea {
  background-color: var(--surface-field) !important;
  color: var(--visual-ink) !important;
  border: 1px solid var(--visual-border) !important;
  border-radius: 6px;
}
html[data-theme="day"] input::placeholder,
html[data-theme="day"] textarea::placeholder {
  color: #64748b !important;
  opacity: 1;
}
html[data-theme="day"] select option {
  background-color: #ffffff !important;
  color: #102a36 !important;
}

/* Resultados y cajas de salida en Modo Día */
html[data-theme="day"] .resultado,
html[data-theme="day"] .res-body,
html[data-theme="day"] .res-card {
  background-color: var(--surface-card) !important;
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
}
html[data-theme="day"] .resultado-final:not(.danger) {
  background: linear-gradient(135deg, #f0f7f9, #e2eff4) !important;
  border: 1px solid #99c2d1 !important;
  color: #0c3344 !important;
}
html[data-theme="day"] .resultado-final:not(.danger) .big {
  color: #006e64 !important;
}

/* Tablas y filas en Modo Día */
html[data-theme="day"] table,
html[data-theme="day"] .tabla-solas,
html[data-theme="day"] .tabla-entrada {
  background-color: var(--surface-card) !important;
  color: var(--visual-ink) !important;
}
html[data-theme="day"] th {
  background-color: var(--surface-raised) !important;
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
}
html[data-theme="day"] td {
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
}
html[data-theme="day"] tr:nth-child(even) td {
  background-color: #f7fafb !important;
}

/* Modales y cuadros de diálogo en Modo Día */
html[data-theme="day"] .modal-content,
html[data-theme="day"] .navc-modal-dialog,
html[data-theme="day"] #marpolModal > div {
  background-color: var(--surface-card) !important;
  color: var(--visual-ink) !important;
  border: 1px solid var(--visual-border) !important;
  box-shadow: 0 12px 36px rgba(16, 42, 54, 0.18) !important;
}

/* Modo Táctico Rojo: cobertura global */
html[data-theme="red"] body,
html[data-theme="red"] .view,
html[data-theme="red"] .module-shell,
html[data-theme="red"] #app-content,
html[data-theme="red"] [id^="content-"] {
  background-color: var(--surface-page);
  color: var(--visual-ink);
}
html[data-theme="red"] .card,
html[data-theme="red"] .reference-section,
html[data-theme="red"] .reference-panel,
html[data-theme="red"] .phase-card,
html[data-theme="red"] .navc-card,
html[data-theme="red"] .navc-bitacora-card,
html[data-theme="red"] .app-container,
html[data-theme="red"] .meteo-panel,
html[data-theme="red"] .eco-card,
html[data-theme="red"] .emergencia-card,
html[data-theme="red"] .asesor-card,
html[data-theme="red"] .rdm-card,
html[data-theme="red"] .rdm-map-panel {
  background-color: var(--surface-card) !important;
  color: var(--visual-ink) !important;
  border-color: var(--visual-border) !important;
}
html[data-theme="red"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
html[data-theme="red"] select,
html[data-theme="red"] textarea {
  background-color: var(--surface-field) !important;
  color: var(--visual-ink) !important;
  border: 1px solid var(--visual-border) !important;
}
html[data-theme="red"] input::placeholder,
html[data-theme="red"] textarea::placeholder {
  color: #9c5c60 !important;
  opacity: 1;
}
html[data-theme="red"] select option {
  background-color: #1c0809 !important;
  color: #ffdada !important;
}

/* Controles de Signo Náutico Táctiles [+]/[-] y [E]/[W] */
html[data-theme="day"] .navc-sign-btn.is-positive {
  color: #047857 !important;
  background-color: rgba(4, 120, 87, 0.12) !important;
  border-right: 1px solid rgba(4, 120, 87, 0.25) !important;
}
html[data-theme="day"] .navc-sign-btn.is-negative {
  color: #b91c1c !important;
  background-color: rgba(185, 28, 28, 0.12) !important;
  border-right: 1px solid rgba(185, 28, 28, 0.25) !important;
}
html[data-theme="red"] .navc-sign-btn.is-positive {
  color: #ff9994 !important;
  background-color: rgba(255, 153, 148, 0.16) !important;
  border-right: 1px solid rgba(255, 153, 148, 0.3) !important;
}
html[data-theme="red"] .navc-sign-btn.is-negative {
  color: #ff6660 !important;
  background-color: rgba(255, 102, 96, 0.22) !important;
  border-right: 1px solid rgba(255, 102, 96, 0.4) !important;
}

/* Navegación y pestañas de Radar / Viento */
.navc-radar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.navc-radar-nav button {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--visual-border);
  background-color: var(--surface-card);
  color: var(--visual-ink);
}
.navc-radar-nav button[aria-pressed="true"] {
  background-color: var(--visual-accent) !important;
  color: #ffffff !important;
  border-color: var(--visual-accent) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
html[data-theme="day"] .navc-radar-nav button {
  background: var(--surface-card);
  color: var(--visual-ink);
  border-color: var(--visual-border);
}
html[data-theme="day"] .navc-radar-nav button[aria-pressed="true"] {
  background: #006e64 !important;
  color: #ffffff !important;
  border-color: #006e64 !important;
}

/* Barra inferior (Bottom Nav) */
.bottom-nav .nav-btn .label {
  font-size: 0.72rem;
  letter-spacing: normal;
}
html[data-theme="day"] .bottom-nav .nav-btn:not(.active),
html[data-theme="day"] .bottom-nav .nav-btn:not(.active) .label,
html[data-theme="day"] .bottom-nav .nav-btn:not(.active) svg {
  color: #294b5c;
}
html[data-theme="day"] .bottom-nav .nav-btn.active .label,
html[data-theme="day"] .bottom-nav .nav-btn.active svg {
  color: #ffffff;
}

/* Pestañas de Calculadoras en Modo Día */
html[data-theme="day"] #calc-view #quickPanel,
html[data-theme="day"] #calc-view #calcCategoryTabs,
html[data-theme="day"] #calc-view #calcTabs {
  background: var(--surface-card);
  border-color: var(--visual-border);
}
html[data-theme="day"] #calc-view .quick-panel-actions .qp-btn,
html[data-theme="day"] #calc-view #calcTabs .tab-btn,
html[data-theme="day"] #calc-view #calcCategoryTabs button {
  color: var(--visual-ink);
  background: var(--surface-raised);
  border-color: var(--visual-border);
}
html[data-theme="day"] #calc-view #calcTabs .tab-btn.active,
html[data-theme="day"] #calc-view #calcCategoryTabs button.active {
  color: #ffffff !important;
  background: #006e64 !important;
  border-color: #006e64 !important;
}

/* Accesibilidad y foco de teclado visible */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--visual-focus);
  outline-offset: 2px;
}

/* Responsive móvil */
@media (max-width: 550px) {
  .navc-radar-nav button {
    flex: 1 1 140px;
    text-align: center;
  }
  #navc-radar-calc {
    padding-inline: 0.5rem;
  }
  #navc-radar-calc .card {
    padding: 14px;
  }
}

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

/* Prevención universal de desbordamiento horizontal en pantallas móviles (320px) */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}
@media (max-width: 480px) {
  .nautical-watermark {
    display: none !important;
  }
}
