/*
 * Sello de Tiempo: Domingo, 1 de Marzo de 2026, 08:00 CST.
 * Modificación: Glassmorphism para Barra Global y Cápsula Gris.
 */

#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; }

#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; }

#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: 250px; 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; }

/* --- GLASSMORPHISM GLOBAL PARA EL CONTENEDOR --- */
.bg-search-box { 
    background: rgba(255, 255, 255, 0.65) !important; 
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.8) !important; 
    border-radius: 16px; 
    box-shadow: 0 8px 32px rgba(0,0,0,0.1) !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: rgba(23, 108, 161, 0.5) !important; }

/* --- CÁPSULA GRIS PARA MODO BÚSQUEDA --- */
#bg-input.bg-main-input { 
    width: 100% !important; 
    border: 1px solid #d1d5db !important; 
    outline: none !important; 
    background: rgba(244, 245, 247, 0.9) !important; 
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02) !important; 
    margin: 0 !important; 
    padding: 12px 40px 12px 20px !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: 48px !important; 
    display: block; 
    border-radius: 24px !important; 
    transition: background 0.3s ease, border-color 0.3s ease; 
}
#bg-input.bg-main-input:focus { background: #ffffff !important; border-color: #176CA1 !important; }

/* MODO PUBLICAR */
.bg-publish-mode .bg-search-box { border-radius: 20px !important; padding: 15px 20px !important; box-shadow: 0 8px 32px rgba(0,0,0,0.1) !important; }
.bg-publish-mode #bg-input.bg-main-input { background: rgba(248, 249, 250, 0.85) !important; border-radius: 24px !important; min-height: 180px !important; padding: 16px 40px 16px 20px !important; margin-bottom: 5px !important; }
.bg-publish-mode #bg-input.bg-main-input.is-compact { min-height: 56px !important; height: 56px !important; overflow: hidden; }
.bg-publish-mode #bg-input.bg-main-input:focus { background: #ffffff !important; }
.bg-publish-mode .bg-toolbar { margin-top: 5px; }
.bg-publish-mode #bg-response-area { border: 1px solid rgba(0, 163, 42, 0.4); background: rgba(255, 255, 255, 0.85); }
.bg-publish-mode .bg-chat-bubble.ai-msg { background: #e6f6ea; border-color: #c3e6cb; color: #111; }

#bg-char-counter { position: absolute; bottom: 12px; right: 15px; font-size: 11px; color: #999; font-weight: 500; pointer-events: none; display: none; }
.bg-publish-mode #bg-char-counter { display: block; }

/* COLORES DE ALERTA */
.bg-empty-optional { background-color: #fffdf2 !important; border-color: #ffebb5 !important; }
.bg-empty-mandatory { background-color: #fdf0f0 !important; border-color: #f5c6cb !important; }

@media (max-width: 992px) and (min-width: 601px) {
    .bg-publish-mode .bg-desktop-text { display: none !important; }
    .bg-publish-mode .bg-tablet-text { display: inline-block !important; }
}

@media (max-width: 600px) {
    .bg-publish-mode #bg-input.bg-main-input { min-height: 220px !important; }
    .bg-publish-mode #bg-input.bg-main-input.is-compact { min-height: 56px !important; }
    .bg-publish-mode .bg-toolbar { flex-wrap: nowrap !important; gap: 5px; }
    .bg-publish-mode #bg-model-selector, .bg-publish-mode #bg-attach-btn { display: none !important; }
    .bg-publish-mode #bg-template-label { font-size: 0 !important; }
    .bg-publish-mode #bg-template-label::before { content: "Prompt"; font-size: 13px; visibility: visible; }
    .bg-publish-mode #bg-template-btn { padding: 0 12px !important; }
    .bg-publish-mode .bg-tools-left { flex: 1; justify-content: flex-start; min-width: 0; }
    .bg-publish-mode .bg-tools-right { flex-shrink: 0; justify-content: flex-end; }
    .bg-publish-mode .bg-desktop-text, .bg-publish-mode .bg-tablet-text { display: none !important; }
    .bg-publish-mode .bg-send-btn { width: 38px !important; height: 38px !important; padding: 0 !important; justify-content: center !important; }
}

.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; } }

.bg-input-area { width: 100% !important; margin-bottom: 5px; display: flex; position: relative; }
#bg-input.bg-main-input.has-scroll { overflow-y: auto !important; }
#bg-input::placeholder { color: #999 !important; }

/* Botón Limpiar ajustado para la cápsula */
#bg-clear-btn { position: absolute; right: 10px; top: 12px; background: #e4e6e9; border: none; width: 24px; height: 24px; border-radius: 50%; color: #777; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 10; }
#bg-clear-btn:hover { background: #d1d5db; color: #333; }

.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: #555 !important; transition: all 0.2s; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.bg-tool-btn:hover { background: rgba(0,0,0,0.05) !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-model-btn, #bg-template-btn { border-radius: 50px !important; border: none !important; background: transparent; transition: all 0.2s ease; padding: 0 16px !important; }
#bg-model-btn:hover, #bg-template-btn:hover { background: rgba(0,0,0,0.05) !important; }

.bg-send-btn { background: #176CA1 !important; color: white !important; border: none !important; padding: 0 20px !important; height: 38px !important; border-radius: 50px !important; font-weight: 600 !important; font-size: 14px !important; cursor: pointer; display: flex; align-items: center; justify-content: 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(3, 1fr); gap: 10px; margin-bottom: 10px; width: 100%; }
.bg-field { width: 100%; min-width: 0; }
.bg-field label { display: block; font-size: 11px; font-weight: 600; color: #555; margin-bottom: 4px; }
.bg-select, .bg-input-small { width: 100% !important; padding: 6px !important; border: 1px solid rgba(0,0,0,0.1) !important; border-radius: 6px !important; font-size: 13px !important; background: rgba(255,255,255,0.9) !important; }
.bg-active-filter { background-color: #e8f5e9 !important; border-color: #c8e6c9 !important; color: #2e7d32 !important; }
.bg-field .dropdown-toggle.bg-active-filter { background-color: #e8f5e9 !important; border: 1px solid #c8e6c9 !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(214, 54, 56, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0); } }

@media (min-width: 992px) {
    .half-map-right-wrap { position: relative !important; padding-top: 100px !important; }
    .houzez-gemini-search-container { position: absolute !important; z-index: 999 !important; top: 20px !important; left: 20px !important; right: 20px !important; width: auto !important; }
    .bg-search-box { background: rgba(255, 255, 255, 0.8) !important; backdrop-filter: blur(16px); box-shadow: 0 5px 20px rgba(0,0,0,0.1) !important; }
    .half-map-right-wrap .advanced-search, .half-map-right-wrap .advanced-search-half-map, .half-map-right-wrap .search-expandable { display: none !important; }
}

#bg-history-container { display: none; width: 100%; margin-top: 0; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); border-radius: 0; border-left: 1px solid rgba(255,255,255,0.5); border-right: 1px solid rgba(255,255,255,0.5); border-bottom: 1px solid rgba(255,255,255,0.5); border-top: none; box-shadow: 0 8px 24px rgba(0,0,0,0.1); padding: 10px 15px 15px 15px; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; animation: slideIn 0.2s ease-out; z-index: 15; position: relative; top: -1px; transition: border-color 0.2s ease; }
#bg-history-container::-webkit-scrollbar { display: none; }
.bg-search-box:focus-within ~ #bg-history-container { border-color: rgba(23, 108, 161, 0.5) !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.2s ease; padding: 10px 10px; border-radius: 6px; cursor: pointer; flex-shrink: 0; opacity: 1 !important; background-color: transparent; }
.bg-history-item:hover { background-color: rgba(23, 108, 161, 0.1); color: #176CA1; }
.bg-history-item svg { margin-right: 10px; width: 14px; height: 14px; color: #176CA1; flex-shrink: 0; }
.bg-history-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 95%; }

.bg-is-halfmap #bg-history-container { background: rgba(255,255,255,0.9) !important; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.5) !important; border-top: none !important; box-shadow: none !important; -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%); mask-image: linear-gradient(to bottom, black 50%, transparent 100%); pointer-events: auto; }
.bg-is-halfmap .bg-history-item { opacity: 1 !important; }
.bg-model-option { padding: 8px 16px; font-size: 13px; color: #444; cursor: pointer; font-family: 'Inter', system-ui, sans-serif; transition: background 0.2s; }
.bg-model-option:hover { background: rgba(0,0,0,0.05); }
.bg-tools-center { transition: opacity 0.3s; }
