body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font-body);
}

#map {
    width: 100vw;
    height: 100vh;
    background-size: 30px 30px;
    background-image: radial-gradient(circle, var(--brand-beige) 1px, transparent 1px);
    background-position: 0 0;
    background-color: #ffffff;
}

.leaflet-container {
    background-color: transparent !important; 
}

/* Estilos del Overlay */
.overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 10000;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(20px); 
    pointer-events: none;
    transition: all 0.4s ease;
}

.overlay.active {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
}

.close-overlay {
    position: fixed;
    top: 20px;
    right: 30px;
    width: 50px;
    height: 50px;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--color-logo);
    background: #ffffff;
    cursor: pointer;
    z-index: 10001;
    border-radius: 50%;
}

.overlay-container {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.overlay-image {
    flex: 1;
    background-color: var(--brand-beige);
    display: flex;
    align-items: center;
    justify-content: center;
}
.overlay-image img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.overlay-body {
    padding: 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--brand-dark);
}

/* Tipografías específicas en el contenido del lote */
#detalles-lote h1, #detalles-lote h2, #detalles-lote h3 {
    font-family: var(--font-titles);
    font-weight: 300; /* Barlow Condensada Light */
    text-transform: uppercase;
    color: var(--color-logo);
}

#detalles-lote p {
    font-family: var(--font-body);
    font-weight: 400; /* Barlow Regular */
    line-height: 1.6;
}

/* Loader personalizado */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--brand-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    font-family: var(--font-titles);
}

.loader-content {
    text-align: center;
    color: var(--color-logo);
}

.brand-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.logo-fondo-static {
    fill: var(--brand-beige);
    opacity: 0.2; /* El fondo "vacío" */
}

.logo-wrapper {
    position: relative;
    width: 100px; 
    height: 112px; 
    margin: 0 auto 20px;
}

#fill-container {
    position: absolute;
    bottom: 0;         /* El contenedor crece desde abajo */
    left: 0;
    width: 100%;
    height: 0%;        /* GSAP animará esto */
    overflow: hidden;  /* Recorta el contenido */
}

.logo-relleno-static {
    fill: var(--brand-beige);
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100px; 
    height: 112px; 
}

/* Texto del loader */
.loader-content p {
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 14px;
    color: var(--brand-beige);
}

@media (min-width: 768px) {
    .overlay-container {
        flex-direction: row;
    }
    .overlay-image, .overlay-body {
        width: 50%;
        height: 100vh;
    }
    #brand-logo img {
    width: 15vw;
    height: auto;
}
}

/* --- Rediseño del Contenedor de Filtros (Bottom Sheet Style) --- */
#filter-container {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%; /* No llega a los bordes laterales en móvil */
    max-width: 800px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 24px; /* Bordes muy redondeados tipo pastilla */
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    gap: 20px;
    border: 1px solid rgba(0,0,0,0.05);
}

.filter-section {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 240px;
    flex: 1;
}

.filter-group label {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-dark);
    margin-bottom: 12px;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center; 
}

.filter-val {
    white-space: nowrap; 
    font-weight: 500;  
    color: var(--brand-dark);
}

/* --- Estilizado Moderno de Sliders (Custom Range) --- */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

/* Quitar el outline al enfocar */
input[type=range]:focus {
    outline: none;
}

/* Track (La línea del slider) */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px; /* Altura de la línea */
    background: var(--brand-beige);
    border-radius: 10px;
    border: none;
}

/* Thumb (La perilla/pastilla) */
input[type=range]::-webkit-slider-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--brand-dark);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    -webkit-appearance: none;
    margin-top: -8px; /* Centrar respecto al track */
    transition: transform 0.2s ease, background 0.2s ease;
}

/* Efecto al presionar */
input[type=range]:active::-webkit-slider-thumb {
    transform: scale(1.15);
    background: var(--color-logo);
}

/* Compatibilidad para Firefox */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 8px;
    background: var(--brand-beige);
    border-radius: 10px;
}
input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--brand-dark);
}

/* --- Leyenda Ajustada --- */
.legend-section {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 15px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Desktop Adjustment */
@media (min-width: 768px) {
    #filter-container {
        bottom: 20px;
        padding: 15px 30px;
        flex-direction: row;
        align-items: center;
        width: auto; /* Se ajusta al contenido en desktop */
    }
    .filter-section {
        border-right: 1px solid rgba(0,0,0,0.1);
        padding-right: 30px;
    }
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-family: var(--font-body);
    color: var(--brand-dark);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
}
.dot.disponible { background-color: #418d4d; border: 1px solid #002D0E; }
.dot.apartado { background-color: #D69A2D; border: 1px solid #886711; }
.dot.vendido { background-color: #cd3838; border: 1px solid #002D0E; }
.dot.desarrollo { background-color: #929292; border: 1px solid #002D0E; }

.lote-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--brand-dark) !important;
    font-family: var(--font-body);
    font-weight: 600;
    pointer-events: none;
    display: none; 
    white-space: nowrap;
    text-align: center;
    transform: translate(-50%, -50%);
}

/* Ajuste opcional para que los sliders se vean activos desde el inicio */
input[type=range] {
    cursor: pointer;
}
/* --- Estilos para el nuevo comportamiento móvil --- */

/* Ocultar elementos móviles por defecto */
#filter-fab, #filter-backdrop {
    display: none;
}


@media (max-width: 767px) {
    /* Botón Circular */
   #filter-fab {
        display: flex;
        position: fixed;
        bottom: 25px;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        white-space: nowrap; /* Evita que el texto salte de línea */
        padding: 12px 24px;
        border-radius: 30px;
        background-color: #ffffff;
        color: var(--brand-dark);
        border: 1px solid rgba(0,0,0,0.08);
        box-shadow: 0 8px 25px rgba(0,0,0,0.12);
        z-index: 2500;
        align-items: center;
        justify-content: center;
        gap: 10px; /* Separación entre el SVG y el texto */
        font-family: var(--font-body);
        font-weight: 600;
        font-size: 14px;
    }
    
    .mobile-only-fab svg {
        width: 18px;
        height: 18px;
        fill: var(--brand-dark);
    }

    /* Contenedor de Filtros "Flotante" en móvil */
    #filter-container {
        left: 4%; /* Centrado horizontal (100 - 92 / 2) */
        bottom: 20px; /* Margen inferior para que flote */
        width: 92%;
        max-width: none;
        border-radius: 24px; /* Redondeado completo */
        transform: translateY(120%); /* Empieza más abajo para ocultar la sombra */
        margin-bottom: 0;
        z-index: 3000;
        position: fixed;
        /* Ya no se pega a los bordes laterales */
    }
}
/* =========================================
   NUEVO DISEÑO DE OVERLAY (MODAL LOTE) 
========================================= */

.overlay-container.modal-rediseño {
    background: #ffffff;
    width: 100%;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* Área de Imagen Superior (Hero) */
.modal-hero {
    width: 100%;
    height: 280px;
    background: var(--brand-beige);
    flex-shrink: 0;
}

.modal-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Contenido / Información */
.modal-content-wrapper {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    color: var(--brand-dark);
}

.modal-header {
    text-align: center;
}

.tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    padding: 8px 20px;
    border-radius: 30px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.tipo-badge img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.lote-title {
    font-family: var(--font-titles);
    font-size: 38px;
    color: var(--color-logo);
    margin: 0;
    font-weight: 400;
    line-height: 1;
}

/* Toggles (Interruptores M2/SQFT - Divisas) */
.toggles-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin: 10px 0;
}

.toggle-group {
    display: inline-flex;
    background: #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
    padding: 4px;
}

.toggle-group button {
    background: transparent;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-group button.active {
    background: var(--brand-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Ficha Técnica */
.ficha-tecnica {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    font-family: var(--font-body);
    font-size: 16px;
}

.ficha-tecnica p {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #ebebeb;
    padding-bottom: 12px;
    margin-bottom: 12px;
    margin-top: 0;
}

.ficha-tecnica p:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ficha-tecnica b {
    color: #777;
    font-weight: 500;
}

.ficha-tecnica span {
    font-weight: 600;
    color: var(--brand-dark);
}

/* Visor de PDF (Plano) */
.pdf-viewer-container {
    width: 100%;
    background: #ffffff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-sizing: border-box;
}

.pdf-viewer-container h3 {
    font-family: var(--font-body);
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 1px;
    color: #999;
    margin-top: 0;
    margin-bottom: 15px;
}

#pdf-canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Nuevo contenedor para los botones */
.botones-acciones {
    display: flex;
    gap: 15px; /* Separación entre ambos botones */
    width: 100%;
    margin-top: 10px;
}

/* Estilo modificado de los botones */
.btn-wa {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 10px;
    background: var(--color-logo);
    color: white;
    padding: 16px 12px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 15px; 
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.3s ease, transform 0.2s ease;
    cursor: pointer;
}

.btn-wa:hover {
    background: var(--brand-dark);
    transform: translateY(-2px);
}

.btn-wa svg {
    flex-shrink: 0;
}

#lago-desc p {
    font-family: var(--font-body);
    line-height: 1.6;
    margin-bottom: 15px;
}

/* =========================================
   ADAPTACIONES DESKTOP (ESCRITORIO)
========================================= */
@media (min-width: 900px) {
    /* El contenedor principal ahora permite scroll en toda la pantalla */
    .overlay-container.modal-rediseño {
        flex-direction: column; 
        width: 100vw;       
        max-width: none;    
        height: 100vh;      
        margin: 0;          
        border-radius: 0;   
        box-shadow: none;   
        overflow-y: auto;   /* <-- El scroll ahora pertenece a toda la página */
    }

    /* Hero banner */
    .modal-hero {
        height: 30vh;
        min-height: 350px; /* Altura mínima de seguridad */
        width: 100%;
        flex-shrink: 0;
    }

    /* Contenedor de contenido (crece de forma natural, sin scroll interno) */
    .modal-content-wrapper {
        width: 100%;
        height: auto; /* <-- Quitamos el 65vh fijo */
        overflow: visible; /* <-- Quitamos el scroll interno */
        padding: 60px 10vw; /* Más aire superior e inferior */
        box-sizing: border-box;
        
        display: grid;
        grid-template-columns: 1fr 1fr; 
        /* Todo el texto y botones a la izquierda, el PDF a la derecha */
        grid-template-areas: 
            "header pdf"
            "toggles pdf"
            "lago pdf"
            "ficha pdf"
            "divisa pdf"
            "btn pdf";
        gap: 20px 60px; 
        align-items: start; /* Evita que los botones o textos se estiren */
    }

    .modal-header { grid-area: header; text-align: left; }
    
    /* Toggles ahora alineados a la izquierda */
    .toggles-wrapper { 
        grid-area: toggles; 
        flex-direction: row; 
        justify-content: flex-start; /* <-- Pegados a la izquierda */
        gap: 15px; /* Separación entre los botones de m2 y divisas */
        border-bottom: none; /* Look más limpio sin línea divisoria */
        padding-bottom: 0; 
        margin-bottom: 10px; 
    }
    
    #lago-desc { grid-area: lago; }
    
    .ficha-tecnica { grid-area: ficha; margin: 0; }
    
    .info-divisa { 
        grid-area: divisa; 
        font-size: 12px; 
        color: #888; 
        margin: 0; 
        line-height: 1.4;
    }
    
    .botones-acciones { 
        grid-area: btn; 
        align-self: start; 
        justify-self: start;
        width: 100%; 
        max-width: 450px;
    }
    
    .btn-wa { 
        padding: 16px 20px; 
    }
    
    .pdf-viewer-container { 
        grid-area: pdf; 
        height: 100%; 
        display: flex; 
        flex-direction: column; 
        justify-content: flex-start; /* Se alinea con el título */
        margin: 0; 
        background: transparent; 
        border: none; 
    }

    .modal-header .tipo-badge {
        margin-bottom: 15px;
    }

    #pdf-canvas {
        max-height: 60vh; /* El plano puede ser más grande ahora */
        width: 100%;
        object-fit: contain;
        margin: 0;
        box-shadow: 0 10px 30px rgba(0,0,0,0.08); 
    }

    /* El botón de cerrar flota fijo para no perderlo al hacer scroll */
    .close-overlay {
        position: fixed; /* <-- Crucial para que baje contigo */
        right: 40px;
        top: 30px;
        color: var(--brand-dark); 
        background: #fff;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        font-size: 32px;
        backdrop-filter: blur(5px);
        transition: background 0.3s ease;
        z-index: 10002;
    }

    .close-overlay:hover {
        background: var(--brand-dark);
        color: #fff;
    }
}
/* =========================================
   NUEVOS ELEMENTOS DE FILTRO (ESCRITORIO) 
========================================= */

/* Por defecto (en móvil), los botones de escritorio no existen */
#filter-btn-desktop, .close-filters-btn {
    display: none;
}

/* El backdrop ahora es global, lo necesitamos en móvil y escritorio */
#filter-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1); /* Sombra sutil para apagar el mapa */
    z-index: 1900; 
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 768px) {
    /* Pastilla redondeada en la parte inferior del escritorio */
    #filter-btn-desktop {
        display: block;
        position: fixed;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        background-color: #ffffff;
        color: var(--brand-dark);
        border: 1px solid rgba(0,0,0,0.08);
        border-radius: 30px;
        padding: 14px 32px;
        font-family: var(--font-body);
        font-weight: 600;
        font-size: 15px;
        box-shadow: 0 8px 25px rgba(0,0,0,0.12);
        cursor: pointer;
        z-index: 2500;
        transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }
    #filter-btn-desktop svg {
        width: 20px;
        height: 20px;
        fill: var(--brand-dark);
        margin-right: 10px;
    }

    #filter-btn-desktop:hover {
        background-color: #f9f9f9;
        transform: translateX(-50%) translateY(-2px);
        box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    }

    /* Sobrescribimos el contenedor en escritorio para que nazca oculto y tenga espacio para la X */
    #filter-container {
        bottom: 20px;
        padding: 15px 50px 15px 30px !important; 
        flex-direction: row;
        align-items: center;
        width: auto;
        transform: translate(-50%, 150%);
    }

    /* Botón X de cerrar dentro del contenedor */
    .close-filters-btn {
        display: block;
        position: absolute;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        background: transparent;
        border: none;
        font-size: 28px;
        color: var(--brand-dark);
        cursor: pointer;
        line-height: 1;
        padding: 0;
        opacity: 0.5;
        transition: opacity 0.2s ease;
    }

    .close-filters-btn:hover {
        opacity: 1;
    }
}