/* --- RESET GENERAL --- */
#bg-wrapper * { box-sizing: border-box; }
#bg-wrapper { 
    width: 100%; 
    margin: 0 auto; 
    font-family: 'Inter', system-ui, sans-serif; 
    position: relative; 
    z-index: 100; 
}

#bg-main-container { display: flex; flex-direction: column; }

/* --- TÍTULO DINÁMICO --- */
#bg-dynamic-title {
    color: #ffffff !important; 
    font-family: inherit !important; 
    font-weight: inherit !important;
    font-style: inherit !important;
    font-size: 42px !important; 
    line-height: 1.2 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.bg-city-hero {
    font-family: inherit !important;
    font-size: 1.5em !important; 
    font-weight: 800 !important; 
    display: inline-block;
    color: #ffffff !important;
    margin-top: 5px;
    margin-bottom: 0px; 
}

.bg-loc-change-btn {
    font-family: 'Inter', system-ui, sans-serif !important; 
    color: #176CA1 !important; 
    text-decoration: none !important;
    border-bottom: 1px dotted #176CA1;
    font-size: 16px !important;
    font-weight: 600 !important;
    transition: all 0.2s;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}
.bg-loc-change-btn:hover { color: #42a5f5 !important; border-bottom: 1px solid #42a5f5; }
.bg-loc-change-btn svg { margin-right: 4px; }

/* --- ÁREA DE CHAT --- */
#bg-response-area {
    display: none; 
    flex-direction: column;
    gap: 8px;
    padding: 15px; 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(5px);
    border-radius: 16px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
    border: 1px solid #e0e0e0;
    max-height: 300px; 
    overflow-y: auto;
    margin-bottom: 8px;
    scrollbar-width: thin;
    transition: all 0.3s ease-in-out;
}

#bg-response-area.active { display: flex; }

.bg-chat-bubble {
    padding: 8px 14px; border-radius: 16px; max-width: 95%; font-size: 13px; line-height: 1.4;
    animation: slideIn 0.2s ease-out; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.user-msg { align-self: flex-end; background: #176CA1; color: white; border-bottom-right-radius: 4px; }
.ai-msg { align-self: flex-start; background: #f0f2f5; color: #333; border: 1px solid #e5e5e5; border-bottom-left-radius: 4px; }

/* --- ANIMACIÓN ÁTOMOS --- */
.bg-atomic-loader { position: relative; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; margin-right: 8px; vertical-align: middle; }
.bg-atom-center { width: 6px; height: 6px; background: #176CA1; border-radius: 50%; position: absolute; z-index: 2; }
.bg-atom-axis { position: absolute; width: 100%; height: 100%; top: 0; left: 0; display: flex; align-items: center; justify-content: center; }
.axis-1 { transform: rotate(45deg); }
.axis-2 { transform: rotate(-45deg); }
.bg-atom-dot { width: 4px; height: 4px; background: #176CA1; border-radius: 50%; opacity: 0.8; position: absolute; animation: atomSlide 1.2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite alternate; }
.axis-2 .bg-atom-dot { animation-delay: -0.6s; }
@keyframes atomSlide { 0% { transform: translateX(-7px) scale(0.8); opacity: 0.5; } 50% { transform: translateX(0px) scale(1.2); opacity: 1; } 100% { transform: translateX(7px) scale(0.8); opacity: 0.5; } }

/* --- CAJA PRINCIPAL DE BÚSQUEDA --- */
.bg-search-box {
    background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px);
    border: 1px solid #e0e0e0; border-radius: 16px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08) !important;
    padding: 10px 15px; transition: all 0.2s ease; 
    display: flex; flex-direction: column; position: relative; z-index: 20; cursor: text; 
}
.bg-search-box.is-expanded {
    border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important; border-bottom: none !important;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05), 5px 0 10px rgba(0,0,0,0.05), -5px 0 10px rgba(0,0,0,0.05) !important; 
}
.bg-search-box:focus-within { border-color: #135B88 !important; }

/* INPUTS */
.bg-input-area { width: 100% !important; margin-bottom: 5px; display: flex; position: relative; }
#bg-input.bg-main-input { width: 100% !important; border: none !important; outline: none !important; background: transparent !important; box-shadow: none !important; margin: 0 !important; padding: 0 35px 0 0 !important; font-size: 16px !important; color: #111 !important; font-weight: 500 !important; line-height: 1.5 !important; resize: none !important; overflow-y: hidden; min-height: 24px !important; display: block; }
#bg-input.bg-main-input.has-scroll { overflow-y: auto !important; }
#bg-input::placeholder { color: #999 !important; }
#bg-clear-btn { position: absolute; right: 0; top: 0; margin-top: 2px; background: #f0f0f0; border: none; width: 22px; height: 22px; border-radius: 50%; color: #777; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 10; }
.bg-toolbar { display: flex; justify-content: space-between; align-items: center; padding-top: 5px; }
.bg-tools-left, .bg-tools-right { display: flex; gap: 8px; align-items: center; }
.bg-tool-btn { background: transparent !important; border: none !important; cursor: pointer; padding: 6px !important; border-radius: 50% !important; color: #757575 !important; transition: all 0.2s; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.bg-tool-btn:hover { background: #f0f0f0 !important; color: #176CA1 !important; }
.bg-tool-btn.is-recording { color: #d63638 !important; background: rgba(214, 54, 56, 0.1) !important; animation: pulse 1.5s infinite; }
.bg-send-btn { background: #176CA1 !important; color: white !important; border: none !important; padding: 0 20px !important; height: 38px !important; border-radius: 19px !important; font-weight: 600 !important; font-size: 14px !important; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 3px 8px rgba(23, 108, 161, 0.3) !important; transition: transform 0.2s, background 0.2s !important; }
.bg-send-btn:hover { background: #135B88 !important; transform: translateY(-2px); box-shadow: 0 6px 15px rgba(19, 91, 136, 0.4) !important; }
.bg-send-btn:disabled { background: #176CA1 !important; opacity: 0.85; box-shadow: none !important; cursor: wait; transform: none; }
.bg-send-btn[style*="display: none"] { display: none !important; }
.bg-icon-svg svg { width: 16px; height: 16px; transition: transform 0.3s; }
.bg-loader { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s infinite linear; display: inline-block; }
.bg-manual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 10px; }
.bg-field label { display: block; font-size: 11px; font-weight: 600; color: #666; margin-bottom: 4px; }
.bg-select, .bg-input-small { width: 100% !important; padding: 6px !important; border: 1px solid #ddd !important; border-radius: 6px !important; font-size: 13px !important; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 600px) {
    .bg-btn-text { display: none !important; }
    .bg-send-btn { padding: 0 !important; width: 38px !important; height: 38px !important; justify-content: center !important; border-radius: 50% !important; }
    .bg-toolbar { flex-wrap: nowrap !important; }
}

/* --- LAYOUT ESPECIAL: BARRA FLOTANTE (ABSOLUTE) --- */
@media (min-width: 992px) {
    /* Forzar al contenedor padre de Houzez a ser relativo */
    .half-map-right-wrap { 
        position: relative !important;
        /* Padding superior para que la lista de propiedades no quede debajo de la barra */
        padding-top: 100px !important; 
    }

    /* CONTENEDOR DE LA BARRA GEMINI */
    .houzez-gemini-search-container {
        position: absolute !important; /* FLOTANTE DENTRO DEL CONTENEDOR */
        z-index: 999 !important;
        
        /* Posición y dimensiones */
        top: 20px !important; 
        left: 20px !important;
        right: 20px !important;
        width: auto !important;
    }
    
    .bg-search-box {
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 5px 20px rgba(0,0,0,0.1) !important;
    }

    /* OCULTAR FILTRO NATIVO DE HOUZEZ */
    .half-map-right-wrap .advanced-search, 
    .half-map-right-wrap .advanced-search-half-map,
    .half-map-right-wrap .search-expandable {
        display: none !important;
    }
}

/* --- HISTORIAL DE BÚSQUEDA --- */
#bg-history-container {
    display: none; 
    width: 100%;
    margin-top: 0; 
    
    background: rgba(255, 255, 255, 0.96); 
    backdrop-filter: blur(8px);
    
    border-radius: 0; 
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    border-bottom: none; 
    border-top: none; 
    
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 10px 15px 35px 15px; 
    flex-direction: column; 
    gap: 6px;
    animation: slideIn 0.2s ease-out; 
    z-index: 15; 
    position: relative; 
    top: -1px; 
    transition: border-color 0.2s ease;
}

/* CONFIGURACIÓN HALF MAP (Fondo Blanco Puro + Desvanecido) */
.bg-is-halfmap #bg-history-container {
    background: #ffffff !important;
    backdrop-filter: none;
    -webkit-mask-image: linear-gradient(to bottom, black 30px, transparent 100%);
    mask-image: linear-gradient(to bottom, black 30px, transparent 100%);
}

.bg-search-box:focus-within ~ #bg-history-container { border-color: #135B88 !important; }

.bg-history-item { display: flex; align-items: center; font-family: 'Inter', system-ui, sans-serif; font-size: 13px; font-weight: 500; color: #222; transition: all 0.3s ease; padding: 3px 0; }
.bg-history-item svg { margin-right: 10px; width: 14px; height: 14px; color: #176CA1; flex-shrink: 0; opacity: 0.9; }
.bg-history-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 95%; }
.bg-history-item:nth-child(1) { opacity: 0.95; font-weight: 600; }
.bg-history-item:nth-child(2) { opacity: 0.75; }
.bg-history-item:nth-child(3) { opacity: 0.55; }
.bg-history-item:nth-child(4) { opacity: 0.40; }