/* ===========================================================
   MOD BUSCADOR — Versión FINAL ROBUSTA (QGIS2Web + OpenLayers)
   =========================================================== */

/* ===========================================================
   VARIABLES GLOBALES DE POSICIÓN
   =========================================================== */
:root {
  --buscador-top: 8px;
  --buscador-left: 8px;

  --badge-offset-y: -44px;     /* etiqueta dirección */
  --links-offset-y: -62px;     /* cajetín PIU/Catastro */

  --btn-gap: 2px;
}

/* ===========================================================
   BLINDAJE TOTAL ANTI-QGIS2WEB
   =========================================================== */
.gc-buscador-control {
  all: unset !important;
  position: absolute !important;
  top: var(--buscador-top) !important;
  left: var(--buscador-left) !important;
  display: flex !important;
  align-items: center !important;
  z-index: 2000 !important;

  pointer-events: auto !important;
  width: auto !important;
  height: auto !important;

  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
}


/* ===========================================================
   BOTÓN PRINCIPAL
   =========================================================== */
.gc-btn {
  width: 36px;
  height: 36px;
  background: #fff;
  border: 1px solid rgba(180,180,180,0.7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: all .25s ease;
}
.gc-btn img.gc-icon {
  width: 18px;
  height: 18px;
}

.gc-buscador-control.open .gc-btn {
  background: #005cbb !important;
  border-color: #004a99 !important;
}
.gc-buscador-control.open .gc-btn img {
  filter: brightness(0) invert(1);
}


/* ===========================================================
   PANEL DE CORTINILLA
   =========================================================== */
.gc-panel {
  position: absolute;
  left: calc(var(--btn-size, 36px) + var(--btn-gap, 6px));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: var(--btn-size, 36px);
  width: 0;
  overflow: hidden;
  opacity: 0;
  background: var(--btn-bg, #fff);
  border: var(--btn-border, 1px solid rgba(180,180,180,0.7));
  border-radius: var(--btn-radius, 8px);
  box-shadow: var(--btn-shadow, 0 1px 3px rgba(0,0,0,0.15));
  transition: width 0.35s ease, opacity 0.35s ease;
  z-index: 4;
}
.gc-buscador-control.open .gc-panel {
  width: 320px;
  opacity: 1;
  pointer-events: auto;
}

/* ===========================================================
   CAMPO DE TEXTO
   =========================================================== */
.gc-input {
  flex: 1;
  height: 100%;
  border: none;
  border-radius: var(--btn-radius, 8px);
  padding: 0 32px 0 10px;
  font: 13px/1.25 Inter, system-ui, Arial, sans-serif;
  color: #111;
  background: transparent;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}


/* ===========================================================
   BOTÓN LIMPIAR ✕
   =========================================================== */
.gc-clear-btn {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;

  width: 22px !important;
  height: 22px !important;

  background: #fff !important;
  border: 1px solid rgba(180,180,180,0.7) !important;
  border-radius: 50% !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  box-shadow: 0 1px 2px rgba(0,0,0,0.25) !important;
  cursor: pointer !important;

  z-index: 99999 !important;
}
.gc-clear-btn i {
  color: #333;
  font-size: 14px;
}


/* ===========================================================
   AUTOCOMPLETADO (jQueryUI + GeoBCN)
   =========================================================== */
.ui-autocomplete,
.geobcn-autocomplete {
  width: 314px !important;
  background: #fff !important;
  border-radius: 0 0 8px 8px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25) !important;
  z-index: 99999 !important;
}


/* ===========================================================
   ETIQUETA DE DIRECCIÓN (gc-badge)
   =========================================================== */
.gc-badge {
  position: absolute !important;
  left: 50% !important;
  transform: translate(-50%, var(--badge-offset-y)) !important;

  background: #fff;
  color: #111;
  padding: 4px 8px;
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);

  pointer-events: none;
  z-index: 10000 !important;
}


/* ===========================================================
   ENLACES PIU/CATASTRO
   =========================================================== */
.gc-links {
  position: absolute !important;
  left: 50% !important;
  transform: translate(-50%, var(--links-offset-y)) !important;

  background: #fff;
  padding: 6px 10px 8px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.25);
  min-width: 130px;

  text-align: center;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  line-height: 1.3;

  z-index: 10000 !important;
}

.gc-links a {
  display: block;
  color: #1a73e8;
  text-decoration: none;
  margin: 3px 0;
}
.gc-links a:hover {
  text-decoration: underline;
}

/* botón cierre enlaces */
.gc-links .gc-close-btn {
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;

  width: 22px !important;
  height: 22px !important;

  background: #fff;
  border: 1px solid rgba(180,180,180,0.7);
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.gc-links .gc-close-btn i {
  font-size: 14px;
  color: #333;
}


/* ===========================================================
   LIMPIEZA GEOBCN / JQUERY UI
   =========================================================== */
label[for="cerca"],
.geoBCN-autocomplete-label,
.ui-helper-hidden-accessible,
button.ui-button-icon-only[title="Esborrar"],
#btnd_cerca {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}


/* ============================================================
   NEUTRALIZACIÓN DEL CONTENEDOR FANTASMA (GeoBCN / jQuery UI)
   ============================================================ */

/* El contenedor que envuelve el input real del autocompletado */
.frmInput {
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  height: 100% !important;
}

/* Ocultamos elementos que no queremos */
.frmInput > label,
.frmInput > .ui-helper-hidden-accessible,
.frmInput > span[role="status"],
.frmInput > span:not(.gc-clear-btn):not(.gc-btn) {
  display: none !important;
}

/* Forzamos que el input generado por GeoBCN
   se comporte exactamente como tu input original */
.frmInput > input.geobcn-autocomplete {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding-left: 12px !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  font-size: inherit !important;
}
