/* =========================
   LAYOUT GENERAL
   ========================= */

body {
  margin: 0;
  background: #0b0b0b;
  color: #fff;
  font-family: Arial, sans-serif;
}

.map-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: auto;
  padding: 12px;
}

/* =========================
   HEADER
   ========================= */

.app-header {
  text-align: center;
  margin-bottom: 12px;
}

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

.logo {
  width: 36px;
  height: 36px;
}

.description {
  max-width: 620px;
  margin: 6px auto;
  color: #aaa;
  font-size: 14px;
}

/* =========================
   MAPA RESPONSIVE
   ========================= */

.map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 900 / 1000; /* ⬅️ IGUAL que el SVG */
  border: 2px solid #00ffff;
  overflow: hidden;
}


/* Imagen ciudad */
.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* SVG */
#grid-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* =========================
   CONTROLES CALLES
   ========================= */

.h-controls {
  display: grid;
  grid-template-columns: repeat(41, 1fr);
  width: 100%;
  margin-bottom: 6px;
}


.v-controls {
  display: grid;
  grid-template-rows: repeat(39, 1fr);
  margin-right: 6px;
}

/* hover sincronizado */
.h-controls button.hovered,
.v-controls button.hovered {
  background: rgba(0, 200, 255, 0.25);
  color: #00ffff;
}

/* active = seleccionado */
.h-controls button.active,
.v-controls button.active {
  background: #00eaff;
  color: #000;
}

/* líneas */
.line-h.hovered,
.line-v.hovered {
  stroke: rgba(0, 234, 255, 0.6);
  stroke-width: 3;
}

.line-h.active,
.line-v.active {
  stroke: #00eaff;
  stroke-width: 4;
  filter: drop-shadow(0 0 6px #00eaff);
}


/* Botones */
.h-controls button,
.v-controls button {
  width: 100%;
  aspect-ratio: 1 / 1;
  font-size: 10px;
  padding: 0;
  background: #111;
  color: #00ffff;
  border: 1px solid #00ffff;
}

/* =========================
   MAP ROW
   ========================= */

.map-row {
  display: flex;
  align-items: stretch;
}

/* =========================
   MANZANAS
   ========================= */

.block {
  fill: transparent;
  cursor: pointer;
  pointer-events: all;
}

.block:hover {
  fill: rgba(0, 180, 255, 0.15);
}

.block.active {
  fill: rgba(0, 180, 255, 0.35);
}

/* =========================
   CALLES
   ========================= */

.line-h,
.line-v {
  stroke: rgba(0, 200, 255, 0.25);
  stroke-width: 2;
}

.line-h.active,
.line-v.active {
  stroke: #00eaff;
  stroke-width: 4;
  filter: drop-shadow(0 0 6px #00eaff);
}

/* =========================
   MARKER + POPUP
   ========================= */
.marker {
  position: absolute;
  width: 28px;
  height: 28px;
  background: #ff1600;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  z-index: 3;
  cursor: pointer;
}

.marker::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  top: 8px;
  left: 8px;
}

.marker::before {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  background: rgba(255, 22, 0, 0.5);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.4);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
#toggleMarkers {
  background: #ff1600;
  color: #000;
  border: 2px solid #ff1600;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

#toggleMarkers.active {
  background: #111;
  color: #ff1600;
}


.popup {
  position: absolute;
  width: min(240px, 90vw);
  background: #111;
  border: 2px solid #ff1600;
  border-radius: 10px;
  padding: 10px;
  z-index: 4;
}

.popup img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
}

.popup.hidden {
  display: none;
}

/* =========================
   RESET
   ========================= */

.global-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255,255,255,0.9);
  padding: 10px;
  border-radius: 6px;
  z-index: 1000;
  width: max-content;
}

.search-group {
  display: flex;
  gap: 6px;
}

.buttons-group {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}


#searchInput {
  background: #111;
  color: #fff;
  border: 1px solid #00ffff;
  border-radius: 6px;
  padding: 6px 10px;
  width: 180px;
}

#searchBtn {
  background: #00ffff;
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

#searchBtn:hover {
  background: #00eaff;
}

/* =========================
   MOBILE AJUSTES
   ========================= */

@media (max-width: 768px) {
  .description {
    font-size: 13px;
  }

  .h-controls button,
  .v-controls button {
    font-size: 9px;
  }
}