/* =========================================================
   ===== BASE CARTOGRÁFICA ESTABLE ===== 
   PMTiles + Proxy PHP + Perfil Ciudadano validado
   ========================================================= */

/* =========================================================
   MAPA-OBRAS.CSS - ESTRUCTURA BASE (NÚCLEO)
   ========================================================= */

html,body{ margin:0; height:100% !important; width:100% !important; overflow:hidden !important; font-family: 'Arial Black Web', "Arial Black", Arial, sans-serif !important; color:#111; background-color: #ffc300; }

/* Fondo con fade */
.app-bg{
  position:fixed; inset:0;
  background-color: #ffc300;
  z-index:0; opacity:1;
}

/* Contenedor mapa con fade (oculto pero con tamaño) */
#map{
  position:fixed !important; inset:0 !important; z-index:1 !important; width:100% !important; height:100vh !important; background:transparent;
  opacity:1; visibility:visible; pointer-events:auto;
  transition:opacity 800ms ease;
}

/* Refuerzo para que el mapa reciba siempre el ratón y el scroll */
#map,
#map .maplibregl-canvas,
#map .maplibregl-canvas-container,
#map .maplibregl-control-container {
  pointer-events: auto !important;
}

/* --- NUEVO: Contenedor del Video Intro --- */
#video-intro-container {
  position: fixed;
  inset: 0;
  z-index: 10 !important; /* Lo subimos un poco más para asegurar prioridad */
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #000 !important;
  opacity: 1;
  visibility: visible;
  transition: opacity 1.5s ease-in-out;
  pointer-events: none;
}

#video-intro-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.1); /* 10% más grande para tener margen de movimiento */
  will-change: transform;
}

/* --- ANIMACIÓN INTRO Y TARJETAS DE CANTIDADES --- */
.dashboard-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.intro-titles {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  text-align: center;
  width: 100%;
}
.intro-text {
  position: absolute;
  width: 100%;
  font-family: 'Arial Black Web', "Arial Black", Arial, sans-serif;
  font-size: clamp(2rem, 5vw, 4.5rem);
  color: #ffc300;
  text-transform: uppercase;
  text-shadow: 0 10px 30px rgba(0,0,0,0.8);
  opacity: 0;
  transform: translateY(20px);
  margin: 0;
}

.dashboard-cards {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}
.dash-card {
  background: rgba(20, 20, 20, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 195, 0, 0.3);
  border-radius: 16px;
  padding: 20px 30px;
  text-align: center;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.dash-card h3 {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 10px 0;
  opacity: 0.8;
}
.dash-val {
  font-family: 'Arial Black Web', "Arial Black", Arial, sans-serif;
  font-size: 2.5rem;
  color: #ffc300;
  line-height: 1;
}
@media (max-width: 768px) {
  .dashboard-cards { gap: 10px; margin-top: 10vh; }
  .dash-card { min-width: 140px; padding: 15px; }
  .dash-val { font-size: 1.8rem; }
}

/* --- FOOTER INICIO --- */
#home-footer {
    position: absolute;
    bottom: 15px; /* Bien pegado abajo */
    left: 50%;
    transform: translateX(-50%);
    z-index: 16;
    color: rgba(255, 255, 255, 0.5); /* Color sutil para no distraer */
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 2s ease;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#home-footer.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Chips */
.chips{
  position:fixed !important; top:20px !important; left:0 !important; right:0 !important; z-index:10000 !important;
  display:flex; justify-content: center;
  pointer-events: none; /* Deja pasar clics al mapa excepto en los botones */
  /* Empiezan ocultos para que el video sea el protagonista */
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease, visibility 1s ease;
}
.chips-group{
  display:flex; align-items: center; gap:6px; padding:6px 12px;
  background-color: rgba(255, 195, 0, 0.5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 50px; border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-width: 95vw; pointer-events: auto;
  overflow: visible !important;
}


@media (max-width: 1024px) {
  .chips-group { overflow-x: auto !important; } /* En móvil mantenemos scroll si es necesario */
}
.chip{
  display:inline-flex; align-items:center; justify-content:center;
  padding:6px 14px; background: transparent;
  border: none; border-radius: 999px; font-size: 11px; font-weight: 900; color: #801039; cursor: pointer;
  font-family: 'Arial Black Web', "Arial Black", Arial, sans-serif !important;
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  white-space: nowrap;
}
.chip:hover{ color: #fff; transform: translateY(-2px); }
.chip.is-active{ background: #801039; color: #ffc300; }
.chip.is-active span{ color: #ffc300; }
.chip-more,
.mobile-category-panel{
  display: none;
}

.divider-v { width: 1px; height: 18px; background: rgba(128, 16, 57, 0.2); margin: 0 4px; flex-shrink: 0; }

/* ===== Píldora de búsqueda (entre "Inicio" y el grupo de chips) ===== */
.search-pill{
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50px; padding: 4px 12px;
  width: 180px; transition: width 0.3s ease;
}
.search-pill:focus-within { width: 240px; background: rgba(255, 255, 255, 0.45); }
.search-pill input{
  border:0; outline:0; background:transparent;
  font: 900 12px/1 'Arial Black Web', "Arial Black", Arial, sans-serif;
  color: #801039;
  width:100%;
}
.search-pill input::placeholder { color: rgba(128, 16, 57, 0.6); }
.search-pill svg{ width:20px; height:20px; color:#801039; pointer-events:none; }

/* Lista de resultados */
.search-list{
  position:absolute; left:0; right:0; top:100%; margin-top:6px;
  background: #801039; border: 1px solid #ffc300; border-radius: 15px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  list-style:none; padding:6px; max-height:52vh; overflow:auto;
  z-index: 1000;
}
.search-list li{
  padding:10px 12px; border-radius:10px; cursor:pointer;
  font: 900 13px/1.25 'Arial Black Web', "Arial Black", Arial, sans-serif; color:#fff;
  text-transform: uppercase;
}
.search-list li small{ display:block; color: #ffc300; opacity:.9; font-weight:bold; }
.search-list li:hover{ background: rgba(255, 195, 0, 0.2); }

  /* Estilos para la etiqueta de segmento en los resultados de búsqueda */
  .search-list li span.seg-tag {
    font-size: 9px;
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255,195,0,0.3);
    color: #ffc300;
    font-family: 'Arial Black Web', "Arial Black", sans-serif;
  }

/* En móviles, que no rompa la barra de chips */
@media (max-width:1024px){
  html,
  body{
    max-width: 100vw !important;
    max-width: 100dvw !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }

  html:has(body.segmento-alcalde_provincial),
  body.segmento-alcalde_provincial{
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none;
  }

  body.segmento-alcalde_provincial #red-vial-map-container,
  body.segmento-alcalde_provincial #red-vial-map-container .maplibregl-map,
  body.segmento-alcalde_provincial #red-vial-map-container .maplibregl-canvas-container,
  body.segmento-alcalde_provincial #red-vial-map-container .maplibregl-canvas {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
  }

  body.segmento-alcalde_provincial .app-bg {
    opacity: 0 !important;
    visibility: hidden !important;
  }

  body.segmento-alcalde_provincial #red-vial-map-container {
    z-index: 50 !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: #e9e5dc !important;
  }

  .app-bg,
  #map,
  #video-intro-container{
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
  }

  .chips{
    top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
    left: 50vw !important;
    left: 50dvw !important;
    right: 0 !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    width: calc(100vw - 48px) !important;
    width: calc(100dvw - 48px) !important;
    max-width: calc(100vw - 48px) !important;
    max-width: calc(100dvw - 48px) !important;
    overflow: visible !important;
    transform: translateX(-50%) !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    touch-action: none !important;
  }

  .chips-group{
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    justify-content: stretch !important;
    gap: 8px !important;
    padding: 0 !important;
    min-height: 0;
    border-radius: 0 !important;
    display: grid !important;
    grid-template-columns: 82px minmax(148px, 1fr) !important;
    grid-template-rows: 40px 40px !important;
    align-items: center;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    touch-action: pan-y !important;
  }

  .chip{
    min-height: 40px;
    width: auto !important;
    min-width: 0 !important;
    padding: 6px 10px !important;
    font-size: clamp(9px, 2.5vw, 12px) !important;
    letter-spacing: 0 !important;
    border: 2px solid rgba(255,255,255,0.9) !important;
    touch-action: manipulation !important;
  }

  .chips-group > .chip[data-map="base"]{
    grid-column: 1;
    grid-row: 2;
    gap: 6px;
    background: #801039 !important;
    color: #fff4bd !important;
    border-radius: 999px !important;
    box-shadow: 0 9px 18px rgba(61,20,22,0.25);
  }

  .chips-group > .chip[data-map="base"] span{
    color: #fff4bd !important;
  }

  .chips-group > .chip[data-map="base"]::before{
    content: "";
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 11.5 12 4l9 7.5-1.45 1.75L18 11.95V20h-5v-5h-2v5H6v-8.05l-1.55 1.3L3 11.5Z'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 11.5 12 4l9 7.5-1.45 1.75L18 11.95V20h-5v-5h-2v5H6v-8.05l-1.55 1.3L3 11.5Z'/%3E%3C/svg%3E") center/contain no-repeat;
  }

  .divider-v{
    display: none !important;
  }

  .chips-group > .chip[data-map]:not([data-map="base"]){
    display: none !important;
  }

  .chip-more{
    display: inline-flex !important;
    grid-column: 2;
    grid-row: 2;
    justify-content: center;
    pointer-events: auto !important;
    gap: 7px;
    background: linear-gradient(180deg, rgba(245,211,113,0.94), rgba(220,173,61,0.96));
    color: #801039;
    overflow: hidden;
    border-radius: 999px !important;
    box-shadow: 0 9px 18px rgba(61,20,22,0.18), inset 0 1px 0 rgba(255,255,255,0.3);
  }

  .chip-more span{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chip-more::after{
    content: "";
    width: 7px;
    height: 7px;
    margin-left: 2px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .22s ease;
  }

  .chip-more[aria-expanded="true"]::after{
    transform: rotate(225deg) translate(-1px, -1px);
  }

  .search-pill{
    flex: 1 1 auto !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
    height: 40px;
    padding: 0 14px !important;
    justify-content: flex-start;
    grid-column: 1 / -1;
    grid-row: 1;
    border-radius: 999px;
    background: rgba(255,255,255,0.94);
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 10px 20px rgba(61,20,22,0.18), inset 0 1px 0 rgba(255,255,255,0.4);
    touch-action: manipulation !important;
  }

  .search-pill svg{
    width: 21px;
    height: 21px;
  }

  .search-pill input{
    width: 100% !important;
    min-width: 0 !important;
    opacity: 1;
    pointer-events: auto;
    font-size: 11px;
  }

  .search-pill:focus-within{
    position: relative !important;
    left: auto !important;
    right: auto;
    top: auto !important;
    transform: none !important;
    z-index: auto;
    flex-basis: auto !important;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
    height: 40px;
    justify-content: flex-start;
    padding: 0 14px !important;
    background: rgba(255,255,255,0.94);
  }

  .search-pill:focus-within input{
    width: 100% !important;
    opacity: 1;
    pointer-events: auto;
  }

  .search-list{
    position: fixed;
    left: calc(var(--mobile-vv-left, 0px) + 18px);
    right: auto;
    width: calc(var(--mobile-vv-width, 100vw) - 36px);
    top: calc(env(safe-area-inset-top, 0px) + 56px);
  }

  .mobile-category-panel{
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 104px);
    left: var(--mobile-vv-center, 50vw);
    right: auto;
    width: max-content;
    min-width: 238px;
    max-width: min(318px, calc(100vw - 44px));
    max-width: min(318px, calc(100dvw - 44px));
    max-height: min(66vh, 390px);
    overflow-y: auto;
    pointer-events: auto !important;
    transform: translateX(-50%);
    z-index: 2147483001 !important;
    display: grid;
    opacity: 1;
    visibility: visible;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,250,235,0.98), rgba(248,231,178,0.98));
    border: 2px solid rgba(255,255,255,0.88);
    box-shadow: 0 14px 26px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.6);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .mobile-category-panel::before{
    content: "";
    position: absolute;
    top: -12px;
    left: 70%;
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-bottom: 12px solid rgba(255,250,235,0.98);
  }

  .mobile-category-panel[hidden]{
    display: none !important;
  }

  .mobile-category-panel.is-open{
    display: grid !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .mobile-category-option{
    min-height: 44px;
    border: 0;
    border-radius: 13px;
    background: rgba(255,255,255,0.82);
    color: #801039;
    font: 900 clamp(10px, 2.45vw, 13px)/1.08 'Arial Black Web', "Arial Black", Arial, sans-serif;
    text-transform: uppercase;
    padding: 7px 9px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(61,20,22,0.08), inset 0 0 0 1px rgba(128,16,57,0.04);
    display: grid;
    grid-template-columns: 28px max-content 10px;
    align-items: center;
    gap: 9px;
    text-align: left;
  }

  .mobile-category-option:active,
  .mobile-category-option.is-active{
    background: #801039;
    color: #ffc300;
  }

  .mobile-category-option__icon{
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #801039;
    background: linear-gradient(180deg, #e9bd3b, #d59a11);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
  }

  .mobile-category-option__icon svg{
    width: 16px;
    height: 16px;
  }

  .mobile-category-option__label{
    min-width: 0;
    max-width: 198px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-category-option__chevron{
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    justify-self: end;
  }
}

/* Crossfade de capas de imagen */
.leaflet-image-layer{ transition:opacity 500ms ease; }

/* HUD de zoom (opcional) */
#zoomHud{
  display: none !important; /* Oculto permanentemente */
}

/* === Leyenda de estados === */
#legend {
  position: fixed;
  left: calc(var(--sidebar-collapsed, 60px) + 12px);
  bottom: 25px; /* Esquinado en la parte inferior */
  z-index: 2000; /* Lo subimos para que flote sobre el mapa y los paneles laterales */
  background-color: rgba(128, 16, 57, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 195, 0, 0.3);
  color: #ffc300;
  padding: 8px 10px;
  border-radius: 8px;
  font: 600 12px/1.4 system-ui, Segoe UI, Roboto, Arial;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
#legend .item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
#legend .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #fff; }
#legend .label { opacity: .9; }

body.segmento-alcalde_provincial #filtersDock,
body.segmento-alcalde_provincial #legend {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce){
  *{ animation:none!important; transition:none!important }
}



/* ===== Solo móvil: subir zoom y bajar la leyenda ===== */
@media (max-width: 600px) {
  :root{
    --zoom-btn: 38px;
    --zoom-gap: 10px;
    --zoom-offset: 50px;
  }

  .leaflet-bottom.leaflet-right{
    padding-right: 8px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  .leaflet-bottom.leaflet-right .leaflet-control-zoom{
    transform: scale(0.92);
    transform-origin: bottom right;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    margin-bottom: var(--zoom-offset);
  }
  .leaflet-control-zoom a{
    width: var(--zoom-btn);
    height: var(--zoom-btn);
    line-height: var(--zoom-btn);
  }

  #legend{
    right: auto;
    left: calc(var(--sidebar-collapsed, 60px) + 8px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    padding: 6px 8px;
    border-radius: 10px;
    font: 700 11px/1.3 system-ui, Segoe UI, Roboto, Arial;
    background: rgba(0,0,0,.46);
    box-shadow: 0 2px 8px rgba(0,0,0,.28);
  }
  #legend .item{ display:flex; align-items:center; gap:6px; margin-bottom:3px; }
  #legend .item:last-child{ margin-bottom:0; }
  #legend .dot{ width:10px; height:10px; }
  #legend .label{ opacity:.95; }

  #zoomHud{
    left: 8px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--zoom-offset) + 6px);
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 11px;
  }
}  /* ← este es el ÚNICO cierre del bloque móvil */




.pill{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 9px; border-radius:999px; font-weight:800;
  border:1px solid rgba(0,0,0,.06);
}
.pill svg{ width:14px; height:14px }

.pill--entregado{ background:#e8f5e9; color:#1b5e20; }
.pill--construccion{ background:#e8f0fe; color:#1a73e8; }
.pill--paralizado{ background:#ffebee; color:#c62828; }
.pill--suspendido{ background:#ffebee; color:#d32f2f; }
.pill--estudios{ background:#eeeeee; color:#424242; }
.pill--buenapro{      background:#fff3e0; color:#ef6c00; }  /* naranja suave */
.pill--transferencia{ background:#f3e8ff; color:#6d28d9; }  /* morado suave */
.pill--oculto{        background:#475569; color:#f8fafc; }  /* gris oscuro */



/* === Reset sólido de panes: overlay < controles < pines < tooltips < popups === */
.leaflet-tile-pane     { z-index: 100 !important; }
.leaflet-overlay-pane  { z-index: 200 !important; }  /* imageOverlay */
.leaflet-shadow-pane   { z-index: 300 !important; }
.leaflet-marker-pane   { z-index: 1200 !important; } /* PINS arriba */
.leaflet-tooltip-pane  { z-index: 1300 !important; pointer-events: none !important; }
.leaflet-popup-pane    { z-index: 1400 !important; }

/* Controles por debajo de pines, por encima del overlay */
.leaflet-control-container,
.leaflet-top,
.leaflet-bottom {
  z-index: 900 !important;
  pointer-events: none !important;
}
.leaflet-control {
  pointer-events: auto !important;
}

/* Rehabilita interacción en markers (tu CSS base los pone en none) */
.leaflet-marker-icon { pointer-events: auto !important; }

/* Por si algún reset global toca opacidad/filtros de los pines */
.leaflet-marker-pane .leaflet-marker-icon { opacity: 1 !important; filter: none !important; }

/* (Opcional) Asegura que la imagen de fondo no cree un stacking raro */
.leaflet-image-layer { z-index: 0 !important; pointer-events: none !important; } /* relativo a su pane (overlay:200) */

/* Solo móvil: ocultar el HUD de zoom */
@media (max-width: 600px){
  #zoomHud { display: none !important; }
}


/* Asegurar visibilidad y tamaño de los divIcon */
.leaflet-marker-pane .leaflet-marker-icon.obra-pin { 
  opacity: 1 !important; 
  filter: none !important; 
  display: block !important;
}

/* Evitar que las etiquetas de texto funcionen como escudos y bloqueen el hover de los pines */
.leaflet-marker-pane .leaflet-marker-icon.obra-label {
  pointer-events: none !important;
}
.obra-label__inner {
  pointer-events: none !important;
}
.obra-label__inner * {
  pointer-events: none !important;
}

/* FIX: Destruir el "muro invisible" del menú superior para que deje pasar el scroll hacia el mapa */
#hero-header {
  pointer-events: none !important;
}
#hero-header .logo-container, #hero-header ul, #hero-header .button-container {
  pointer-events: auto !important;
}

/* Eliminamos las reglas restrictivas que bloqueaban la apertura */
#sheet:not(.is-open),
#sheetBackdrop:not(.is-open) {
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Ocultamiento ultrarrápido por GPU durante el zoom */
#map.labels-suspended .obra-label__inner {
  display: none !important;
}

/* FIX LEAFLET EXTREMO: Desactivar animaciones nativas de los tooltips (Tarjetas Fantasma).
   Al hacerlos instantáneos (0ms), Leaflet nunca pierde la cuenta de qué tarjeta está abriendo 
   o cerrando, eliminando por completo la corrupción de memoria al hacer scrolls súper rápidos. */
.leaflet-tooltip, .ghost-card-tip {
  transition: none !important;
  animation: none !important;
  pointer-events: none !important;
}

/* Asegurar que el contenedor de tooltips NUNCA funcione como un muro invisible que bloquee
   los clics hacia los pines que están detrás o muy pegados a él. */
.leaflet-tooltip-pane {
  pointer-events: none !important;
}

/* Prevenir que el Chat de IA capture scrolls cuando está cerrado */
#ft-chat-container.ft-chat-closed {
  pointer-events: none !important;
}
#ft-chat-container.ft-chat-closed #ft-chat-fab {
  pointer-events: auto !important;
}
#ft-chat-container.ft-chat-open {
  pointer-events: auto !important;
}

/* =========================================================================
   FASE 3: ADAPTACIÓN DE TARJETAS FANTASMA A MAPLIBRE
   ========================================================================= */

/* FIX DEFINITIVO DE ZOOM: Evita que la caja invisible atrape la rueda del ratón */
.ghost-card-popup {
  pointer-events: none !important;
}

.ghost-card-popup .maplibregl-popup-content {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  pointer-events: none !important;
}
.ghost-card-popup .maplibregl-popup-tip {
  display: none !important;
}

/* =========================================================================
   ESTILOS DEL MAPA SVG VECTORIAL (FASE 3 PREVIEW)
   ========================================================================= */
#synced-svg-container {
    transition: opacity 0.8s ease;
}
#synced-svg-container svg path {
    fill: #FFFFF0 !important; /* Color Marfil unificado para todos los mapas */
    stroke: #801039 !important; /* Borde Granate institucional */
    stroke-width: 3.5px !important; /* Borde más grueso por defecto */
    transition: filter 0.3s ease, stroke-width 0.3s ease, fill 0.3s ease, stroke 0.3s ease;
    /* NUEVO: Efecto Dibujo de Autocad (Holograma) */
    stroke-dasharray: 200 30 !important;
    animation: hologram-draw 6s linear infinite !important;
    will-change: stroke-dashoffset;
}

@keyframes hologram-draw {
    from { stroke-dashoffset: 230; } /* La suma exacta de 200 + 30 para un loop perfecto invisible */
    to { stroke-dashoffset: 0; }
}

/* Efecto de Iluminación (Hover Interactividad) - FASE 3 */
#synced-svg-container svg path.is-hovered {
    fill: #ffffff !important; /* Se vuelve blanco puro para "iluminarse" */
    stroke: #ffc300 !important; /* El borde cambia al color dorado */
    stroke-width: 5px !important; /* Borde ligeramente más grueso */
    filter: drop-shadow(0 0 12px rgba(255, 195, 0, 0.8)); /* Resplandor (Glow) dorado de la provincia */
}

/* =========================================================================
   HINT ONBOARDING MAPA (NUEVO)
   ========================================================================= */
.map-onboarding-hint {
  position: fixed;
  top: 55%;
  right: 15%;
  transform: translateY(-50%) rotate(-10deg) scale(0.5);
  z-index: 8000; 
  pointer-events: none;
  font-family: 'Segoe Print', 'Bradley Hand', 'Chalkboard SE', 'Comic Sans MS', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  color: #111;
  text-align: center;
  text-shadow: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.map-onboarding-hint.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) rotate(-5deg) scale(1);
  animation: map-hint-float 2s ease-in-out infinite alternate;
}
.map-onboarding-hint.is-hiding {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20%) rotate(15deg) scale(0.4);
  transition: all 0.6s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}
.map-onboarding-hint .icon-mouse {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 2px;
  animation: mouse-scroll-hint 1.5s infinite;
}
@keyframes map-hint-float {
  from { transform: translateY(-50%) rotate(-5deg) scale(1); }
  to { transform: translateY(-45%) rotate(-2deg) scale(1.05); }
}
@keyframes mouse-scroll-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}
@media (max-width: 900px) {
  .map-onboarding-hint {
    top: 75%;
    right: 50%;
    transform: translate(50%, -50%) rotate(-5deg) scale(0.5);
    font-size: 0.75rem;
    width: 100%;
  }
  .map-onboarding-hint.is-visible {
    transform: translate(50%, -50%) rotate(-2deg) scale(1);
  }
  .map-onboarding-hint.is-hiding {
    transform: translate(50%, -20%) rotate(15deg) scale(0.4);
  }
  @keyframes map-hint-float {
    from { transform: translate(50%, -50%) rotate(-2deg) scale(1); }
    to { transform: translate(50%, -45%) rotate(0deg) scale(1.05); }
  }
  .map-onboarding-hint .icon-mouse {
    font-size: 1.1rem;
  }
}

/* =========================================================
   RED VIAL STUDIO - PANEL DE CONTROL
   ========================================================= */
.rv-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  right: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  width: 240px;
  font-family: system-ui, -apple-system, sans-serif;
  border: 1px solid rgba(128, 16, 57, 0.2);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.rv-panel.is-collapsed {
  width: 190px;
}
.rv-panel.is-collapsed .rv-panel-body {
  display: none;
}
.rv-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fdf5f7;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(128, 16, 57, 0.05);
}
.rv-panel-title {
  margin: 0;
  font-size: 13px;
  color: #801039;
  font-weight: 900;
  text-transform: uppercase;
  font-family: 'Arial Black Web', "Arial Black", sans-serif;
}
.rv-panel-toggle {
  background: none;
  border: none;
  color: #801039;
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.3s;
}
.rv-panel.is-collapsed .rv-panel-toggle {
  transform: rotate(180deg);
}
.rv-panel-body {
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.rv-panel-body::-webkit-scrollbar {
  width: 4px;
}
.rv-panel-body::-webkit-scrollbar-thumb {
  background: rgba(128, 16, 57, 0.3);
  border-radius: 4px;
}
.rv-panel-group {
  margin-bottom: 16px;
}
.rv-panel-group:last-child {
  margin-bottom: 0;
}
.rv-panel-group-title {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}
.rv-panel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #334155;
  margin-bottom: 8px;
  font-weight: 500;
}
.rv-panel-item:last-child {
  margin-bottom: 0;
}
.rv-panel-item input[type="checkbox"] {
  accent-color: #801039;
  cursor: pointer;
  margin: 0;
  width: 14px;
  height: 14px;
}

/* --- NUEVO: Selector de Perfiles y Opciones Avanzadas --- */
.rv-profiles {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 6px;
}
.rv-profile-btn {
  flex: 1;
  padding: 6px 2px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}
.rv-profile-btn:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.6);
  color: #1e293b;
  transform: translateY(-1px);
}
.rv-profile-btn.is-active {
  background: #fff;
  color: #801039;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.rv-advanced-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  padding: 10px 0 4px 0;
  border-top: 1px solid #e2e8f0;
  margin-top: 8px;
}
.rv-advanced-content {
  display: none;
  padding-top: 12px;
}
.rv-advanced-content.is-open {
  display: block;
}

body:not(.segmento-alcalde_provincial) #rv-studio-panel,
body:not(.segmento-alcalde_provincial) #rv-studio-fab {
  display: none !important;
}

@media (max-width: 1024px) {
  body.segmento-alcalde_provincial .rv-panel {
    position: fixed !important;
    top: auto !important;
    right: auto !important;
    bottom: 0 !important;
    left: 50dvw !important;
    width: calc(100dvw - 20px) !important;
    max-width: 520px !important;
    height: auto !important;
    max-height: min(58dvh, 520px) !important;
    box-sizing: border-box !important;
    border-radius: 22px 22px 0 0 !important;
    z-index: 2147483500 !important;
    overflow: hidden !important;
    border: 1px solid rgba(255,255,255,0.84) !important;
    border-bottom: 0 !important;
    background: rgba(255, 250, 245, 0.98) !important;
    box-shadow: 0 -18px 36px rgba(61, 20, 22, 0.22) !important;
    transform: translateX(-50%) translateY(0) !important;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease, visibility 0.18s ease !important;
  }

  body.segmento-alcalde_provincial .rv-panel.is-collapsed {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateX(-50%) translateY(calc(100% + 18px)) !important;
  }

  body.segmento-alcalde_provincial .rv-panel.is-mobile-open {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(-50%) translateY(0) !important;
    z-index: 2147483700 !important;
  }

  body.segmento-alcalde_provincial .rv-studio-fab {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + 294px) !important;
    left: 22px !important;
    right: auto !important;
    width: 56px !important;
    height: 56px !important;
    border: 1px solid rgba(255,255,255,0.9) !important;
    border-radius: 999px !important;
    background: rgba(255,255,255,0.96) !important;
    box-shadow: 0 13px 24px rgba(61,20,22,0.24) !important;
    z-index: 2147482700 !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    cursor: pointer !important;
  }

  body.segmento-alcalde_provincial .rv-studio-fab.is-open {
    background: #801039 !important;
    color: #ffc300 !important;
  }

  body.segmento-alcalde_provincial .rv-studio-fab svg {
    width: 28px !important;
    height: 28px !important;
    display: block !important;
  }

  body.segmento-alcalde_provincial .rv-panel-header {
    position: relative !important;
    padding: 18px 18px 10px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    background: rgba(255,255,255,0.72) !important;
    border-bottom: 1px solid rgba(128,16,57,0.10) !important;
  }

  body.segmento-alcalde_provincial .rv-panel-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(128,16,57,0.18);
    transform: translateX(-50%);
  }

  body.segmento-alcalde_provincial .rv-panel-title {
    font-size: 15px !important;
    letter-spacing: 0 !important;
  }

  body.segmento-alcalde_provincial .rv-panel-toggle {
    width: 32px !important;
    height: 32px !important;
    border-radius: 999px !important;
    background: rgba(128,16,57,0.08) !important;
    color: #801039 !important;
    font-size: 16px !important;
    display: grid !important;
    place-items: center !important;
    transform: rotate(180deg) !important;
  }

  body.segmento-alcalde_provincial .rv-panel-body {
    max-height: calc(min(58dvh, 520px) - 60px) !important;
    padding: 9px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.segmento-alcalde_provincial .rv-profiles {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 999px !important;
    padding: 4px !important;
    gap: 4px !important;
    margin-bottom: 8px !important;
    background: rgba(128,16,57,0.08) !important;
  }

  body.segmento-alcalde_provincial .rv-profile-btn {
    min-width: 0 !important;
    min-height: 32px !important;
    border-radius: 999px !important;
    font-size: 10px !important;
    color: #801039 !important;
  }

  body.segmento-alcalde_provincial .rv-profile-btn.is-active {
    background: #801039 !important;
    color: #ffc300 !important;
    box-shadow: 0 8px 18px rgba(128,16,57,0.20) !important;
  }

  body.segmento-alcalde_provincial .rv-advanced-header {
    display: none !important;
  }

  body.segmento-alcalde_provincial .rv-advanced-content {
    display: block !important;
    padding-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  body.segmento-alcalde_provincial .rv-panel-group {
    display: grid !important;
    grid-template-columns: minmax(0, calc((100% - 6px) / 2)) minmax(0, calc((100% - 6px) / 2)) !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin: 0 0 8px !important;
  }

  body.segmento-alcalde_provincial .rv-panel-group-title {
    grid-column: 1 / -1 !important;
    margin: 0 0 6px !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 10px !important;
    letter-spacing: 0.6px !important;
    color: #801039 !important;
  }

  body.segmento-alcalde_provincial .rv-panel-item {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    min-height: 34px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.86) !important;
    box-shadow: 0 5px 16px rgba(61,20,22,0.08) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    color: #334155 !important;
    gap: 6px !important;
    min-width: 0 !important;
    line-height: 1.05 !important;
    overflow: hidden !important;
  }

  body.segmento-alcalde_provincial .rv-panel-item > * {
    min-width: 0 !important;
  }

  body.segmento-alcalde_provincial .rv-panel-item input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    flex: 0 0 auto !important;
  }

  body.segmento-alcalde_provincial .rv-ref-list {
    grid-column: 1 / -1 !important;
    max-height: 84px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body.segmento-alcalde_provincial .rv-ref-list li {
    padding: 4px 0 !important;
    font-size: 10.5px !important;
  }
}
