:root {
    --bg-main: #FBFaf8; /* Soft warm off-white */
    --surface: #FFFFFF;
    --text-main: #2C3539; /* Deep charcoal/slate */
    --text-light: #7A8B8F;
    --primary: #D4AF37; /* Elegant soft gold */
    --primary-light: #f5eedc;
    --secondary: #A3B8B0; /* Soft elegant sage green */
    --accent: #E3877A; /* Soft muted coral for emphasis */
    --border: #E8E5E1;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic viewport height para celulares */
    width: 100vw;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 420px;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 20px rgba(0,0,0,0.04);
    z-index: 1000;
}

.sidebar-header {
    padding: 32px 24px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #ffffff, #fcfcfc);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--primary);
}

.logo i {
    font-size: 1.8rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.sidebar-header p {
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 300;
}

/* Property List */
.property-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.property-list::-webkit-scrollbar {
    width: 6px;
}
.property-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}

/* Property Card */
.property-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
}

.property-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--primary);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    transform-origin: bottom;
}

.property-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.property-card:hover::before,
.property-card.active::before {
    transform: scaleY(1);
}

.property-card.active {
    background-color: var(--primary-light);
    border-color: var(--primary);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* pre-line respeta los saltos de línea que arma el título automático (negocio/tipo/
       precio/características en una línea, localidad+dirección en la siguiente) sin dejar
       de ajustar el resto del texto normal si no entra en el ancho de la tarjeta. */
    white-space: pre-line;
    text-align: center;
}

.card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 12px;
}

.card-details {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.detail-item i {
    color: var(--primary);
}

.card-notes {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    text-align: center;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
    background-color: #e5e5e5;
}

/* Custom Popup Styling */
.leaflet-popup {
    max-width: 95vw !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0;
    overflow: hidden;
    max-width: 95vw !important;
}

.leaflet-popup-content {
    margin: 0;
    padding: 12px 16px;
    max-width: 95vw !important;
}

/* La X de cerrar del popup, a la izquierda en vez de la derecha (default de Leaflet) —
   así queda siempre visible/alcanzable sin que la tape el borde del mapa o el panel de
   capas cuando el popup se abre pegado al costado derecho. */
.leaflet-popup-close-button {
    left: 4px !important;
    right: auto !important;
    top: 4px !important;
}

/* Encabezado "Info" del control de capas (ver insertarEncabezadoInfo en app_arba_prueba.js):
   se muestra como una fila más DE "Capital Federal" (pedido explícito: "una subcuenta dentro
   de Capital Federal") aunque el plugin no soporta sub-grupos anidados de verdad -- se pliega
   y despliega junto con Capital Federal (ver aplicarPliegueCapitalFederal) y se indenta un
   poco para leerse como parte de ese grupo. Los 9 grupos de puntos de interés de CABA quedan
   un nivel más adentro todavía (indentación + borde izquierdo tenue), como hijos de Info. */
.cb-info-header {
    margin-left: 6px;
}
.cb-grupo-info-caba {
    margin-left: 14px;
    padding-left: 6px;
    border-left: 2px solid #e2e8f0;
}
/* "Comercios" reubicado como fila de "Bahía Blanca" (ver moverComerciosDentroDeBahiaBlanca
   en app_arba_prueba.js) -- mismo criterio visual que "Info" dentro de Capital Federal. */
.cb-comercios-en-bahia {
    margin-left: 6px;
}

.popup-header {
    background-color: var(--primary-light);
    padding: 16px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.popup-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
    margin: 0;
}

.property-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.popup-body {
    padding: 16px;
    font-family: 'Outfit', sans-serif;
    text-align: center;
}

.popup-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 8px;
}

.popup-info {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.popup-link {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--primary);
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    text-align: center;
    width: 100%;
}

.popup-link:hover {
    background-color: #B5952F;
}

.sidebar-footer {
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Tooltip customization */
.leaflet-tooltip.custom-hover-tooltip {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    color: var(--text-main);
    padding: 6px 12px;
}
.leaflet-tooltip.custom-hover-tooltip::before {
    border-top-color: var(--border);
}

/* Popup Tabs */
.popup-tabs {
    display: flex;
    justify-content: space-between;
    overflow-x: hidden;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.popup-tab-btn {
    flex: 1;
    text-align: center;
    background: none;
    border: none;
    padding: 8px 1px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: -0.2px;
}
.popup-tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}
/* Pestañas que existen (zonificación, normativa, etc.) pero quedan atrás del login: se
   ven para que se note que hay más info, pero no se pueden tocar. */
.popup-tab-btn.bloqueada {
    color: var(--text-light);
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.popup-tab-content {
    display: none;
    min-height: 280px;
}

/* Propiedades nuevas: pin que titila entre el color normal y fucsia (mapa) + etiqueta
   en la tarjeta de la lista, para que llamen la atención y las abran. */
.badge-nuevo {
    display: inline-block;
    background: #e6007e;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 4px;
}
@keyframes pinNuevoTitileo {
    0%, 100% { background-color: var(--primary); }
    50% { background-color: #e6007e; }
}
.custom-pin-nuevo-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 10px rgba(0,0,0,0.4);
    animation: pinNuevoTitileo 1s ease-in-out infinite;
}

/* Resalte del marcador de la propiedad actual en la hoja mobile (ver resaltarMarcador en
   mobile_bottom_sheet.js) -- se anima el DIV de adentro del pin (mismo criterio que
   .custom-pin-nuevo-dot arriba), nunca el contenedor que Leaflet mueve con su propio
   transform inline en cada pan/zoom. */
@keyframes hpMarcadorPulso {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(37,99,235,0)); }
    50% { transform: scale(1.5); filter: drop-shadow(0 0 6px rgba(37,99,235,0.95)); }
}
.hp-marcador-resaltado {
    animation: hpMarcadorPulso 1s ease-in-out infinite;
}
.popup-tab-content.active {
    display: flex;
    flex-direction: column;
}
.popup-btn-link {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--primary);
    color: white !important;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    width: 100%;
    margin-top: 10px;
    transition: transform 0.2s;
}
.popup-btn-link:hover {
    transform: scale(1.02);
}
.popup-btn-link i {
    margin-right: 8px;
}
.zoning-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.zoning-card {
    background: var(--bg-color);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid var(--border);
}
.zoning-card span {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
}
.zoning-card strong {
    font-size: 1rem;
    color: var(--text-main);
}
.zoning-result {
    background: rgba(17, 100, 71, 0.1);
    color: var(--primary);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid rgba(17, 100, 71, 0.2);
}

/* Adjust Leaflet controls to prevent overlapping with the footer */
.leaflet-touch .leaflet-control-layers-toggle {
    width: 44px;
    height: 44px;
}

/* Ocultar tooltips globalmente cuando hay un popup abierto */
body.hide-tooltips .leaflet-tooltip {
    display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        display: contents; /* Allows children to be flex items of app-container */
    }
    
    .sidebar-header {
        order: 1;
        width: 100%;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    /* El buscador (calle/partida + selector de zona) no tenía "order" propio: con
       .sidebar en display:contents, sus hijos son flex items directos de .app-container,
       y sin order explícito caían en el valor por defecto (0) — por delante del header,
       que sí tiene order:1. Quedaba arriba de todo, antes del logo. */
    #buscador-terrenos-box {
        order: 1;
        width: 100%;
    }

    .map-container {
        order: 2;
        width: 100%;
        flex: 1;
        height: auto;
        min-height: 0; /* Evita que desborde el contenedor flex */
    }
    
    .property-list {
        display: none; /* Hide the sidebar list on mobile as requested */
    }
    
    .sidebar-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        background: var(--surface);
    }
}

/* ===== Hoja deslizable de propiedades (celular) — ver mobile_bottom_sheet.js =====
   Reemplaza la lista lateral (oculta arriba en mobile) por una hoja de 3 estados sobre
   el mapa: oculta (solo la manija), vista previa (una propiedad, deslizable de costado) y
   lista completa (tapa el mapa). Solo existe en el DOM si mobile_bottom_sheet.js decide
   crearla (viewport angosto), así que estas reglas no afectan nunca al escritorio. */
#hoja-propiedades-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    z-index: 1200;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    touch-action: none;
}
#hoja-propiedades-mobile.hp-arrastrando { transition: none; }
#hoja-propiedades-mobile:not(.hp-arrastrando) { transition: height 0.25s ease; }

.hp-manija-zona {
    flex-shrink: 0;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}
.hp-manija {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}

.hp-peek {
    flex-shrink: 0;
    /* padding-right reserva el ancho de los botones flotantes de voz (mic 58px + modo
       automático 34px + gap 8px + margen derecho 20px de #voz-fila, ver voz_ia.js), que
       quedan fijos abajo a la derecha y se superponían con el texto de la tarjeta/los
       puntos -- pedido explícito. Un poco de margen extra (128 en vez de 120 exactos) para
       que no quede al ras. */
    padding: 0 128px 12px 16px;
    position: relative;
}
.hp-peek .property-card { margin-bottom: 0; }
.hp-peek-puntos {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 8px;
}
.hp-peek-puntos span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
}
.hp-peek-puntos span.hp-punto-activo {
    background: var(--primary);
}

.hp-lista-full {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* CPU Zone Tooltips */
.cpu-zone-tooltip {
    background: rgba(63, 91, 169, 0.92) !important;
    color: #fff !important;
    border: none !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    padding: 4px 10px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}
.cpu-zone-tooltip::before {
    border-top-color: rgba(63, 91, 169, 0.92) !important;
}
/* Nombres de localidades (capa Localidades): se achican o desaparecen al alejar el zoom,
   para no saturar el mapa cuando se ve toda la región de una vez. */
.cpu-zone-tooltip-chico {
    font-size: 0.6rem !important;
    padding: 2px 6px !important;
    opacity: 0.65 !important;
}
.cpu-zone-tooltip-oculto {
    display: none !important;
}

/* Eliminar cuadrado/borde negro de enfoque al interactuar con el mapa o capas vectoriales */
.leaflet-container :focus,
.leaflet-interactive:focus,
path.leaflet-interactive:focus,
svg:focus,
svg *:focus {
    outline: none !important;
    box-shadow: none !important;
}


/* Elevar controles de Leaflet en moviles para no superponer con el footer */
@media (max-width: 900px) {
    .leaflet-bottom {
        bottom: 90px !important;
    }
}

/* ===== Dibujar zona + buscar en esa zona (ver dibujar_zona.js) ===== */
.dz-panel {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    padding: 8px;
    max-width: min(320px, calc(100vw - 90px));
}
.dz-fila {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.dz-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    border-radius: 20px;
    padding: 7px 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
}
.dz-btn:hover {
    background-color: #f5f0e0;
}
.dz-btn:active {
    transform: scale(0.97);
}
/* Botón de arranque ("Dibujar zona"): solo el ícono, redondo y chico -- mismo lenguaje
   visual que los demás controles sueltos del mapa (zoom, ubicación), no un botón con texto
   compitiendo por espacio en la esquina. */
.dz-btn-solo-icono {
    padding: 0;
    width: 34px;
    height: 34px;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.95rem;
}
/* Vive agrupado junto a zoom/ubicación (ver dibujar_zona.js, en mobile y en escritorio por
   igual) -- mismo tamaño que esos controles (28px, medido en vivo) y un pelín de aire arriba
   para separarlo del "+" de zoom, en vez del padding pensado para cuando el panel está solo
   en su propia esquina (eso solo pasa si #voz-controles-mapa no llegó a existir todavía, ver
   moverArribaDelZoom). Selector por descendencia en vez de @media: la agrupación ya no
   depende del ancho de pantalla. */
#voz-controles-mapa .dz-panel { padding: 0; background: none; box-shadow: none; margin-bottom: 6px; }
#voz-controles-mapa .dz-btn-solo-icono { width: 28px; height: 28px; font-size: 0.8rem; }
.dz-estado {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-light);
    line-height: 1.3;
}
.dz-estado:empty {
    margin-top: 0;
}
