/* ===== GYMAPA FRONTEND ===== */
:root {
  --gymapa-primary:      #0A2D82;
  --gymapa-primary-dark: #052775;
  --gymapa-primary-mid:  #1746A2;
  --gymapa-accent:       #F2C94C;
  --gymapa-white:        #FFFFFF;
  --gymapa-text:         #172033;
  --gymapa-panel-w:      390px;
  --gymapa-panel-proj-w: 580px;
  --gymapa-radius:       20px;
  --gymapa-shadow:       0 8px 40px rgba(10,45,130,.22);
}

/* ── Section wrapper ── */
#gymapa-section {
  width: 100%;
  display: block;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gymapa-text);
}

/* ── Top bar ── */
.gymapa-topbar {
  background: #052775;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 36px;
  position: relative;
  z-index: 10;
}
.gymapa-topbar-label {
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 5px;
  text-transform: uppercase;
  font-weight: 600;
  font-family: Montserrat, 'Segoe UI', Arial, sans-serif;
}

/* ── Map wrap ── */
#gymapa-wrap {
  position: relative;
  width: 100%;
  height: 80vh;
  min-height: 600px;
  background:
    radial-gradient(ellipse 90% 80% at 42% 22%, rgba(255,255,255,0.88) 0%, rgba(255,255,255,0) 100%),
    linear-gradient(135deg, #f7fbff 0%, #edf5ff 48%, #eaf3ff 100%);
  overflow: hidden;
}

/* ── Decorative SVG — fixed, never moves ── */
#gymapa-deco-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ── Map zone: agrupa deco-svg, map-area y zoom-controls ── */
#gymapa-map-zone {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ── Map area: SVG + pins together, panels excluded ── */
#gymapa-map-area {
  position: absolute;
  inset: 0;
  transform: translateX(250px);
}

/* ── SVG map ── */
#gymapa-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Country paths — reference design ── */
.gymapa-country {
  fill: rgba(202, 220, 244, 0.45);
  stroke: #92b3e8;
  stroke-width: 0.82;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill .25s ease, stroke .25s ease;
}

/* Active countries (assigned via JS from data) */
.gymapa-active-country {
  fill: rgba(138, 175, 232, 0.55);
  stroke: #6a9fd8;
  cursor: pointer;
}
.gymapa-active-country:hover {
  fill: rgba(93, 144, 220, 0.70);
  stroke: #4a7fc0;
}
.gymapa-active-country.active {
  fill: rgba(23, 70, 162, 0.75);
  stroke: #0A2D82;
  stroke-width: 1.5;
}

/* ── Dynamic SVG pin (rendered inside #gymapa-svg, scales with zoom/pan) ── */
/* Styled via SVG presentation attributes in frontend.php; no additional CSS needed. */

/* ── Panels base ── */
.gymapa-panel {
  position: absolute;
  top: 50%;
  left: 40px;
  transform: translateY(-50%);
  border-radius: var(--gymapa-radius);
  box-shadow: var(--gymapa-shadow);
  z-index: 10;
  transition: opacity .3s ease, transform .3s ease;
}

/* ── Initial panel ── */
.gymapa-panel--initial {
  width: var(--gymapa-panel-w);
  background: var(--gymapa-primary-dark);
  padding: 0;
  overflow: hidden;
}
.gymapa-panel-initial-body {
  padding: 40px 38px 38px;
}
.gymapa-panel-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 52px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--gymapa-white);
  margin: 0 0 16px;
  letter-spacing: -.5px;
}
.gymapa-panel-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,.65);
  line-height: 1.6;
  margin: 0 0 22px;
}
.gymapa-country-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gymapa-country-list li {
  font-size: 13px;
  color: rgba(255,255,255,.82);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gymapa-country-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--gymapa-accent);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Projects panel ── */
.gymapa-panel--projects {
  width: var(--gymapa-panel-proj-w);
  background: var(--gymapa-white);
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-48%) translateX(-12px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.gymapa-panel--projects.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(-50%) translateX(0);
}

.gymapa-panel-header {
  background: var(--gymapa-primary);
  padding: 18px 24px;
  flex-shrink: 0;
  border-radius: var(--gymapa-radius) var(--gymapa-radius) 0 0;
}
.gymapa-panel-country-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gymapa-white);
  letter-spacing: .3px;
}

.gymapa-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.35);
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(10,45,130,.18);
  transition: background .2s, border-color .2s;
  padding: 0;
}
.gymapa-close-btn:hover {
  background: rgba(255,255,255,0.95);
  color: var(--gymapa-primary);
  border-color: rgba(255,255,255,0.95);
}

/* ── Projects list ── */
.gymapa-projects-list {
  flex: 1;
  max-height: 430px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(5,39,117,0.35) transparent;
}
.gymapa-projects-list::-webkit-scrollbar { width: 6px; }
.gymapa-projects-list::-webkit-scrollbar-track { background: rgba(5,39,117,0.06); border-radius: 10px; }
.gymapa-projects-list::-webkit-scrollbar-thumb { background: rgba(5,39,117,0.35); border-radius: 10px; }
.gymapa-projects-list::-webkit-scrollbar-thumb:hover { background: rgba(5,39,117,0.55); }

.gymapa-project-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid #edf0f8;
  transition: background .15s;
}
.gymapa-project-item:last-child { border-bottom: none; }
.gymapa-project-item:hover { background: #f7f9ff; }

.gymapa-project-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gymapa-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gymapa-project-img {
  width: 88px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #dde6f7;
}
.gymapa-project-img-placeholder {
  width: 88px;
  height: 62px;
  border-radius: 8px;
  background: linear-gradient(135deg, #c8d8f0 0%, #a8b8d8 100%);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gymapa-project-img-placeholder svg { opacity: .45; }

.gymapa-project-body {
  flex: 1;
  min-width: 0;
}
.gymapa-project-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--gymapa-text);
  line-height: 1.35;
  margin: 0 0 4px;
}
.gymapa-project-desc {
  font-size: 12px;
  color: #7080a0;
  margin: 0 0 8px;
  line-height: 1.4;
}
.gymapa-project-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gymapa-primary);
  border: 1.5px solid var(--gymapa-primary);
  padding: 4px 12px;
  border-radius: 20px;
  text-decoration: none;
  transition: background .2s, color .2s;
  letter-spacing: .3px;
}
.gymapa-project-btn:hover {
  background: var(--gymapa-primary);
  color: #fff;
}

/* ── Zoom controls ── */
#gymapa-zoom-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255,255,255,0.96);
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(10,45,130,.18);
  padding: 5px;
}
#gymapa-zoom-controls button {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  color: #0A2D82;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}
#gymapa-zoom-controls button svg {
  width: 16px;
  height: 16px;
}
#gymapa-zoom-controls button:hover:not(:disabled) {
  background: #edf3ff;
}
#gymapa-zoom-controls button:disabled {
  color: #c0cce0;
  cursor: default;
}

/* ── Perú dividido por regiones/departamentos ── */
.gymapa-peru-base {
  fill: rgba(138, 175, 232, 0.08);
  stroke: none;
  pointer-events: none;
}
.gymapa-peru-regions {
  pointer-events: auto;
}
.gymapa-peru-region {
  fill: rgba(138, 175, 232, 0.22);
  stroke: #92b3e8;
  stroke-width: 0.82;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.25s ease, stroke 0.25s ease, stroke-width 0.25s ease;
}
.gymapa-peru-region:hover {
  fill: rgba(65, 137, 219, 0.42);
  stroke: #6a9fd8;
  stroke-width: 0.82;
}
.gymapa-peru-outline {
  fill: none;
  stroke: #92b3e8;
  stroke-width: 0.82;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
#gymapa-peru.active .gymapa-peru-region,
#gymapa-peru.gymapa-active-country .gymapa-peru-region {
  fill: rgba(138, 175, 232, 0.28);
  stroke: #4f8bd8;
}
.gymapa-peru-region-selected {
  fill: rgba(23, 70, 162, 0.70) !important;
  stroke: #0A2D82 !important;
  stroke-width: 2 !important;
}

/* ── Empty state for regions without projects ── */
.gymapa-no-projects {
  padding: 28px 22px;
  font-size: 13px;
  color: #7080a0;
  text-align: center;
  line-height: 1.5;
}

/* ── Panel enter/exit animation ── */
.gymapa-panel--initial.hide {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-16px);
  transition: opacity .25s ease, transform .25s ease;
}

/* ── Responsive: tablet ── */
@media (max-width: 900px) {
  :root {
    --gymapa-panel-w:      320px;
    --gymapa-panel-proj-w: 320px;
  }
  .gymapa-panel-title { font-size: 38px; }
  .gymapa-panel { left: 16px; }
  #gymapa-wrap { height: 70vh; min-height: 500px; }
}

/* ── Responsive: mobile — mapa arriba, panel inicial abajo ── */
@media (max-width: 767px) {
  #gymapa-section {
    overflow: visible;
  }

  /* El wrap se convierte en columna flex */
  #gymapa-wrap {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  /* La zona del mapa ocupa 430px fijos y clipea su contenido */
  #gymapa-map-zone {
    position: relative !important;
    height: 430px !important;
    min-height: 430px !important;
    overflow: hidden !important;
    flex-shrink: 0;
    order: 1;
    z-index: 1;
  }

  /* El panel inicial pasa a flujo normal debajo del mapa */
  #gymapa-panel-initial {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    order: 2;
    width: calc(100% - 32px) !important;
    max-width: none !important;
    margin: 20px 16px 28px !important;
    z-index: 5 !important;
  }

  /* Ocultar con display:none para evitar que ocupe espacio al desaparecer */
  #gymapa-panel-initial.hide {
    display: none !important;
    transform: none !important;
  }

  /* Título más pequeño en mobile */
  .gymapa-panel-title {
    font-size: 36px !important;
    line-height: 1.1 !important;
  }

  /* El panel de proyectos superpone el mapa (position: absolute vs #gymapa-wrap) */
  #gymapa-panel-projects {
    top: 10px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-height: calc(430px - 20px) !important;
    transform: translateY(-6px) translateX(-6px) !important;
    z-index: 20 !important;
  }
  #gymapa-panel-projects.open {
    transform: none !important;
  }

  /* Controles de zoom (dentro de map-zone, position: absolute vs map-zone) */
  #gymapa-zoom-controls {
    bottom: 16px !important;
    right: 16px !important;
    z-index: 20 !important;
  }

  /* Topbar */
  .gymapa-topbar { padding: 0 16px; height: 48px; }
  .gymapa-topbar-label { font-size: 10px; letter-spacing: 3px; }
}

/* ── Peru department hover — must be last to beat #gymapa-peru.active specificity ── */
.gymapa-peru-regions,
.gymapa-peru-region {
  pointer-events: auto;
}
.gymapa-peru-region {
  cursor: pointer;
  transition: fill 0.22s ease, stroke 0.22s ease, stroke-width 0.22s ease, filter 0.22s ease;
}
.gymapa-peru-region:hover {
  fill: rgba(5, 39, 117, 0.58) !important;
  stroke: #4a7fc0 !important;
  stroke-width: 0.82 !important;
  filter: drop-shadow(0 4px 8px rgba(5, 39, 117, 0.22));
}
.gymapa-peru-region.gymapa-peru-region-selected {
  fill: rgba(5, 39, 117, 0.78) !important;
  stroke: #052775 !important;
  stroke-width: 2 !important;
}
.gymapa-peru-region.gymapa-peru-region-selected:hover {
  fill: rgba(5, 39, 117, 0.78) !important;
  stroke: #052775 !important;
  stroke-width: 2 !important;
  filter: none;
}

/* ── Active / disabled location states ── */
.gymapa-country.gymapa-location-disabled,
.gymapa-peru-region.gymapa-location-disabled {
  cursor: default !important;
}
.gymapa-country.gymapa-location-disabled:hover {
  fill: rgba(202, 220, 244, 0.45) !important;
  stroke: #92b3e8 !important;
  filter: none !important;
}
.gymapa-peru-region.gymapa-location-disabled:hover {
  fill: rgba(138, 175, 232, 0.22) !important;
  stroke: #92b3e8 !important;
  stroke-width: 0.82 !important;
  filter: none !important;
}
.gymapa-country.gymapa-location-active {
  cursor: pointer;
}
.gymapa-peru-region.gymapa-location-active {
  fill: rgba(138, 175, 232, 0.55) !important;
  stroke: #6a9fd8 !important;
  cursor: pointer;
}
.gymapa-peru-region.gymapa-location-active:hover {
  fill: rgba(93, 144, 220, 0.70) !important;
  stroke: #4a7fc0 !important;
}

/* ── Centrar visualmente la X del botón cerrar ── */
#gymapa-close.gymapa-close-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  line-height: 1 !important;
  font-size: 0 !important;
}
#gymapa-close.gymapa-close-btn::before {
  content: "×";
  display: block;
  font-size: 22px;
  line-height: 1;
  font-family: Arial, sans-serif;
  font-weight: 300;
  transform: translateY(-1px);
}
