/* ===============================================================
   1. VARIABLES GLOBALES — CONFIGURACIÓN PRINCIPAL
   =============================================================== */
:root {
  --ls-panel-width: 260px;
  --ls-panel-bg: rgba(255, 255, 255, 0.95);
  --ls-panel-border: 1px solid rgba(180,180,180,0.6);
  --ls-panel-radius: 12px;
  --ls-panel-shadow: 0 2px 4px rgba(0,0,0,0.15);

  --ls-x-main: 18px;      
  --ls-icon-top: 1px;    
  --ls-spacing-text: 0.25em;

  --ls-blue: #0A56C2;
  --ls-gray-icon-bg: #ffffff;

  --ls-y-group-gap: -0.75em;
  --ls-y-block-vectors-groups: 0.55em;
}

/* ===============================================================
   2. BOTÓN PRINCIPAL (OL LOGO)
   =============================================================== */
.layer-switcher > button {
  width: 36px !important;
  height: 36px !important;
  background: #ffffff !important;
  background-image: url("../icons/OpenLayers_logo.svg") !important;
  background-repeat: no-repeat !important;
  background-size: 24px 24px !important;
  background-position: center !important;
  border: 1px solid rgba(0,0,0,0.25) !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22) !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;
  cursor: pointer !important;
}

.layer-switcher > button::before,
.layer-switcher > button::after {
    content: "" !important;
    display: none !important;
}

/* ===============================================================
   3. CORRECCIÓN SALTO DE LÍNEA — ETIQUETAS RASTER
   =============================================================== */
.layer-switcher ul li:not(:has(img, svg)) {
    min-height: 22px !important;
}

/* ===============================================================
   4. PANEL CONTENEDOR
   =============================================================== */
.layer-switcher {
  width: var(--ls-panel-width) !important;
  max-width: var(--ls-panel-width) !important;
  background: transparent !important;
  overflow: visible !important;
}

.layer-switcher .panel {
  width: 100% !important;
  background: var(--ls-panel-bg) !important;
  border: var(--ls-panel-border) !important;
  border-radius: var(--ls-panel-radius) !important;
  box-shadow: var(--ls-panel-shadow) !important;
  overflow-y: auto !important;
  max-height: calc(100vh - 120px) !important;
  padding-top: 1em !important;
  padding-bottom: 0.8em !important;
}

/* ===============================================================
   5. LISTA Y ELEMENTOS LI/UL
   =============================================================== */
.layer-switcher ul {
  margin: 0 !important;
  padding: 0 !important;
}

.layer-switcher li {
  position: relative;
  margin-top: 0.20em !important;
}

/* ===============================================================
   6. BOTÓN DE CIERRE
   =============================================================== */
.ls-close-btn {
  position: absolute;
  top: 10px;
  left: 185px;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.ls-close-btn:hover {
  background: #f2f2f2;
}

/* ===============================================================
   7. CHECKBOX Y RADIO — APARIENCIA Y POSICIÓN
   =============================================================== */
.layer-switcher input[type="checkbox"],
.layer-switcher input[type="radio"] {
  position: absolute !important;
  left: var(--ls-x-main) !important;
  top: var(--ls-icon-top) !important;
  width: 18px !important;
  height: 18px !important;
  cursor: pointer !important;
}

/* Custom checkbox */
.layer-switcher input[type="checkbox"] {
  appearance: none !important;
  border-radius: 4px !important;
  background: #fff !important;
  border: 1px solid rgba(0,0,0,0.45) !important;
}

.layer-switcher input[type="checkbox"]:checked::before {
  content: "✓";
  font-size: 15px;
  color: var(--ls-blue);
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Custom radio */
.layer-switcher input[type="radio"] {
  appearance: none !important;
  border-radius: 50% !important;
  background: #fff !important;
  border: 1px solid rgba(0,0,0,0.45) !important;
}

.layer-switcher input[type="radio"]:checked {
  background: var(--ls-blue) !important;
  border-color: var(--ls-blue) !important;
}

/* ===============================================================
   8. ESPACIADOS ENTRE GRUPOS Y CAPAS
   =============================================================== */
.layer-switcher li.group {
  margin-top: var(--ls-y-group-gap) !important;
}

.layer-switcher li.layer {
  margin-top: var(--ls-y-block-vectors-groups) !important;
}

/* ===============================================================
   9. ETIQUETAS — BASE GENERAL
   =============================================================== */
.layer-switcher ul li label {
  padding-left: calc(var(--ls-x-main) + 16px) !important;
  font-size: 13px !important;
  line-height: 16px !important;
}

/* ===============================================================
   10. ETIQUETAS DE GRUPO (COLOR Y SANGRÍA)
   =============================================================== */
.layer-switcher ul li.group > label {
  padding-left: calc(var(--ls-x-main) + 34px) !important;
  font-weight: 600 !important;
  color: #000 !important;
}

.layer-switcher li.group ul li.group > label {
  padding-left: calc(var(--ls-x-main) + 44px) !important;
  font-weight: 600 !important;
  color: #000 !important;
}

/* ===============================================================
   11. ALINEACIÓN DE ETIQUETAS SIN ICONO
   =============================================================== */
.layer-switcher ul li:not(:has(img, svg)) > label {
    padding-left: calc(var(--ls-x-main) + 36px) !important;
}

/* ===============================================================
   12. BOTONES DE GRUPO — ICONO CÍRCULO
   =============================================================== */
.layer-switcher li.group > button {
  position: absolute !important;
  left: 14px !important;
  width: 28px !important;
  height: 28px !important;
  top: 19px !important;
  background: #ffffff !important;
  border: 1px solid rgba(0,0,0,0.25) !important;
  border-radius: 50% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.16) !important;
  cursor: pointer !important;
  position: relative !important;
}

.layer-switcher li.group ul li.group > button {
  top: 0px !important;
}

/* ===============================================================
   13. PURGA ▸ ▾ DEL PLUGIN — LIMPIEZA BÁSICA
   =============================================================== */
.layer-switcher button::before {
    content: "" !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
}

/* ===============================================================
   14. RECONSTRUCCIÓN COMPLETA DEL ICONO SVG
   =============================================================== */
.layer-switcher li.group > button::after {
    content: "" !important;
    position: absolute !important;
    width: 16px !important;
    height: 16px !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background-size: 16px 16px !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    pointer-events: none !important;
}

.layer-switcher li.group ul li.group > button::after {
    width: 16px !important;
    height: 16px !important;
    background-size: 16px 16px !important;
}

/* ===============================================================
   15. LÓGICA DE ESTADO — TRIÁNGULOS NEGRO/AZUL
   =============================================================== */
.layer-switcher li.group.layer-switcher-close > button::after {
    background-image: url("../icons/triangulo_negro.svg") !important;
}

.layer-switcher li.group:not(.layer-switcher-close) > button::after {
    background-image: url("../icons/triangulo_azul.svg") !important;
}

/* ===============================================================
   16. LIMPIEZA REAL DEL UNICODE ▸ ▾
   =============================================================== */
.layer-switcher li.group > button::after {
    content: "" !important;
    color: transparent !important;
    font-size: 0 !important;
    text-shadow: none !important;
    mask: none !important;
    -webkit-mask: none !important;
    background: none !important;
}

/* Reconstrucción posterior */
.layer-switcher li.group.layer-switcher-close > button::after {
    background-image: url("../icons/triangulo_negro.svg") !important;
}

.layer-switcher li.group:not(.layer-switcher-close) > button::after {
    background-image: url("../icons/triangulo_azul.svg") !important;
}

/* ===============================================================
   17. PARCHE DEFINITIVO — ELIMINACIÓN DE ▸ ▾
   =============================================================== */
.layer-switcher li.group > button::before,
.layer-switcher li.group > button::after {
    content: "" !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-shadow: none !important;
    color: transparent !important;
    -webkit-mask: none !important;
    mask: none !important;
}

/* Reconstrucción */
.layer-switcher li.group > button::after {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 16px !important;
    height: 16px !important;
    background-size: 16px 16px !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    pointer-events: none !important;
}

/* ===============================================================
   18. ALINEACIÓN PRECISA DEL ICONO (EJE COMÚN)
   =============================================================== */
:root {
    --ls-center-x: calc(var(--ls-x-main) + 9px);
}

.layer-switcher li.group > button {
    left: calc(var(--ls-center-x) - 14px) !important;
}

.layer-switcher li.group ul li.group > button {
    left: calc(var(--ls-center-x) 24px) !important;
}

/* ===============================================================
   19. AJUSTE VERTICAL DEL TEXTO DE GRUPO
   =============================================================== */
.layer-switcher .panel ul li.group > label {
    position: relative !important;
    top: -6px !important;
}

.layer-switcher .panel ul li.group ul li.group > label {
    position: relative !important;
    top: -3px !important;
}

/* ===============================================================
   20. ATRIBUCIONES PERSONALIZADAS
   =============================================================== */
.ol-attribution ul li:nth-child(n+4) a {
    color: #00009A !important;
    font-weight: bold !important;
}

.attrib-custom {
    color: #00009A !important;
    font-weight: bold !important;
}

.custom-attrib-label {
    font-weight: bold;
    color: #00009A !important;
    margin-right: 4px;
}

.green-attrib {
    color: #00009A !important;
    font-weight: bold;
}

.attr-label {
    margin-right: 4px;
    padding-right: 4px;
}

.ol-attribution a {
    color: inherit !important;
}

/* ===============================================================
   21. AUMENTO SENSIBILIDAD — HALO CLICKABLE
   =============================================================== */
.layer-switcher input[type="checkbox"] {
    position: relative !important;
    z-index: 2 !important;
}

.layer-switcher input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -6px;
    right: -6px;
    z-index: 3;
}

.layer-switcher ul li > input[type="radio"]::after,
.layer-switcher ul li > input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -6px;
    right: 6px;
    pointer-events: auto;
    background: transparent;
    z-index: 5;
}

.layer-switcher ul li:has(input[type="radio"]):not(:has(img, svg)) input[type="radio"]::after,
.layer-switcher ul li:has(input[type="checkbox"]):not(:has(img, svg)) input[type="checkbox"]::after {
    display: block !important;
}

/* ===============================================================
   22. ALINEACIÓN CORRECTA DE RASTER SIN ICONO
   =============================================================== */
.layer-switcher ul li > input[type="checkbox"] + label,
.layer-switcher ul li > input[type="radio"] + label {
    padding-left: calc(var(--ls-x-main) + 36px) !important;
}

/* ===============================================================
   23. ALINEACIÓN DEFINITIVA DE ETIQUETAS (5 REGLAS)
   =============================================================== */

/* 1) Vectoriales con icono SVG */
.layer-switcher ul li.layer:has(img, svg) > label {
    padding-left: calc(var(--ls-x-main) + 16px) !important;
}

/* 2) Vectoriales sin icono */
.layer-switcher ul li.layer:not(:has(img, svg)) > label {
    padding-left: calc(var(--ls-x-main) + 34px) !important;
}

/* 3) Raster dentro de grupo */
.layer-switcher ul li.group ul li:not(:has(img, svg)) > label {
    padding-left: calc(var(--ls-x-main) + 34px) !important;
}

/* 4) Raster suelta */
.layer-switcher ul > li.layer:not(:has(img, svg)):has(input[type="checkbox"]) > label {
    padding-left: calc(var(--ls-x-main) + 17px) !important;
}

/* 5) Oculta mapa (radio suelto) */
.layer-switcher ul > li.layer:not(:has(img, svg)):has(input[type="radio"]) > label {
    padding-left: calc(var(--ls-x-main) + 36px) !important;
}

