/* ─── Variables — tema Bluey ─────────────────────────────────────────────── */
:root {
  --bg:         #FFFAF4;
  --surface:    #FFFFFF;
  --surface2:   #FFF3E4;
  --border:     rgba(45, 27, 0, 0.10);
  --shadow:     0 3px 14px rgba(45, 27, 0, 0.08);
  --text:       #2D1B00;
  --text-muted: #9B7740;
  --accent:     #5BB8F5;
  --topbar-h:   68px;
  --statsbar-h: 48px;
  --filters-h:  82px;
  --radius:     16px;
  --radius-sm:  12px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

a { color: #1E88E5; text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 3px solid var(--border);
  box-shadow: 0 3px 16px rgba(45, 27, 0, 0.07);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
}

.topbar-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
}

.topbar-notices {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 20px;
  border-right: 2px dashed var(--border);
}

.update-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.65;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 22px;
  font-weight: 900;
  color: #5BB8F5;
  letter-spacing: -0.5px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFF3E4;
  border: 2px solid #FF9F43;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  color: #E67E22;
  font-weight: 800;
}

.live-dot {
  width: 7px; height: 7px;
  background: #FF9F43;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ─── Stats bar — banda azul Bluey ──────────────────────────────────────── */
.stats-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  height: var(--statsbar-h);
  background: #5BB8F5;
  border-bottom: 3px solid #3BA5E8;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  overflow-x: auto;
  z-index: 999;
}

.stats-bar::-webkit-scrollbar { display: none; }

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 20px;
  padding: 3px 12px;
}

.stat span {
  font-size: 16px;
  font-weight: 900;
  color: #FFFFFF;
}

.stat small {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-teatro   { background: rgba(255, 107, 107, 0.35); border-color: rgba(255, 107, 107, 0.55); }
.stat-musica   { background: rgba(255, 159,  67, 0.35); border-color: rgba(255, 159,  67, 0.55); }
.stat-expo     { background: rgba(162, 155, 254, 0.35); border-color: rgba(162, 155, 254, 0.55); }
.stat-gratis   { background: rgba( 85, 239, 196, 0.35); border-color: rgba( 85, 239, 196, 0.55); }
.stat-infantil { background: rgba(253, 203, 110, 0.45); border-color: rgba(253, 203, 110, 0.65); }

/* ─── Filtros ────────────────────────────────────────────────────────────── */
.filters {
  position: fixed;
  left: 0; right: 0;
  height: 41px;
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 6px;
  overflow-x: auto;
  z-index: 998;
}

.filters::-webkit-scrollbar { display: none; }

.filters-cuando {
  top: calc(var(--topbar-h) + var(--statsbar-h));
}

.filters-tipo {
  top: calc(var(--topbar-h) + var(--statsbar-h) + 41px);
}

.filter-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-sep {
  width: 2px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
  border-radius: 2px;
}

.filter-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 2px 11px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: #1E88E5;
  background: rgba(91, 184, 245, 0.08);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(91, 184, 245, 0.40);
}

/* ─── Layout principal ───────────────────────────────────────────────────── */
.main {
  position: fixed;
  top: calc(var(--topbar-h) + var(--statsbar-h) + var(--filters-h));
  left: 0; right: 0;
  bottom: 0;
  display: flex;
}

/* ─── Mapa ───────────────────────────────────────────────────────────────── */
#map {
  flex: 1;
  height: 100%;
  background: #D4E8F7;
}

/* Zoom controls al estilo Bluey */
.leaflet-bar {
  border: 2px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 12px rgba(45, 27, 0, 0.12) !important;
  overflow: hidden;
}

.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom-color: var(--border) !important;
  font-weight: 900 !important;
  font-size: 16px !important;
  line-height: 26px !important;
  width: 28px !important;
  height: 28px !important;
}

.leaflet-bar a:hover {
  background: var(--surface2) !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  font-size: 10px;
  border-radius: 6px 0 0 0;
}

/* ─── Panel lateral ──────────────────────────────────────────────────────── */
.panel {
  width: 310px;
  height: 100%;
  background: var(--surface);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: -4px 0 20px rgba(45, 27, 0, 0.06);
}

.panel-header {
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 8px;
}

#panel-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.keyword-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 3px 9px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}

.keyword-input::placeholder { color: var(--text-muted); font-weight: 600; }
.keyword-input:focus { border-color: var(--accent); }

.panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.panel-list::-webkit-scrollbar { width: 4px; }
.panel-list::-webkit-scrollbar-track { background: transparent; }
.panel-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.panel-footer {
  padding: 8px 14px;
  border-top: 2px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface2);
}

.panel-credit {
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.5;
  font-style: italic;
}

/* ─── Items del panel ────────────────────────────────────────────────────── */
.inc-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(45, 27, 0, 0.04);
}

.inc-item:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 12px rgba(91, 184, 245, 0.22);
  transform: translateY(-1px);
}

.inc-item.selected {
  border-color: var(--accent);
  background: rgba(91, 184, 245, 0.07);
  box-shadow: 0 3px 12px rgba(91, 184, 245, 0.22);
}

.inc-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.inc-cat-icon { font-size: 15px; flex-shrink: 0; }

.inc-titulo {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.inc-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 21px;
}

.inc-fecha   { font-size: 11px; color: #1E88E5; font-weight: 700; }
.inc-lugar   { font-size: 11px; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.inc-distrito { font-size: 10px; color: var(--text-muted); opacity: 0.65; }

.inc-footer {
  margin-left: 21px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-gratis {
  background: rgba(85, 239, 196, 0.18);
  color: #00B894;
  border: 2px solid rgba(85, 239, 196, 0.45);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  letter-spacing: 0.5px;
}

.inc-link { font-size: 11px; color: #1E88E5; font-weight: 700; }

.empty-msg, .loading {
  padding: 30px 14px;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

/* ─── Popups ─────────────────────────────────────────────────────────────── */
.leaflet-popup,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip-container,
.leaflet-popup-tip {
  pointer-events: none !important;
}

.leaflet-popup-content-wrapper {
  background: #FFFFFF !important;
  color: var(--text) !important;
  border: 3px solid #5BB8F5 !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 30px rgba(45, 27, 0, 0.14) !important;
}

.leaflet-popup-content {
  pointer-events: auto !important;
  margin: 12px 14px !important;
}

.leaflet-popup-tip { background: #FFFFFF !important; }

.popup-evento { min-width: 220px; }

.popup-cat {
  font-size: 10px;
  text-transform: uppercase;
  color: #5BB8F5;
  letter-spacing: 0.8px;
  font-weight: 800;
  margin-bottom: 4px;
}

.popup-titulo {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 6px;
  color: var(--text);
}

.popup-fecha  { font-size: 12px; color: #1E88E5; font-weight: 700; margin-bottom: 4px; }
.popup-lugar  { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }

.popup-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
  border-top: 2px dashed var(--border);
  padding-top: 6px;
}

.popup-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.popup-gratis {
  background: rgba(85, 239, 196, 0.18);
  color: #00B894;
  border: 2px solid rgba(85, 239, 196, 0.45);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
}

.popup-precio { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.popup-link   { font-size: 11px; color: #1E88E5; font-weight: 700; }

/* ─── Leyenda ────────────────────────────────────────────────────────────── */
.leyenda {
  position: fixed;
  bottom: 24px;
  left: 12px;
  background: #FFFFFF;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(45, 27, 0, 0.10);
}

.leyenda-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.leyenda-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(45, 27, 0, 0.15);
}

/* ─── Error ───────────────────────────────────────────────────────────────── */
.error-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 107, 107, 0.12);
  border: 2px solid rgba(255, 107, 107, 0.45);
  color: #C0392B;
  padding: 8px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  z-index: 2000;
}

/* ─── Buscador de calles ─────────────────────────────────────────────────── */
.search-container {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 600;
  width: 270px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  border: 2px solid var(--border);
  border-radius: 22px;
  padding: 5px 10px;
  box-shadow: 0 4px 16px rgba(45, 27, 0, 0.12);
}

.gps-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
  transition: transform 0.15s;
}
.gps-btn:hover { transform: scale(1.2); }
.gps-btn:disabled { opacity: 0.5; cursor: default; }

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
}

.search-input::placeholder { color: var(--text-muted); font-weight: 600; }

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 0 2px;
  line-height: 1;
  font-weight: 900;
  flex-shrink: 0;
}

.search-clear:hover { color: var(--text); }

.search-suggestions {
  list-style: none;
  background: #FFFFFF;
  border: 2px solid var(--border);
  border-radius: 14px;
  margin-top: 5px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(45, 27, 0, 0.12);
}

.search-suggestions li {
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

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

.search-suggestions li:hover {
  background: rgba(91, 184, 245, 0.08);
  color: #1E88E5;
}

/* ─── Badge de distrito activo ───────────────────────────────────────────── */
.distrito-badge {
  position: absolute;
  top: 72px;
  left: 12px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #5BB8F5;
  color: #FFFFFF;
  border: 3px solid #3BA5E8;
  border-radius: 24px;
  padding: 8px 14px 8px 16px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.2px;
  box-shadow: 0 6px 22px rgba(91, 184, 245, 0.55), 0 2px 8px rgba(45, 27, 0, 0.18);
}

.distrito-clear {
  background: rgba(255,255,255,0.28);
  border: none;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 900;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}

.distrito-clear:hover { background: rgba(255,255,255,0.45); }

/* ─── Tooltip de distrito en el mapa ─────────────────────────────────────── */
.distrito-tooltip {
  background: rgba(255,255,255,0.92) !important;
  border: 2px solid #5BB8F5 !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  font-family: 'Nunito', sans-serif !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  padding: 3px 9px !important;
  box-shadow: 0 3px 10px rgba(45, 27, 0, 0.12) !important;
  white-space: nowrap !important;
}

.distrito-tooltip::before { display: none !important; }

/* ─── Inputs de fecha (filtro Rango) ─────────────────────────────────────── */
.fecha-rango {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.fecha-input {
  height: 27px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 2px 8px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  min-width: 120px;
  transition: border-color 0.15s;
}

.fecha-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 184, 245, 0.15);
}

.fecha-sep {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .panel            { display: none; }
  .leyenda          { display: none; }
  .search-container { width: calc(100vw - 24px); }
}
