/* Topbar */
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:var(--panel); border-bottom:1px solid var(--border);
  box-shadow:var(--shadow);
}
.brand{ display:flex; gap:10px; align-items:center }
.brand .home{ text-decoration:none; font-size:20px }
.topbar h1{ font-size:18px; margin:0 }
.actions{ display:flex; gap:8px; align-items:center }
.btn{ display:inline-flex; align-items:center; gap:8px; height:36px; padding:0 12px; border-radius:10px; border:1px solid var(--border); background:#f7f7f7; cursor:pointer; }
.btn:hover{ filter:brightness(.98) }
.input{ height:36px; padding:0 10px; border:1px solid var(--border); border-radius:10px; background:#fff; min-width:0; }

/* Layout */
.wrap{ max-width:1100px; margin:18px auto; padding:0 16px }
.card{ background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:14px; box-shadow:0 2px 8px rgba(0,0,0,.03); margin-bottom:14px }
.row{ display:flex; flex-wrap:wrap; gap:8px; align-items:center }
.hint{ color:var(--muted); font-size:12px }
.muted{ color:var(--muted) } .small{ font-size:12px }

.grid{ display:grid; gap:12px; grid-template-columns: 1.1fr 0.9fr; }
.grid > .card:nth-child(3){ grid-column: 1 / -1; }
@media (max-width: 900px){ .grid{ grid-template-columns: 1fr } .grid > .card:nth-child(3){ grid-column:auto } }

/* Mapa */
#map{ width:100%; height:380px; border:1px solid var(--border); border-radius:12px; overflow:hidden }
.leaflet-control-layers{ border-radius:10px; border:1px solid var(--border); box-shadow:var(--shadow) }

/* KVs */
.kvs{ display:grid; gap:10px; grid-template-columns: 1fr; }
.kv{
  color: #1f2328;
  display:grid; grid-template-columns: 32px 1fr; align-items:center; gap:10px;
  border:1px solid var(--border); border-radius:12px; background:#fff;
  padding:10px 12px; box-shadow:0 1px 4px rgba(0,0,0,.02);
}
.kv-ico{ width:32px; height:32px; border-radius:8px; display:grid; place-items:center; background:#f3f4f6; font-size:16px }
.kv-main{ font-weight:800; font-size:18px; line-height:1.1 }
.kv-main .unit{ margin-left:4px; color:var(--muted); font-weight:600 }
.kv-sub{ font-size:12px; color:var(--muted); margin-top:2px }

/* Pronóstico días */
.forecast-day{ border:1px solid var(--border); border-radius:12px; background:#fff; margin-bottom:10px; overflow:hidden }
.forecast-header{
  display:grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr; /* cada elemento directo ocupa la misma fracción */
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  color: #1f2328;
}
.forecast-header > .hdr-left{
  display:flex;
  align-items:center;
  gap:10px;
  flex:1 1 auto;
  min-width:0; /* evita que el texto empuje la flecha fuera */
  overflow:hidden;
}
.forecast-header > .arrow{
  flex:0 0 auto;
  margin-left:12px;
  font-size:18px;
  color:var(--muted);
}
.forecast-header b{ font-weight:700 }
.forecast-detail { 
  display: none; 
  padding: 10px 12px; 
  font-size: 13px; 
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.hr-row{ display:flex; gap:10px; justify-content:space-between; border-top:1px dashed var(--border); padding-top:6px; margin-top:6px }
.hr-left{ color:var(--muted) }

.badge{ display:inline-block; padding:2px 6px; border-radius:4px; color:#fff; font-weight:600; font-size:12px; border:1px solid var(--border) }
.badge-green{ background:#16a34a; } .badge-olive{ background:#4d7c0f; } .badge-amber{ background:#d97706; } .badge-red{ background:#dc2626; }

/* Añade en tu CSS global */
#fishing-legend { 
  font-size:13px;
  color:#222;
  background:#f7f7f9;
  border:1px solid #e6e6ea;
  padding:8px 12px;
  border-radius:8px;
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
  margin:0 0 10px 0;
}
#fishing-legend .legend-row { min-width:220px; }
#fishing-legend .legend-note { color:#666; font-size:12px; margin-left:auto; min-width:180px; text-align:right; }

/* Evitar que el mapa tape el panel de pronóstico / toggle */
.forecast-day,
.forecast-header,
.forecast-detail {
  position: relative;
  z-index: 1100; /* panel por encima del mapa */
}

/* Selector genérico para contenedores de mapa (Leaflet, Mapbox, etc.)
   baja su z-index para que no cubra los controles del UI */
.leaflet-container,
.map,
#map,
.map-container {
  position: relative;
  z-index: 0 !important;
}

/* Asegura que el botón/toggle sea clicable y visible */
.forecast-header {
  cursor: pointer;
  z-index: 1110;
}

/* Si el panel se expande, mantenerlo sobre el mapa */
.forecast-day.open {
  z-index: 1120;
}

/* Nuevo: estilo tipo "tabla" — hora arriba centrada y la información debajo en fila */
.forecast-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

/* cada hora como tarjeta: hora en la parte superior, contenido debajo */
.hr-row{
  display: grid;
  grid-template-columns: 72px 1fr;    /* hora | contenido */
  grid-auto-rows: minmax(88px, auto);
  gap: 8px;
  align-items: center;                /* centra verticalmente */
  justify-items: start;
  width: 160px;
  min-width: 140px;
  padding: 12px;
  box-sizing: border-box;
}

/* Centrar todo el bloque derecho bajo la hora */
.hr-row > div:nth-child(2){
  display: flex;
  flex-direction: column;
  align-items: center;    /* centra horizontalmente */
  justify-content: center;/* centra verticalmente dentro de la celda */
  text-align: center;
  gap: 6px;
  min-width: 0;
  box-sizing: border-box;
}

/* Asegurar que la línea principal y las métricas estén centradas */
.hr-main{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
}
.hr-metrics{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
}

/* Centrar iconos dentro de cada métrica */
.hr-metrics .m-item{ display:inline-flex; align-items:center; justify-content:center; gap:6px; }

/* Mantener el bloque de la hora separado y centrado verticalmente */
.hr-row > .hr-left{
  grid-column:1/2;
  grid-row:1/3;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* Responsive: en pantallas pequeñas vuelve a alineado a la izquierda para legibilidad */
@media (max-width:700px){
  .forecast-day.open > .forecast-detail {
    justify-content: center !important;
  }

  .hr-row{
    width:100%;
    grid-template-columns: 56px 1fr;
    gap:12px;
  }
  .hr-row > div:nth-child(2){
    align-items:flex-start;
    text-align:left;
    justify-content:center;
  }
  .hr-metrics{ justify-content:flex-start; }
}

/* ...existing code... */

.forecast-day { text-align: left; display: block; }

.forecast-header {
  display: flex;
  justify-content: space-between; /* JUSTIFICADO: espacio entre los extremos */
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
/* contenido interno de la cabecera: permitir que el texto ocupe el espacio disponible */
.forecast-header > span { display: flex; align-items: center; gap: 8px; flex: 1; }

/* detalle oculto por defecto; al abrir .forecast-day.open lo convertimos en fila con items justificados */
.forecast-detail {
  display: none;
  padding: 10px 12px;
  font-size: 13px;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  justify-content: flex-start;
}

/* cuando se abre, filas horizontales que envuelven y se distribuyen (justificado) */
.forecast-day.open > .forecast-detail {
  display: flex !important;
  flex-flow: row wrap !important;
  gap: 12px !important;
  align-items: flex-start !important;
  justify-content: space-between/* JUSTIFICADO: repartir el espacio entre columnas */
}

/* dejar la tarjeta por hora igual, pero contenido alineado a la izquierda */
.hr-row{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  flex: 0 0 160px;
  width: 160px;
  min-width: 140px;
  padding: 10px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.0), rgba(250,250,250,0.02));
  border-radius: 8px;
  transition: background .12s ease, transform .06s ease;
  box-sizing: border-box;
  margin: 0;
}

/* hora: mantener bloque, pero alineado a la izquierda dentro de la tarjeta */
.hr-row > .hr-left{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap:8px;
  width: 84px;
  height: 36px;
  margin: 0 0 8px 0;
  font-weight: 800;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
}

/* resumen/nota alineada a la izquierda */
.hint { text-align: left; }

/* mantener z-index sobre el mapa */
.forecast-day, .forecast-header, .forecast-detail, .hr-row { position: relative; z-index: 1100; }

/* Card de pronóstico a ancho completo */
.card.fullwidth-forecast {
  max-width: none;
  width: 100%;
  margin: 12px 0;
  padding-left: 12px;
  padding-right: 12px;
  border-radius: 12px;
}

/* Asegura que el detalle y la cabecera ocupen todo el ancho dentro de la card */
.card.fullwidth-forecast .forecast-header,
.card.fullwidth-forecast .forecast-detail {
  width: 100%;
  box-sizing: border-box;
}

/* Forzar que la lista de días rellene el ancho interno */
.card.fullwidth-forecast .forecast-day { width: 100%; }

/* Forzar alineación vertical consistente del icono lunar */
.forecast-header .moon{
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 18px;
  margin-left: 8px;
  vertical-align: middle;
  transform: translateY(1px); /* ajustar si hace falta (0..2px) */
}

/* Si aún hay pequeñas diferencias entre navegadores, usar fallback ajustado */
.forecast-header .moon img,
.forecast-header .moon svg { width: 100%; height: 100%; display:block; }

/* Tarjeta horaria: bloque cuadrado, contenido centrado */
.forecast-detail .hr-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 160px;            /* ancho base */
  min-width: 140px;
  max-width: 220px;
  padding: 12px;
  gap: 8px;
  box-sizing: border-box;
  text-align: center;
  background: transparent;
}

/* bloque de hora (badge) consistente */
.forecast-detail .hr-row .hr-left {
  width: 64px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border-radius: 8px;
  font-weight: 800;
  color: var(--muted);
  box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
}

/* bloque de métricas: evitar saltos y recortar si es necesario */
.forecast-detail .hr-row > div:nth-child(2) {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  box-sizing: border-box;
}

/* iconos y emoji: tamaño fijo y centrado verticalmente */
.forecast-detail .hr-row .moon,
.forecast-detail .hr-row img,
.forecast-detail .hr-row svg {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

/* hover/activo opcional: ligera elevación */
.forecast-detail .hr-row:hover { transform: translateY(-2px); transition: transform .12s ease; }

/* Responsive: en pantallas pequeñas convertir en fila para aprovechar ancho */
@media (max-width: 700px) {
  .forecast-detail .hr-row {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  .forecast-detail .hr-row .hr-left { width: 56px; height: 36px; }
  .forecast-detail .hr-row > div:nth-child(2) { white-space: normal; }
}

/* Overrides para evitar que el contenido se corte */
.forecast-header{
  /* columnas iguales pero con mínimo para evitar recorte extremo */
  grid-auto-columns: minmax(80px, 1fr) !important;
}

/* permitir que los items internos hagan wrap y no se queden en ellipsis */
.forecast-header .hdr-item,
.forecast-header > span,
.forecast-header .hdr-left {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  min-width: 0;
}

/* mantener fecha y badge sin partir para conservar legibilidad */
.forecast-header .date,
.forecast-header .badge-wrap,
.forecast-header b,
.forecast-header .badge {
  white-space: nowrap;
}

/* El wrapper de métricas (temp/wind/press) puede envolver en varias líneas */
.forecast-header .temp,
.forecast-header .wind,
.forecast-header .press {
  white-space: normal;
  line-height: 1.05;
}

/* Evitar truncado en las tarjetas horarias: permitir wrap de métricas */
.forecast-detail .hr-row > div:nth-child(2) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

/* En pantallas muy pequeñas seguir usando compactación pero sin cortar */
@media (max-width: 700px) {
  .forecast-header { grid-auto-columns: minmax(60px, 1fr) !important; }
  .forecast-header .date, .forecast-header .badge-wrap { white-space: nowrap; }
  .forecast-detail .hr-row > div:nth-child(2) { white-space: normal; }
}

/* score-dot: circulito con número, color según rango */
.score-dot{
  display:inline-grid;
  place-items:center;
  width:28px;
  height:28px;
  border-radius:50%;
  font-weight:800;
  color:#fff;
  font-size:12px;
  line-height:1;
  margin-right:8px;
  flex:0 0 auto;
}
.score-dot.score-green{ background:#16a34a; }
.score-dot.score-olive{ background:#4d7c0f; }
.score-dot.score-amber{ background:#d97706; }
.score-dot.score-red{ background:#dc2626; }
.score-dot.score-none{ background:#9ca3af; color:#fff; }

/* ajustes de la hr-row para nueva estructura */
.hr-row > div:nth-child(2) .hr-main{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:700;
}
.hr-row > div:nth-child(2) .hr-score-text{ color:var(--muted); font-weight:700; }
.hr-row > div:nth-child(2) .hr-metrics{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
  display:inline-grid;
  gap:8px;
  flex-wrap:wrap;
  line-height:1.1;
}

/* ---------- hr-row: diseño compacto horizontal (reemplazo) ---------- */
.hr-row{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:12px;
  width:100%;
  max-width:420px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(250,250,250,0.00));
  box-sizing:border-box;
  transition: transform .08s ease, box-shadow .12s ease;
}

/* hora: bloque fijo a la izquierda */
.hr-row > .hr-left{
  flex:0 0 72px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:72px;
  height:44px;
  background:#f3f4f6;
  border-radius:8px;
  font-weight:800;
  color:var(--muted);
}

/* contenido principal: score arriba y métricas debajo (pero en una sola línea si cabe) */
.hr-row > div:nth-child(2){
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}

/* línea superior: score + texto corto */
.hr-row .hr-main{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:700;
  min-width:0;
  overflow:hidden;
}
.hr-row .hr-main .hr-score-text{ color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* línea de métricas: intentar en una sola línea, permitir wrap en pantallas pequeñas */
.hr-row .hr-metrics{
  display:flex;
  gap:10px;
  align-items:center;
  color:var(--muted);
  font-size:13px;
  flex-wrap:nowrap;
  min-width:0;
}
@media (max-width:520px){
  .hr-row .hr-metrics{ flex-wrap:wrap; gap:6px; }
}

/* score-dot: tamaño compacto, centrado verticalmente */
.score-dot{
  display:inline-grid;
  place-items:center;
  width:34px;
  height:34px;
  border-radius:50%;
  font-weight:800;
  color:#fff;
  font-size:13px;
  line-height:1;
  flex:0 0 auto;
}
.score-dot.score-green{ background:#16a34a; }
.score-dot.score-olive{ background:#4d7c0f; }
.score-dot.score-amber{ background:#d97706; }
.score-dot.score-red{ background:#dc2626; }
.score-dot.score-none{ background:#9ca3af; }

/* Variante "solo punto" (sin número): usar clase .dot-only en lugar de texto */
.score-dot.dot-only{ width:14px; height:14px; font-size:0; border-radius:50%; }

/* hover */
.hr-row:hover{ transform: translateY(-3px); box-shadow: 0 8px 18px rgba(15,23,42,0.06); }
/* ---------- fin del reemplazo ---------- */

/* Selector de especie */
#fishing-species-wrap { display:flex; align-items:center; gap:8px; margin:0 0 12px 0; }
#fishing-species-wrap label { font-weight:600; color:var(--muted); }
#fishing-species-select {
  padding:8px 10px;
  border-radius:6px;
  border:1px solid rgba(0,0,0,0.08);
  background:var(--card-bg, #fff);
  font-size:14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  min-width:140px;
}

/* Resumen de pesos (encima del día) */
.weights-summary{
  padding:8px 12px;
  margin:0 0 8px 0;
  font-size:13px;
  color:var(--muted);
  background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
  border-radius:6px;
  border:1px solid rgba(0,0,0,0.03);
}
.weights-summary small{ display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Mejoras en layout horario */
.hr-row { display:flex; gap:12px; align-items:center; padding:6px 8px; border-radius:6px; }
.hr-left { width:56px; font-weight:600; color:var(--muted); }

/* Apilar la cabecera y ajustar tarjetas HORAS solo en pantallas pequeñas */
@media (max-width:700px) {
  .forecast-header{
    display:flex;
    flex-direction:column;
    gap:8px;
    padding:8px 10px;
  }
  /* cada elemento de la cabecera ocupa toda la fila y se reparten extremos */
  .forecast-header > * {
    /* width:100%; */
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:8px;
  }
  .forecast-header .date,
  .forecast-header .badge-wrap {
    white-space: normal;
  }
  .forecast-header .arrow-wrap {
    display: none;
    justify-self:stretch;
    justify-content:flex-end;
  }

  /* asegurar que el detalle horario ocupe todo el ancho en móvil */
  .forecast-detail .hr-row {
    width:100%;
    min-width:0;
    display:flex;
    flex-direction:row;
    gap:12px;
    align-items:center;
  }
  .forecast-detail .hr-row > div:nth-child(2){
    align-items:flex-start;
    text-align:left;
    white-space:normal;
  }
}
