:root {
  --bg: #eaf0f6;
  --card-bg: rgba(15, 23, 42, 0.95);
  --card-border: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
  --text-sub: #cbd5e1;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --rain-blue: #38bdf8;
  --cold-cyan: #67e8f9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg);
  overflow: hidden;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg) !important;
}

.leaflet-container {
  background: var(--bg) !important;
}

/* Header superior */
.app-topbar {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  right: 0.85rem;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
}

.app-topbar > * {
  pointer-events: auto;
}

.nav-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  flex-shrink: 0;
}

.nav-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.reset-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  display: none;
  transition: background 0.15s;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Buscador */
.search-container {
  position: relative;
  width: 280px;
  max-width: 45vw;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35);
}

.search-icon {
  font-size: 0.82rem;
  margin-right: 0.45rem;
  opacity: 0.7;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  width: 100%;
}

.search-input::placeholder {
  color: var(--text-dim);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  max-height: 230px;
  overflow-y: auto;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
  display: none;
  scrollbar-width: none;
}

.search-results::-webkit-scrollbar {
  display: none;
}

.search-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover, .search-item.active {
  background: rgba(56, 189, 248, 0.15);
}

.item-city {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.item-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 1px;
}

/* Botones GPS e Info */
.geo-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.48rem 0.85rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: background 0.15s;
  white-space: nowrap;
}

.geo-btn:hover {
  background: rgba(30, 41, 59, 0.98);
}

.geo-btn.loading .geo-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@media (max-width: 680px) {
  .search-container {
    width: auto;
    flex-grow: 1;
    max-width: none;
  }
  .geo-label {
    display: none;
  }
  .geo-btn {
    padding: 0.48rem 0.55rem;
    border-radius: 50%;
  }
  .nav-header {
    padding: 0.45rem 0.65rem;
  }
}

.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
}

/* Pastillas del tiempo */
.weather-pill {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.2s ease;
  user-select: none;
}

.weather-pill:hover, .weather-pill.active {
  transform: translate(-50%, -50%) scale(1.08);
  background: #0284c7;
  border-color: #ffffff;
  z-index: 1000 !important;
}

.weather-pill.rain-alert {
  border-color: var(--rain-blue);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
  animation: rainPulse 2.5s infinite;
}

@keyframes rainPulse {
  0%, 100% { border-color: rgba(56, 189, 248, 0.6); }
  50% { border-color: #ffffff; box-shadow: 0 0 18px rgba(56, 189, 248, 0.9); }
}

.pill-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
}

.pill-temp {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Tarjeta flotante */
.leaflet-popup-content-wrapper {
  background: var(--card-bg) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 18px !important;
  padding: 0 !important;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45) !important;
  color: var(--text) !important;
  overflow: hidden !important;
}

.leaflet-popup-tip {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: none !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 334px !important;
  max-width: calc(100vw - 32px) !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 50% !important;
  width: 26px !important;
  height: 26px !important;
  line-height: 24px !important;
  text-align: center !important;
  top: 10px !important;
  right: 10px !important;
  padding: 0 !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.popup-top-bar {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
}

.popup-card {
  padding: 0.9rem 1.1rem 0.9rem;
  position: relative;
}

.popup-card.bg-sun { background: radial-gradient(circle at top right, rgba(250, 204, 21, 0.16) 0%, rgba(245, 158, 11, 0.04) 55%, transparent 85%); }
.popup-top-bar.bar-sun { background: linear-gradient(90deg, #facc15, #fbbf24, #f59e0b); }

.popup-card.bg-night { background: radial-gradient(circle at top right, rgba(129, 140, 248, 0.18) 0%, rgba(49, 46, 129, 0.08) 60%, transparent 85%); }
.popup-top-bar.bar-night { background: linear-gradient(90deg, #818cf8, #6366f1, #312e81); }

.popup-card.bg-clouds { background: radial-gradient(circle at top right, rgba(148, 163, 184, 0.15) 0%, rgba(71, 85, 105, 0.05) 55%, transparent 85%); }
.popup-top-bar.bar-clouds { background: linear-gradient(90deg, #64748b, #94a3b8, #cbd5e1); }

.popup-card.bg-rain { background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.2) 0%, rgba(30, 58, 138, 0.08) 60%, transparent 85%); }
.popup-top-bar.bar-rain { background: linear-gradient(90deg, #38bdf8, #2563eb, #60a5fa); }

.popup-card.bg-heat { background: radial-gradient(circle at top right, rgba(249, 115, 22, 0.22) 0%, rgba(220, 38, 38, 0.08) 60%, transparent 85%); }
.popup-top-bar.bar-heat { background: linear-gradient(90deg, #fb923c, #ef4444, #b91c1c); }

.popup-card.bg-cold { background: radial-gradient(circle at top right, rgba(165, 243, 252, 0.22) 0%, rgba(14, 116, 144, 0.08) 60%, transparent 85%); }
.popup-top-bar.bar-cold { background: linear-gradient(90deg, #a5f3fc, #67e8f9, #bae6fd); }

.pop-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-right: 28px;
  margin-bottom: 0.15rem;
}

.pop-city-box {
  display: flex;
  flex-direction: column;
}

.pop-city {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.pop-province {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.pop-temp-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.pop-temp {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  margin-left: 0.5rem;
}

.pop-time-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 3px;
}

.pop-verdict {
  font-size: 1.18rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  margin-top: 0.35rem;
  display: inline-block;
}

.weather-anim-sun { color: #fde047 !important; }
.weather-anim-night { color: #c7d2fe !important; }
.weather-anim-cloud { color: #cbd5e1 !important; }
.weather-anim-rain { color: var(--rain-blue) !important; }
.weather-anim-heat { color: #fb923c !important; }
.weather-anim-cold { color: var(--cold-cyan) !important; }
.weather-anim-wind { color: #e2e8f0 !important; }

.pop-sub {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.75rem;
  line-height: 1.25;
  min-height: 2em;
}

.pop-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.45rem 0.3rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.pop-stats div span {
  display: block;
  font-size: 0.62rem;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}

.pop-stats div strong {
  font-size: 0.88rem;
  font-weight: 800;
  color: #ffffff;
}

/* Indicador de viento */
.wind-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.wind-arrow {
  display: inline-block;
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 0.25s ease;
}

/* Selector segmentado de pestañas */
.pop-tabs-header {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 0.65rem;
  gap: 3px;
}

.pop-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  user-select: none;
}

.pop-tab-btn:hover {
  color: #ffffff;
}

.pop-tab-btn.is-active {
  background: var(--accent);
  color: #0b1120;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.pop-hourly-view, .pop-daily-view {
  display: none;
}

.pop-hourly-view.is-active {
  display: flex;
}

.pop-daily-view.is-active {
  display: flex;
  flex-direction: column;
}

/* Carrusel de horas con Drag-to-scroll */
.pop-hourly-row {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 2px 2px 4px;
  user-select: none;
  cursor: grab;
}

.pop-hourly-row.is-dragging {
  cursor: grabbing;
  user-select: none;
  scroll-behavior: auto !important;
}

.pop-hourly-row::-webkit-scrollbar {
  display: none;
}

.pop-hour-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 0.45rem 0.4rem;
  min-width: 58px;
  text-align: center;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.pop-hour-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.pop-hour-pill.is-active {
  background: #0284c7 !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
  transform: translateY(-2px) scale(1.04);
}

.pop-h-t {
  font-size: 0.66rem;
  color: var(--text-dim);
  font-weight: 700;
}

.pop-hour-pill.is-active .pop-h-t {
  color: #e0f2fe;
}

.pop-h-icon {
  font-size: 1.15rem;
  line-height: 1;
  margin: 1px 0;
}

.pop-h-deg {
  font-size: 0.95rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
}

.pop-h-prob {
  font-size: 0.62rem;
  color: var(--rain-blue);
  font-weight: 700;
}

.pop-hour-pill.is-active .pop-h-prob {
  color: #ffffff;
}

/* Vista de 5 días */
.pop-daily-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pop-daily-row:last-child {
  border-bottom: none;
}

.pop-d-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  width: 75px;
}

.pop-d-center {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.pop-d-icon {
  font-size: 1.1rem;
}

.pop-d-rain {
  font-size: 0.65rem;
  color: var(--rain-blue);
  font-weight: 700;
  min-width: 32px;
}

.pop-d-range {
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  gap: 0.4rem;
}

.pop-d-min {
  color: var(--text-dim);
  font-weight: 600;
}

/* Panel informativo SEO */
.info-panel {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 540px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.2rem;
  z-index: 2000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  color: var(--text);
}

.info-content h1 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  color: var(--accent);
}

.info-content h2 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0.6rem 0 0.2rem;
  color: #ffffff;
}

.info-content p {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-sub);
}

.close-info-btn {
  float: right;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}