:root {
    /* Paleta institucional Alcaldía de Floridablanca (basada en su sitio oficial) */
    --fb-azul: #0c3b7a;       /* azul barra superior / gov.co */
    --fb-azul-oscuro: #082a58;
    --fb-verde: #16743f;      /* verde secciones / escudo */
    --fb-verde-oscuro: #0f5b30;
    --fb-amarillo: #ffcb05;   /* franja amarilla de acento */
    --fb-dorado: #c9a227;     /* dorado del escudo */
}

* { box-sizing: border-box; }
html, body {
    height: 100%;
    margin: 0;
}
body {
    display: flex;
    flex-direction: column;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1f2a24;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--fb-azul);
    color: #fff;
    border-bottom: 4px solid var(--fb-amarillo);
    flex-shrink: 0;
}

.header-marca {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-logo {
    height: 42px;
    width: auto;
    background: #fff;
    border-radius: 6px;
    padding: 3px;
}
.header-titulos { display: flex; flex-direction: column; line-height: 1.15; }
.header-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fb-amarillo);
    font-weight: 600;
}
.app-header h1 { font-size: 18px; margin: 2px 0 0; color: #fff; }

.app-body {
    position: relative;
    flex: 1;
    min-height: 0;
}

#mapa {
    width: 100%;
    height: 100%;
}

.btn-primary {
    background: var(--fb-verde);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
.btn-primary:hover { background: var(--fb-verde-oscuro); }

.btn-secundario {
    background: #fff;
    color: var(--fb-azul);
    border: 1px solid #cbd5e1;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.btn-secundario:hover { background: #f1f5f9; }

.panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    overflow-y: auto;
    padding: 16px 20px 40px;
    transition: transform 0.2s ease;
    z-index: 1000;
}
.panel.oculto { transform: translateX(105%); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.panel-header h2 { font-size: 16px; margin: 0; }

.btn-cerrar {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #666;
}
.btn-cerrar:hover { color: var(--fb-azul); }

.ayuda-mapa {
    font-size: 12px;
    color: #b45309;
    background: #fef3c7;
    padding: 6px 8px;
    border-radius: 6px;
}

fieldset {
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 10px 12px 14px;
}
legend {
    font-size: 12px;
    font-weight: 600;
    color: var(--fb-verde);
    padding: 0 4px;
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: #333;
}
input, select, textarea {
    width: 100%;
    margin-top: 4px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
}
input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}
input[type="color"] {
    width: 28px;
    height: 22px;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

.panel-acciones {
    display: flex;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 8px;
}

.leaflet-popup-content { font-size: 13px; }
.popup-editar {
    display: inline-block;
    margin-top: 6px;
    color: var(--fb-verde-oscuro);
    cursor: pointer;
    font-weight: 600;
}

.header-botones { display: flex; gap: 8px; }

/* ---------- Pantalla de carga inicial ---------- */
.pantalla-carga {
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 28, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 5000;
    color: #fff;
    transition: opacity 0.4s ease;
}
.pantalla-carga.oculta {
    opacity: 0;
    pointer-events: none;
}
.pantalla-carga .spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pantalla-carga-girar 0.8s linear infinite;
}
@keyframes pantalla-carga-girar { to { transform: rotate(360deg); } }
#pantalla-carga-texto {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin: 0;
}

/* ---------- Paneles flotantes (capas / clasificación) ---------- */
.panel-flotante {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 300px;
    max-width: 85vw;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
    border-top: 3px solid var(--fb-azul);
    box-shadow: 0 6px 24px rgba(12, 59, 122, 0.22);
    padding: 12px 14px 16px;
    z-index: 1100;
}
.panel-flotante.oculto { display: none; }
.panel-flotante .panel-header h3 { color: var(--fb-azul); }

.panel-clasificacion { top: 12px; left: 330px; }

.capas-seccion { margin-bottom: 10px; }
.capas-seccion-titulo {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    padding: 6px 0;
    margin: 4px 0 2px;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    font-family: inherit;
    font-weight: 600;
}
.capas-seccion-titulo:hover { color: var(--fb-azul); }
.capas-seccion-titulo .chevron {
    transition: transform 0.15s ease;
    font-size: 13px;
}
.capas-seccion-titulo.colapsado .chevron { transform: rotate(-90deg); }

.capas-seccion-contenido.colapsado { display: none; }
.capa-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 6px;
}

.capa-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}
.capa-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.capa-item.capa-anidada {
    margin-left: 18px;
    padding-left: 8px;
    border-left: 2px solid #e5e7eb;
}
.capa-item input[type="range"] { width: 80px; }
.capa-item.capa-pendiente { opacity: 0.55; }
.etiqueta-pendiente {
    font-size: 10px;
    background: #f3f4f6;
    color: #888;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.btn-engranaje {
    background: #f3f4f6;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
}
.btn-engranaje:hover { background: #e5e7eb; }

/* ---------- Panel de clasificación ---------- */
.panel-clasificacion label {
    display: block;
    font-size: 13px;
    margin: 8px 0 4px;
}
.panel-clasificacion select,
.panel-clasificacion input[type="range"] { width: 100%; }

.clasif-fila-color-fijo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    margin: 8px 0;
}
.clasif-check-etiquetas { display: flex; align-items: center; gap: 6px; }
.clasif-check-etiquetas input { width: auto; }

.clasif-opciones-etiqueta {
    margin: 6px 0 10px 22px;
    padding-left: 10px;
    border-left: 2px solid #e5e7eb;
}
.clasif-opciones-etiqueta.oculto { display: none; }

.clasif-nota {
    font-size: 11px;
    color: #777;
    margin: 10px 0 0;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
}

/* Subcapas de clasificación anidadas bajo "Ofertas inmobiliarias" en el panel de Capas */
.clasif-subcapas {
    margin: 2px 0 6px 22px;
    padding-left: 10px;
    border-left: 2px solid var(--fb-azul);
}
.clasif-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}
.clasif-fila-check {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.clasif-fila-check .clasif-color {
    border-radius: 4px;
    cursor: pointer;
}
.clasif-etiqueta {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.clasif-conteo {
    background: #f3f4f6;
    color: #555;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    flex-shrink: 0;
}

/* ---------- Barra de herramientas del mapa: zoom, pantalla completa, regla ---------- */
/* Control propio con posición absoluta, independiente del sistema de esquinas
   de Leaflet, para no arrastrar la atribución de OpenStreetMap/CARTO al centrarla. */
.barra-herramientas-mapa {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 1000;
}
.herramienta-boton {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-decoration: none;
    background: var(--fb-azul);
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(12,59,122,0.35);
    cursor: pointer;
}
.herramienta-boton:hover { background: var(--fb-azul-oscuro); }
.herramienta-boton.herramienta-activa {
    background: var(--fb-amarillo);
    color: var(--fb-azul-oscuro);
}

/* ---------- Visor de coordenadas del mouse (esquina real bottomleft) ---------- */
.coordenadas-control {
    background: rgba(255,255,255,0.9);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: "Courier New", monospace;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    white-space: nowrap;
}

#regla-etiqueta {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1200;
    pointer-events: none;
}

.etiqueta-oferta {
    background: rgba(255,255,255,0.85);
    border: none;
    box-shadow: none;
    font-size: 10px;
    padding: 1px 4px;
}
.etiqueta-oferta::before { display: none; }

.etiqueta-capa-catastral {
    background: transparent;
    border: none;
    box-shadow: none;
    white-space: nowrap;
    pointer-events: none;
}
.etiqueta-capa-catastral span {
    color: #1f2a24;
    font-weight: 600;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

/* ---------- Control de mapa base (círculo + miniaturas) ---------- */
.mapabase-control { position: relative; }

.mapabase-boton {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #00000022;
    background: #fff;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.mapabase-boton:hover { background: #f5f5f5; }

.mapabase-panel {
    position: absolute;
    top: 56px;
    right: 0;
    display: grid;
    grid-template-columns: repeat(2, 80px);
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.mapabase-panel.oculto { display: none; }

.mapabase-item { text-align: center; cursor: pointer; }
.mapabase-miniatura {
    width: 80px;
    height: 56px;
    border-radius: 8px;
    border: 2px solid transparent;
}
.mapabase-item span {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    color: #555;
}
.mapabase-item-activo .mapabase-miniatura { border-color: var(--fb-azul); }
.mapabase-item-activo span { color: var(--fb-azul); font-weight: 600; }
