:root {
  --bg:       #f7f8fc;   /* fondo general */
  --surface:  #ffffff;   /* tarjetas principales */
  --panel:    #f1f3f9;   /* paneles secundarios */

  --border:   rgba(0,0,0,0.06);
  --border2:  #E3E3E3;

  --primary: #07426D.     /* azul oscuro */
  --accent:   #07426D;   /* verde pastel */

  --danger:   #fda4af;   /* rojo suave */

  --text:     #1f2937;   /* gris oscuro (legible en claro) */
  --muted:    #444444;
  --muted2:   #9ca3af;

  --radius:   12px;
  --radius-lg: 18px;
  --font: 'Inter', sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Layout ── */
#app { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  height: 70svh; 
  min-height: 400px; 
  column-gap: 40px;
  position: relative;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

#sidebar>div{
  margin-bottom: 0 !important;
}

#sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--accent); }
  50%       { opacity: 0.5; box-shadow: 0 0 4px var(--accent); }
}

.logo-text {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted2);
}

#sidebar-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

#sidebar-header p {
  font-size: 13px;
  color: var(--muted);
  font-weight: 300;
}

/* ── Search ── */
#search-wrap {
  padding-bottom: 16px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  #search-wrap {
  padding: 16px 0;
}
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #000;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box:focus-within .search-icon { color: var(--accent); }

#search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 40px 12px 4px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
}

#search-input:focus {
  box-shadow: none !important;
}

#search-input::placeholder {
  color: var(--text) !important;
  opacity: 0.5
}

#clear-btn {
  position: absolute;
  right: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.search-icon {
  position: absolute;
  right: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

#clear-btn:hover { color: var(--text); background: var(--border); }
#clear-btn.visible { display: flex; }

#clear-btn.visible ~ .search-icon {
    display: none; 
}

/* ── Stats bar ── */
#stats-bar {
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#results-count { font-size: 12px; color: var(--muted); font-family: var(--font); }
#results-count span { color: var(--accent); font-weight: 500; }

.filter-chips { display: flex; gap: 6px; }

.chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
  white-space: nowrap;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: rgba(79,255,176,0.1); border-color: var(--accent); color: var(--accent); }

/* ── Results list ── */
#results-list {
  flex: 1;
	padding-right: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#results-list::-webkit-scrollbar { width: 4px; }
#results-list::-webkit-scrollbar-track { background: #F1F1F1; }
#results-list::-webkit-scrollbar-thumb { background: #0B52D9; border-radius: 4px; }

.result-item {
  padding: 14px 0;
  border-radius: 0;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom-color: var(--border2);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: block;
}

.result-item:hover {
  background: var(--panel);
  border-color: var(--border2);
  margin-top: 14px;
}

.result-item:hover::before { transform: scaleY(1); }

.result-item.active {
  background: rgba(7, 66, 109,0.06);
  border-color: none;
  padding-left: 12px;
  padding-right: 12px;
}

.result-item.active::before {
  background: var(--accent);
  transform: scaleY(1);
}

.result-item.inactive {
  opacity: 0.45;
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.item-city {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
}

.status-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  font-family: var(--font);
}

.status-badge.on {
  background: rgba(7, 66, 109,0.12);
  color: var(--accent);
  border: 1px solid rgba(7, 66, 109,0.2);
}

.status-badge.off {
  background: rgba(107,114,128,0.12);
  color: var(--muted);
  border: 1px solid rgba(107,114,128,0.2);
}

.item-address {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

.item-coords {
  display: flex;
  gap: 12px;
}

.coord {
  font-size: 11px;
  font-family: var(--font);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Empty state ── */
#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}

#empty-state svg { color: var(--muted); opacity: 0.4; }
#empty-state p { font-size: 14px; color: var(--muted); }
#empty-state small { font-size: 12px; color: var(--muted); opacity: 0.6; }

/* ── Map ── */
#map-container {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

#map { width: 100%; height: 100%; }

/* ── Map overlay (loading) ── */
#map-loader {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  transition: opacity 0.5s ease;
}

#map-loader.hidden { opacity: 0; pointer-events: none; }

.loader-ring {
  width: 40px; height: 40px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#map-loader p { font-size: 13px; color: var(--muted); }

/* ── Map top bar ── */
#map-topbar {
  position: absolute;
  top: 20px; left: 20px; right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

.map-badge {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font);
  pointer-events: auto;
}

.map-badge strong { color: var(--accent); }

/* ── Custom popup ── */
.custom-popup {
  display: flex;
  flex-direction: column;
  align-items:center;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  max-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(79,255,176,0.1);
  font-family: var(--font);
  position: relative;
}

.popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-family: var(--font);
  letter-spacing: 0.04em;
}

.popup-badge.on {
  background: rgba(79,255,176,0.12);
  color: var(--accent);
  border: 1px solid rgba(107,114,128,0.2);
}

.popup-badge.off {
  background: rgba(107,114,128,0.12);
  color: var(--muted2);
  border: 1px solid rgba(107,114,128,0.2);
}

.popup-city {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1.2;
  width: fit-content;
}

.popup-address {
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.5;
  width: fit-content;
}

.popup-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 14px;
}

.popup-coords {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-coord-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popup-coord-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font);
}

/* Google Maps overrides */
.gm-style .gm-style-iw-c {
  background: transparent !important;
  padding: 0 !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
}

.gm-style .gm-style-iw-d { overflow: hidden !important; }
.gm-style .gm-style-iw-t::after { display: none !important; }
.gm-style .gm-ui-hover-effect { display: none !important; }
.gm-style-iw-chr { display: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 60vh 400px; height: auto; }
  #map-container { order: -1; }
}

/* ── Highlight search match ── */
mark {
  background: rgba(7, 66, 109,0.2);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}

/* ── No API key warning ── */
#api-warning {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,79,106,0.15);
  border: 1px solid rgba(255,79,106,0.3);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  color: #ff8fa3;
  white-space: nowrap;
  z-index: 10;
  backdrop-filter: blur(10px);
}