/* ============================================================
 * Colas Frontera Ceuta — identidad visual de Ceuta
 * Paleta inspirada en el escudo de la ciudad: campo de PLATA,
 * quinas de AZUR, bordura de GULES y castillos de ORO.
 * Motivos: bandera jironada blanco/negro (bandera de San Vicente),
 * olas del Estrecho y el escudo de las cinco quinas como logo.
 * ============================================================ */
:root {
  --bg: #f6f3ec;            /* plata cálida */
  --card: #ffffff;
  --ink: #10182b;
  --muted: #5d6575;
  --line: #e7e1d3;          /* línea cálida */
  --accent: #1a56a0;        /* azur de Ceuta */
  --accent-2: #123f7d;
  --accent-soft: #e8eff9;
  --sea: #1b6ab0;
  --deep: #0b2f66;
  --gules: #c0182b;         /* rojo del escudo */
  --gules-soft: #fbe4e7;
  --gold: #b8860b;          /* castillos de oro */
  --gold-soft: #faf1d8;
  --green: #1e8a4e;
  --green-soft: #ddf3e6;
  --yellow: #c08a06;
  --yellow-soft: #fdf3cd;
  --orange: #d95f0c;
  --orange-soft: #fde9d7;
  --red: #d2232f;
  --red-soft: #fbe1e4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 43, .05), 0 4px 16px rgba(16, 24, 43, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  /* Fondo sutil de olas del Estrecho: líneas de contorno en azur con un toque dorado */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='72' viewBox='0 0 240 72'%3E%3Cg fill='none' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M0 12 Q30 4 60 12 T120 12 T180 12 T240 12' stroke='%231a56a0' opacity='0.09'/%3E%3Cpath d='M0 28 Q30 34 60 28 T120 28 T180 28 T240 28' stroke='%231a56a0' opacity='0.14'/%3E%3Cpath d='M0 44 Q30 36 60 44 T120 44 T180 44 T240 44' stroke='%231b6ab0' opacity='0.11'/%3E%3Cpath d='M0 60 Q30 66 60 60 T120 60 T180 60 T240 60' stroke='%23b8860b' opacity='0.08'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 240px 72px;
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

/* El fondo de olas se integra con la ola del header (mismo color de relleno) */
.header-wave { fill: var(--bg); }

.app { max-width: 560px; margin: 0 auto; padding: 0 14px 40px; }

/* ---------- Header marítimo (olas del Estrecho) ---------- */
.header {
  position: sticky; top: 0; z-index: 10;
  margin: 0 -14px;
  background: linear-gradient(165deg, var(--deep) 0%, var(--accent-2) 55%, var(--sea) 100%);
  color: #fff;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 6px 18px rgba(11, 47, 102, .28);
  padding-bottom: 0;
}

/* Banda de la bandera de Ceuta (jironada). El color de las franjas
 * refleja el estado de la frontera (semáforo):
 * blanco+verde = fluida · blanco+ámbar = moderada · blanco+rojo = colas · gris = cerrada */
.flag-band {
  height: 9px;
  background: repeating-linear-gradient(135deg, #14171d 0 16px, #ffffff 16px 32px);
  border-radius: 0 0 2px 2px;
}
.flag-band.state-green { background: repeating-linear-gradient(135deg, var(--green) 0 16px, #ffffff 16px 32px); }
.flag-band.state-amber { background: repeating-linear-gradient(135deg, var(--yellow) 0 16px, #ffffff 16px 32px); }
.flag-band.state-red { background: repeating-linear-gradient(135deg, var(--red) 0 16px, #ffffff 16px 32px); }
.flag-band.state-gray { background: repeating-linear-gradient(135deg, #8a94a6 0 16px, #ffffff 16px 32px); }

.header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px 18px 0; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 42px; height: 42px; flex: none;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .28));
  border-radius: 12px;
  background: #fff;
}

h1 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.subtitle { font-size: 12.5px; color: rgba(255, 255, 255, .78); margin-top: 1px; }

.lang-bar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; flex-wrap: wrap; padding: 10px 18px 0;
}
.lang-btn {
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  cursor: pointer; flex: none; backdrop-filter: blur(4px); line-height: 1.4;
}
.lang-btn.active { background: #fff; color: var(--deep); border-color: #fff; }
.lang-btn:active { transform: scale(.96); }
.dev-lang-badge {
  font-size: 11px; font-weight: 600; color: #e8eff9;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.dev-lang-badge[hidden] { display: none; }

/* ---------- Segmented ---------- */
.segmented {
  margin: 13px 18px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 4px;
}
.seg-btn {
  border: 0; background: transparent; color: rgba(255, 255, 255, .82);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 8px; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .15s, color .15s;
}
.seg-btn[aria-selected="true"] { background: #fff; color: var(--deep); box-shadow: 0 2px 8px rgba(0, 0, 0, .28); }
.seg-arrow { font-size: 15px; }

/* Ola que separa el header del contenido */
.header-wave { display: block; width: 100%; height: 15px; margin-top: 14px; }

/* ---------- Cards ---------- */
.cards { display: grid; gap: 12px; margin-top: 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; align-items: center; gap: 14px;
  border-left: 5px solid var(--muted);
  transition: border-color .3s;
}
.card.status-green { border-left-color: var(--green); }
.card.status-yellow { border-left-color: var(--yellow); }
.card.status-orange { border-left-color: var(--orange); }
.card.status-red { border-left-color: var(--red); }
.card.status-closed { border-left-color: var(--muted); opacity: .75; }

.card-info { flex: 1; min-width: 0; }
.card-name { font-weight: 700; font-size: 15.5px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.card-meta b { color: var(--ink); font-weight: 600; }

.card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }

.wait {
  font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.wait small { font-size: 12px; font-weight: 600; color: var(--muted); }

.status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill-orange { background: var(--orange-soft); color: var(--orange); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-closed { background: #e7e1d3; color: var(--muted); }

.report-btn {
  border: 0; background: var(--accent); color: #fff; font: inherit;
  font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: 10px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  box-shadow: 0 3px 8px rgba(26, 86, 160, .32);
}
.report-btn:active { transform: scale(.96); }
.report-btn.closed { background: var(--muted); box-shadow: none; }

/* ---------- Panel / predicción ---------- */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 16px; margin-top: 16px;
}
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h2 { font-size: 16px; font-weight: 800; }
.daytype { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; }

/* Badge EN DIRECTO: gules del escudo, con punto pulsante */
.cam-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gules); color: #fff; padding: 4px 11px; text-decoration: none;
}
.cam-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; animation: pulse 1.6s ease infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

.cross-chips { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.cross-chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; flex: none;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(26, 86, 160, .32); }

/* Mejor momento: dorado (los castillos de oro del escudo) */
.best-time {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--gold-soft), #fffdf4);
  border: 1px solid #ecd9a0; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.best-time-icon { font-size: 22px; }
.best-time-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.best-time-value { font-size: 15.5px; font-weight: 800; margin-top: 1px; color: var(--accent); }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 4px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 22px; border-radius: 4px 4px 2px 2px; background: #cbd5e1;
  min-height: 3px; transition: height .2s;
}
.bar.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.bar.best { background: var(--green); }
.bar.best.now { outline-color: var(--green); }
.bar.b-green { background: #86efac; }
.bar.b-yellow { background: #fde047; }
.bar.b-orange { background: #fdba74; }
.bar.b-red { background: #fca5a5; }
.bar-label { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-label.now { color: var(--ink); font-weight: 800; }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }

.chart-note { font-size: 11.5px; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* ---------- FAQ (preguntas frecuentes) ---------- */
.faq-item { border-top: 1px solid var(--line); }
.faq-item:last-child { border-bottom: 1px solid var(--line); }
.faq-item summary {
  cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--ink);
  padding: 12px 2px; list-style: none; display: flex; justify-content: space-between;
  align-items: center; gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "＋"; color: var(--accent); font-weight: 800; flex: none; }
.faq-item[open] summary::after { content: "－"; }
.faq-item p { font-size: 13px; color: var(--muted); line-height: 1.6; padding: 0 2px 12px; margin: 0; }

/* ---------- Cámaras en directo ---------- */
.cam-block + .cam-block { margin-top: 18px; }
.cam-title { font-size: 13px; color: var(--accent); margin: 0 0 8px; font-weight: 700; }
.cam-wrap {
  position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  background: #0b1220; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.cam-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cam-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.official-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.official-links a {
  font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft);
  text-decoration: none; padding: 7px 12px; border-radius: 999px;
}
.official-links a:active { transform: scale(.97); }

/* ---------- Páginas legales ---------- */
.legal-page { max-width: 640px; margin: 0 auto; padding: 26px 18px 70px; }
.lang-switch { display: inline-flex; gap: 6px; flex-wrap: wrap; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.lang-switch a {
  font-size: 12.5px; font-weight: 700; text-decoration: none; color: var(--muted);
  padding: 5px 12px; border-radius: 999px;
}
.lang-switch a.active { background: var(--accent); color: #fff; }
html[dir="rtl"] .legal-page .back { display: inline-block; transform: scaleX(-1); }
.legal-page a.back { color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 700; }
.legal-page h1 { font-size: 22px; margin: 12px 0 4px; }
.legal-page .updated { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.legal-page h2 { font-size: 16px; margin: 22px 0 8px; }
.legal-page p, .legal-page li { font-size: 14px; line-height: 1.65; color: var(--ink); }
.legal-page ul { padding-left: 20px; }
.legal-page .note { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin: 14px 0; }
.legal-page code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }

/* ---------- Aviso de consentimiento ---------- */
.consent {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 45;
  background: var(--deep); color: #fff; border-radius: 14px; padding: 13px 15px;
  box-shadow: 0 10px 30px rgba(11, 47, 102, .4); font-size: 12.5px; line-height: 1.5;
  max-width: 520px; margin: 0 auto;
}
.consent a { color: #9fc4ee; font-weight: 700; }
.consent-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.consent-actions .btn-ok {
  border: 0; background: var(--gules); color: #fff; font: inherit; font-weight: 700;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; margin-left: auto;
}

/* ---------- Footer ---------- */
.footer { margin-top: 4px; text-align: center; }
.footer-wave { display: block; width: 100%; height: 22px; margin-bottom: 14px; }
.footer p { font-size: 11.5px; color: var(--muted); line-height: 1.55; max-width: 46ch; margin: 0 auto; }
.made-in {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.made-in svg { flex: none; }
.reset-link { margin-top: 10px; background: none; border: 0; color: #94a3b8; font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }

/* ---------- Splash de bienvenida ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: linear-gradient(165deg, var(--deep), var(--accent-2) 55%, var(--sea));
  color: #fff; text-align: center;
  transition: opacity .45s ease;
}
.splash[hidden] { display: none; }
.splash.hide { opacity: 0; pointer-events: none; }
.splash .flag-band { position: absolute; top: 0; left: 0; right: 0; }
.splash-logo {
  width: 108px; height: 108px; border-radius: 26px; background: #fff;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .38));
  animation: splash-in .5s ease both;
}
.splash-title { font-size: 26px; font-weight: 800; letter-spacing: -.01em; animation: splash-in .5s .08s ease both; }
.splash-tag { font-size: 13.5px; color: rgba(255, 255, 255, .82); margin-top: 4px; animation: splash-in .5s .16s ease both; }
.splash-wave { position: absolute; bottom: 0; left: 0; right: 0; width: 100%; height: 26px; }
@keyframes splash-in { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-title, .splash-tag { animation: none; }
}

/* ---------- Modal ---------- */
.overlay[hidden], .toast[hidden] { display: none; }

.overlay {
  position: fixed; inset: 0; background: rgba(11, 47, 102, .5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
  position: relative; animation: slideup .22s ease;
  box-shadow: 0 -8px 30px rgba(11, 47, 102, .22);
}
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } }

.modal h3 { font-size: 17px; font-weight: 800; padding-right: 34px; }
.modal-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px;
  border: 0; background: var(--bg); border-radius: 50%; cursor: pointer;
  font-size: 14px; color: var(--muted);
}

.report-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.report-opt {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 12px 6px; cursor: pointer; font: inherit; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: border-color .12s, background .12s;
}
.report-opt b { font-size: 16px; font-weight: 800; }
.report-opt span { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.report-opt:active { background: var(--accent-soft); border-color: var(--accent); }

.modal-thanks { margin-top: 16px; font-size: 14px; font-weight: 700; color: var(--green); background: var(--green-soft); border-radius: 10px; padding: 12px; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: var(--deep); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(11, 47, 102, .4);
  animation: fade .2s ease; max-width: calc(100vw - 40px); text-align: center;
}

/* ---------- Auth / formularios ---------- */
.footer-links { display: flex; gap: 14px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* Botón flotante de instalación (abajo a la derecha) */
.install-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 13.5px; color: #fff;
  background: linear-gradient(135deg, var(--deep), #14519c);
  border: 1px solid rgba(255,255,255,.25); border-radius: 999px;
  padding: 10px 16px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(11,47,102,.45);
}
.install-fab[hidden] { display: none; }
.install-fab:active { transform: scale(.96); }
.install-fab-logo { width: 26px; height: 26px; flex: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.install-hint {
  position: fixed; right: 16px; bottom: 72px; z-index: 60;
  max-width: min(320px, calc(100vw - 32px));
  font-size: 12px; color: #14233c; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(11,47,102,.25); line-height: 1.45;
}
.install-hint[hidden] { display: none; }
.field { display: block; margin-top: 14px; }
.field span { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: 11px; background: var(--card); color: var(--ink);
  resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26, 86, 160, .15); }
.auth-error { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--red); background: var(--red-soft); border-radius: 10px; padding: 10px 12px; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.btn-primary, .btn-ghost {
  font: inherit; font-size: 14px; font-weight: 700; padding: 11px; border-radius: 11px; cursor: pointer;
}
.btn-primary { border: 0; background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(26, 86, 160, .3); }
.btn-ghost { border: 1.5px solid var(--line); background: var(--card); color: var(--ink); }
.btn-primary:active, .btn-ghost:active { transform: scale(.97); }

/* ---------- RTL ---------- */
html[lang="ar"] .brand { flex-direction: row; }
html[lang="ar"] .header-top { flex-direction: row-reverse; }
html[lang="ar"] .modal-close { right: auto; left: 14px; }

@media (min-width: 600px) {
  .overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; }
}
