/* Cova — temas dark/light sincronizados con MapLibre */

/* evita parpadeo de Alpine en carga */
[x-cloak] { display: none !important; }

:root {
  --bg: #f7f5f0;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-fg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 4px 18px rgba(0,0,0,.08);
}
:root.dark {
  --bg: #0a0f0d;
  --panel: #111916;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --accent: #10b981;
  --accent-fg: #0a0f0d;
  --border: #1f2937;
  --shadow: 0 4px 18px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  background: var(--bg); color: var(--ink);
}

#map { position: absolute; inset: 56px 0 0; }

/* topbar ---------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand .logo { font-size: 22px; }
.brand strong { font-size: 18px; color: var(--accent); letter-spacing: -0.02em; }
.brand .sub { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font: inherit; min-width: 0;
}
.filters input[type=search] { width: 160px; }
.filters button {
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 16px;
}
.filters button:hover { background: var(--accent); color: var(--accent-fg); }

/* card lateral ---------------------------------------------------- */
.card {
  position: fixed; right: 12px; top: 72px; max-width: 360px; width: calc(100vw - 24px);
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
  z-index: 20; padding: 0;
}
.card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.card header h2 { margin: 0; font-size: 16px; }
.card header button.fav-btn {
  background: none; border: none; color: #f59e0b; cursor: pointer;
  font-size: 22px; padding: 0 6px; line-height: 1;
}
.card header button.fav-btn:hover { transform: scale(1.1); }
:root.dark .card header button.fav-btn { color: #fbbf24; }
.card header button {
  background: none; border: none; color: var(--ink); font-size: 18px; cursor: pointer;
}
.card img { width: 100%; height: 180px; object-fit: cover; display: block; }
.card .cat, .card .coord, .card .weather { padding: 0 14px; }
.card .cat { color: var(--accent); font-weight: 600; text-transform: capitalize; padding-top: 10px; margin: 0; }
.card .coord { color: var(--muted); font-size: 12px; margin: 4px 0; }
.card .weather { font-size: 13px; }
.card details { padding: 8px 14px; }
.card details summary { cursor: pointer; color: var(--accent); }
.card .desc { font-size: 13px; max-height: 160px; overflow: auto; }
.card .desc img { height: auto; border-radius: 8px; margin-top: 8px; }
.card .cta {
  display: block; margin: 12px; padding: 10px; text-align: center;
  background: var(--accent); color: var(--accent-fg); border-radius: 10px;
  text-decoration: none; font-weight: 600;
}
.card button.add-to-trip {
  display: block; margin: 12px 12px 0; padding: 8px; width: calc(100% - 24px);
  background: var(--bg); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 10px;
  cursor: pointer; font: inherit; font-weight: 600;
}
.card button.add-to-trip:hover { background: var(--accent); color: var(--accent-fg); }

/* modal settings -------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-body {
  background: var(--panel); color: var(--ink);
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
  border-radius: 16px; box-shadow: var(--shadow);
}
.modal-body header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-body h2 { margin: 0; font-size: 17px; }
.modal-body label { display: block; padding: 12px 16px 4px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body select {
  display: block; width: calc(100% - 32px); margin: 0 16px;
  padding: 8px 10px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.modal-body .warn {
  margin: 12px 16px; padding: 8px 12px; background: rgba(239,68,68,.1);
  border-radius: 8px; color: #ef4444; font-size: 13px;
}
.modal-body .models {
  margin: 12px 16px; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
}
.modal-body .model {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.modal-body .model small { color: var(--muted); font-size: 11px; margin-left: auto; }
.modal-body footer {
  padding: 14px 16px; border-top: 1px solid var(--border); text-align: right;
}
.modal-body footer button {
  padding: 8px 18px; background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 10px; font: inherit; cursor: pointer; font-weight: 600;
}

/* dark mode overrides para MapLibre */
:root.dark .maplibregl-ctrl-attrib { background: rgba(0,0,0,.6); color: #cbd5e1; }
:root.dark .maplibregl-ctrl-attrib a { color: #93c5fd; }
:root.dark .maplibregl-popup-content {
  background: var(--panel); color: var(--ink); border-radius: 10px;
}

/* ---- banner error (backend caído) ---- */
.banner {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: #fef3c7; color: #78350f;
  border-bottom: 1px solid #fbbf24;
  font-size: 14px;
}
:root.dark .banner { background: #422006; color: #fbbf24; border-bottom-color: #92400e; }
.banner button {
  margin-left: auto;
  background: #78350f; color: #fef3c7;
  border: none; border-radius: 6px; padding: 4px 12px;
  cursor: pointer; font: inherit;
}
:root.dark .banner button { background: #fbbf24; color: #422006; }

/* ---- spinner de carga inicial ---- */
.map-overlay {
  position: fixed; inset: 56px 0 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,.6); backdrop-filter: blur(2px);
  color: var(--muted); pointer-events: none;
}
:root.dark .map-overlay { background: rgba(10,15,13,.7); }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- modal hint y status ---- */
.modal-body .hint {
  margin: 12px 16px 4px; padding: 10px 12px;
  background: rgba(15,118,110,.08); border-radius: 8px;
  font-size: 12px; color: var(--muted);
}
.modal-body .status {
  margin: 12px 16px; padding: 8px 12px;
  background: var(--bg); border-radius: 8px;
  font-size: 13px; color: var(--muted);
}
.modal-body .warn-key {
  margin: 12px 16px; padding: 8px 12px;
  background: rgba(245,158,11,.1); border-radius: 8px;
  color: #92400e; font-size: 13px;
}
.modal-body .models { margin: 12px 16px; }
.modal-body .models-count {
  padding: 8px 10px; font-size: 12px; color: var(--muted);
  background: var(--bg); border-radius: 8px 8px 0 0;
  border: 1px solid var(--border); border-bottom: 0;
}
.modal-body .models-list, .modal-body .models .model-list {
  max-height: 280px; overflow: auto; border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
}

/* ajustar el orden del .models para que el count quede pegado */
.modal-body .models {
  border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; overflow: auto;
}
.modal-body .models-count {
  position: sticky; top: 0;
  background: var(--bg); border-radius: 8px 8px 0 0;
}
.modal-body .models-head {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}
.modal-body .models-count {
  position: static; /* anulado por .models-head */
  font-size: 12px; color: var(--muted); white-space: nowrap;
  background: transparent; border-radius: 0;
}
.modal-body .models-search {
  flex: 1; padding: 6px 10px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; outline: none;
}
.modal-body .models-search:focus {
  border-color: var(--accent);
}
.modal-body .models-empty {
  padding: 18px 12px; text-align: center;
  color: var(--muted); font-size: 13px;
}

/* ---- modal centrado (antes quedaba pegado a la izda) ---- */
.modal {
  align-items: center; justify-content: center; /* ya estaba, refuerzo */
}
.modal-body {
  /* en lugar de anclado a la izquierda, lo centramos bien */
  margin: 0;
  /* anula reglas que ubicaban modal a la izda accidentalmente */
}

/* ---- móvil: modal full-bleed ---- */
@media (max-width: 640px) {
  .modal { padding: 0; }
  .modal-body {
    width: 100vw; max-width: 100vw; max-height: 100vh;
    height: 100vh; border-radius: 0;
  }
  .modal-body header h2 { font-size: 16px; }
  .filters { gap: 4px; }
  .filters input[type=search] { width: 90px; font-size: 13px; }
  .filters button { padding: 5px 8px; }
}

/* ---- FAB Cova (botón flotante) ---- */
.fab-sira {
  position: fixed; right: 18px; bottom: 18px; z-index: 25;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, background .18s ease;
}
.fab-sira:hover { transform: scale(1.06); background: #14b8a6; }
.fab-sira.open { background: #ef4444; }
:root.dark .fab-sira.open { background: #ef4444; color: #fff; }

/* ---- Panel chat Cova ---- */
.chat-panel {
  position: fixed; right: 18px; bottom: 86px; z-index: 25;
  width: 380px; max-width: calc(100vw - 24px);
  height: 560px; max-height: calc(100vh - 110px);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
}
.chat-panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.chat-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.chat-brand .avatar { font-size: 22px; }
.chat-brand .status { font-size: 11px; padding: 2px 6px; border-radius: 8px;
                     background: rgba(127,127,127,.1); color: var(--muted); }
.chat-brand .status.online { background: rgba(16,185,129,.15); color: #10b981; }
.chat-brand .status.offline { background: rgba(239,68,68,.1); color: #ef4444; }
.chat-brand .status.busy    { background: rgba(245,158,11,.15); color: #d97706; }
.chat-panel header button {
  background: none; border: none; color: var(--ink); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px;
}
.chat-panel header button:hover { background: var(--bg); }

.chat-log {
  flex: 1; overflow: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 14px;
}
.chat-empty {
  color: var(--muted); font-size: 13px;
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 12px; padding: 12px; text-align: center;
  margin: auto 0;
}
.msg { display: flex; flex-direction: column; max-width: 90%; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg .bubble {
  padding: 8px 12px; border-radius: 14px;
  line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble {
  background: var(--accent); color: var(--accent-fg);
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg .meta {
  font-size: 10px; color: var(--muted); margin-top: 4px; padding: 0 8px;
}

/* typing dots */
.dots::after { content: '...'; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* input */
.chat-input {
  display: flex; gap: 6px; padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.chat-input textarea {
  flex: 1; resize: none;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font: inherit;
  outline: none;
}
.chat-input textarea:focus { border-color: var(--accent); }
.chat-input button {
  padding: 8px 14px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600;
}
.chat-input button:disabled { opacity: .4; cursor: not-allowed; }

/* responsive: en móvil el panel ocupa casi todo */
@media (max-width: 640px) {
  .chat-panel {
    right: 8px; bottom: 76px; left: 8px; width: auto;
    height: calc(100vh - 100px); max-height: none;
  }
}
/* ---- Timeline panel · Mi viaje ---- */
.timeline-panel {
  position: fixed; left: 18px; top: 72px; z-index: 22;
  width: 380px; max-width: calc(100vw - 24px);
  height: calc(100vh - 96px);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
  overflow: hidden;
}
.timeline-panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.timeline-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.timeline-brand .avatar { font-size: 22px; }
.timeline-panel header button {
  background: none; border: none; color: var(--ink); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px;
}
.timeline-panel header button:hover { background: var(--bg); }
.trip-body { flex: 1; overflow: auto; padding: 14px; }
.trip-empty {
  color: var(--muted); font-size: 13px; text-align: center;
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 12px; padding: 18px 14px; margin: 24px 0;
}
.trip-empty-sub { color: var(--muted); font-style: italic; font-size: 12px; }
.trip-cta {
  display: inline-block; margin-top: 12px; padding: 10px 18px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer;
}
.trip-header h3 { margin: 0 0 4px; font-size: 17px; }
.trip-summary { font-size: 12px; color: var(--muted); margin: 0 0 12px; }

.trip-day {
  margin-top: 14px; padding: 10px 0;
  border-top: 1px dashed var(--border);
}
.trip-day header {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 12px; color: var(--muted);
  border: 0; padding: 0;
}
.trip-day-idx {
  font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.trip-day-date { font-size: 12px; }

.trip-stops {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.trip-stops li {
  display: grid; grid-template-columns: 28px 1fr auto auto;
  gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 8px;
}
.trip-stops li:hover { background: var(--bg); }
.trip-stop-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  font-size: 12px; font-weight: 700;
}
.trip-stop-name { font-size: 13px; }
.trip-stops small {
  font-size: 11px; color: var(--muted);
  background: var(--bg); padding: 2px 6px; border-radius: 6px;
}
.trip-stop-del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 2px 6px;
  border-radius: 6px;
}
.trip-stop-del:hover { background: rgba(239,68,68,.1); color: #ef4444; }

/* topbar btn */
.itinerary-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 16px;
}
.itinerary-btn:hover { background: var(--accent); color: var(--accent-fg); }
.itinerary-btn.open { background: var(--accent); color: var(--accent-fg); }

@media (max-width: 640px) {
  .timeline-panel {
    left: 8px; right: 8px; width: auto;
    height: calc(100vh - 96px);
  }
}

/* ---- FAB Sidrerías ---- */
.fab-sidrerias {
  position: fixed; left: 18px; bottom: 18px; z-index: 21;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transition: transform 0.15s ease;
}
.fab-sidrerias:hover { transform: scale(1.06); }
.fab-sidrerias.open { background: var(--ink); color: var(--bg); }

/* ---- Panel Sidrerías ---- */
.sidrerias-panel {
  position: fixed; left: 18px; top: 72px; z-index: 22;
  width: 380px; max-width: calc(100vw - 24px);
  height: calc(100vh - 96px);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
  overflow: hidden;
}
.sidrerias-panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.sidrerias-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.sidrerias-brand .avatar { font-size: 22px; }
.sidrerias-panel header button {
  background: none; border: none; color: var(--ink); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px;
}
.sidrerias-panel header button:hover { background: var(--bg); }
.sidrerias-controls {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.sidrerias-controls label {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
}
.sidrerias-controls select {
  padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--ink); font: inherit;
}
.sidrerias-refresh {
  margin-left: auto; padding: 6px 12px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 8px; cursor: pointer; font: inherit;
}
.sidrerias-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.sidrerias-body { flex: 1; overflow: auto; padding: 10px 14px; }
.sidrerias-empty, .sidrerias-error {
  color: var(--muted); font-size: 13px; text-align: center;
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 10px; padding: 14px; margin: 12px 0;
}
.sidrerias-error { color: #ef4444; border-color: #ef4444; }
.sidreria-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.sidreria-card.is-sidreria {
  border-left: 3px solid #ef4444;
  background: linear-gradient(90deg, rgba(239,68,68,.04), var(--bg) 30%);
}
.sidreria-card header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0; border: 0; margin-bottom: 4px;
}
.sidreria-card strong { font-size: 14px; }
.sidreria-kind { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.sidreria-meta { margin: 4px 0 6px; font-size: 12px; color: var(--muted); }
.sidreria-dist { font-weight: 600; color: var(--ink); }
.sidreria-badge {
  display: inline-block; margin-left: 8px;
  background: #ef4444; color: #fff;
  padding: 1px 6px; border-radius: 6px; font-size: 10px;
}
.sidreria-actions {
  display: flex; gap: 8px; margin-top: 6px;
}
.sidrerias-actions a {
  font-size: 12px; color: var(--accent); text-decoration: none;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.sidreria-actions a:hover { background: var(--accent); color: var(--accent-fg); }
@media (max-width: 640px) {
  .sidrerias-panel {
    left: 8px; right: 8px; width: auto;
    height: calc(100vh - 96px);
  }
  .fab-sidrerias { left: 12px; bottom: 12px; }
}

