/* ============================================================
   Spacenes AI Chat Widget — Luxury Emerald & Gold Theme
   ============================================================ */

/* ── Floating Button ── */
#spacenes-ai-btn {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 9998;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #033626 0%, #011c13 100%);
    border: 2px solid #D4AF37;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 32px rgba(3, 54, 38, 0.45), 0 0 12px rgba(212, 175, 55, 0.3);
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s ease;
    animation: ai-btn-pulse 3s ease-in-out infinite;
    outline: none;
}

#spacenes-ai-btn:hover {
    transform: scale(1.12) translateY(-3px);
    box-shadow: 0 16px 48px rgba(3, 54, 38, 0.55), 0 0 18px rgba(212, 175, 55, 0.5);
}

#spacenes-ai-btn:active {
    transform: scale(0.96);
}

#spacenes-ai-btn i {
    color: #E6C665;
    font-size: 24px;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

#spacenes-ai-btn .ai-btn-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #D4AF37, #AA7C11);
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    letter-spacing: 0.3px;
    font-family: 'Inter', sans-serif;
    border: 1.5px solid #fff;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

@keyframes ai-btn-pulse {
    0%, 100% { box-shadow: 0 10px 32px rgba(3, 54, 38, 0.45), 0 0 0 0 rgba(212, 175, 55, 0.4); }
    50% { box-shadow: 0 10px 32px rgba(3, 54, 38, 0.45), 0 0 0 12px rgba(212, 175, 55, 0); }
}

/* ── Chat Panel ── */
#spacenes-ai-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 410px;
    max-width: calc(100vw - 24px);
    height: 640px;
    max-height: calc(100vh - 120px);
    z-index: 9999;
    border-radius: 28px;
    background: #FAF7F2;
    border: 1px solid rgba(212, 175, 55, 0.35);
    box-shadow: 0 24px 60px rgba(2, 44, 30, 0.25), 0 4px 16px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease;
}

#spacenes-ai-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ── Panel Header ── */
.ai-panel-header {
    background: linear-gradient(135deg, #022c1e 0%, #011c13 100%);
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.ai-panel-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 300'%3E%3Cpath fill='none' stroke='rgba(212,175,55,0.18)' stroke-width='1.5' d='M-100,100 C150,20 350,250 800,50 M-50,200 C200,120 450,280 850,150 M0,50 C300,220 500,20 900,180'/%3E%3C/svg%3E");
    background-size: cover;
    opacity: 0.8;
    pointer-events: none;
}

.ai-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.35) 0%, rgba(2, 44, 30, 0.95) 100%);
    border: 2px solid #D4AF37;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 8px rgba(212, 175, 55, 0.3);
}

.ai-avatar i {
    color: #E6C665;
    font-size: 22px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.ai-avatar-sparkle {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    background: #FFF;
    border-radius: 50%;
    box-shadow: 0 0 6px 2px #D4AF37;
}

.ai-header-info {
    flex: 1;
    position: relative;
    z-index: 1;
}

.ai-header-info h3 {
    color: #FFFFFF;
    font-size: 17px;
    font-weight: 700;
    font-family: 'Outfit', 'Inter', sans-serif;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-title-gold {
    color: #E5C158;
}

.ai-star-sparkle {
    color: #E5C158;
    font-size: 13px;
}

.ai-header-info p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #22c55e;
    animation: ai-blink 2s ease-in-out infinite;
}

@keyframes ai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-close-btn {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* ── Quick Chips ── */
.ai-quick-chips {
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    flex-shrink: 0;
    background: #FAF7F2;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
    scrollbar-width: none;
}

.ai-quick-chips::-webkit-scrollbar { display: none; }

.ai-chip {
    background: #FFFFFF;
    color: #033626;
    border: 1px solid #EBD9B4;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.08);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
}

.ai-chip:hover {
    background: #FFFDF9;
    border-color: #D4AF37;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.18);
}

/* ── Messages Area ── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #FAF7F2;
    scrollbar-width: thin;
    scrollbar-color: rgba(212,175,55,0.3) transparent;
}

.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.3); border-radius: 2px; }

/* ── Message Bubbles ── */
.ai-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: ai-msg-in 0.3s ease-out;
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-msg-row.user {
    flex-direction: row-reverse;
}

.ai-msg-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #033626, #011c13);
    border: 1px solid #D4AF37;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-msg-icon i {
    color: #E6C665;
    font-size: 14px;
}

.ai-bubble {
    max-width: 84%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
}

.ai-msg-row.ai .ai-bubble {
    background: #FFFFFF;
    color: #102a1a;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-bottom-left-radius: 4px;
    box-shadow: 0 3px 10px rgba(3, 54, 38, 0.05);
}

.ai-msg-row.user .ai-bubble {
    background: linear-gradient(135deg, #033626 0%, #01241a 100%);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(3, 54, 38, 0.25);
}

/* ── Typing Indicator ── */
.ai-typing-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: ai-msg-in 0.3s ease-out;
}

.ai-typing-bubble {
    background: #FFFFFF;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 13px 18px;
    box-shadow: 0 3px 10px rgba(3, 54, 38, 0.05);
}

.ai-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.ai-typing-dots span {
    width: 7px;
    height: 7px;
    background: #D4AF37;
    border-radius: 50%;
    animation: ai-dot-bounce 1.2s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Property Cards in Chat ── */
.ai-property-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.ai-prop-card {
    background: #FFFFFF;
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
    box-shadow: 0 3px 10px rgba(3, 54, 38, 0.05);
}

.ai-prop-card:hover {
    border-color: #D4AF37;
    box-shadow: 0 8px 24px rgba(3, 54, 38, 0.15);
    transform: translateY(-2px);
}

.ai-prop-img {
    width: 84px;
    height: 76px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f7f3ed;
}

.ai-prop-img-placeholder {
    width: 84px;
    height: 76px;
    background: linear-gradient(135deg, #f7f3ed, #e9dfd0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-prop-img-placeholder i {
    color: #033626;
    font-size: 24px;
}

.ai-prop-info {
    padding: 9px 12px;
    flex: 1;
    min-width: 0;
}

.ai-prop-title {
    font-size: 13px;
    font-weight: 700;
    color: #033626;
    font-family: 'Inter', sans-serif;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-prop-location {
    font-size: 11px;
    color: #5A6660;
    font-family: 'Inter', sans-serif;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-prop-location i {
    color: #D4AF37;
    font-size: 9px;
}

.ai-prop-price {
    font-size: 12.5px;
    font-weight: 700;
    color: #033626;
    font-family: 'Inter', sans-serif;
}

.ai-prop-badges {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.ai-prop-badge {
    font-size: 9.5px;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    background: rgba(212, 175, 55, 0.12);
    color: #033626;
}

.ai-prop-arrow {
    padding: 0 12px 0 4px;
    color: #D4AF37;
    font-size: 14px;
    flex-shrink: 0;
}

/* ── Input Area ── */
.ai-input-area {
    padding: 14px 18px 16px;
    background: #FAF7F2;
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    flex-shrink: 0;
}

.ai-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #FFFFFF;
    border: 1.5px solid #034731;
    border-radius: 28px;
    padding: 6px 8px 6px 16px;
    box-shadow: 0 4px 14px rgba(3, 54, 38, 0.06);
    transition: all 0.25s ease;
}

.ai-input-row:focus-within {
    border-color: #033626;
    box-shadow: 0 4px 20px rgba(3, 54, 38, 0.15), 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.ai-input-sparkle {
    color: #00A86B;
    font-size: 15px;
    display: flex;
    align-items: center;
}

.ai-input-row textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    color: #102a1a;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 100px;
    line-height: 1.5;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 4px 0;
}

.ai-input-row textarea::placeholder {
    color: #76857f;
}

.ai-send-btn {
    background: linear-gradient(135deg, #033626 0%, #011f16 100%);
    color: #FFFFFF;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(3, 54, 38, 0.3);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.ai-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(3, 54, 38, 0.4);
}

.ai-send-btn:active {
    transform: scale(0.95);
}

.ai-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-input-hint {
    font-size: 11px;
    color: #6b7b75;
    font-family: 'Inter', sans-serif;
    margin-top: 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.ai-input-hint i {
    color: #034731;
    font-size: 11px;
}

/* ── Welcome State ── */
.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 30px 18px 16px;
    gap: 10px;
}

.ai-welcome-emblem-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.ai-welcome-emblem {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFFDF8 0%, #FFF5E5 100%);
    border: 3px solid #D4AF37;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.12), 0 8px 24px rgba(3, 54, 38, 0.12);
}

.ai-welcome-emblem i {
    font-size: 38px;
    color: #033626;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.ai-star-left, .ai-star-right {
    position: absolute;
    color: #D4AF37;
    font-size: 14px;
}

.ai-star-left { left: -22px; top: 35%; }
.ai-star-right { right: -22px; top: 35%; }

.ai-welcome h4 {
    font-size: 24px;
    font-weight: 700;
    color: #102a1a;
    font-family: 'Outfit', 'Inter', sans-serif;
}

.ai-welcome h4 .ai-title-bold {
    color: #033626;
    font-weight: 800;
}

.ai-welcome-divider {
    color: #D4AF37;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.8;
}

.ai-welcome-divider::before, .ai-welcome-divider::after {
    content: '';
    width: 36px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #D4AF37, transparent);
}

.ai-welcome p {
    font-size: 13.5px;
    color: #5A6660;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    max-width: 320px;
}

/* ── Error State ── */
.ai-error-bubble {
    background: #FFF5F5;
    border: 1px solid #FECACA;
    color: #DC2626;
    border-radius: 16px;
    padding: 11px 15px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-error-bubble i {
    font-size: 14px;
    flex-shrink: 0;
}

/* ── More Results Link ── */
.ai-more-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #033626;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    text-decoration: none;
    margin-top: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.25);
    transition: all 0.2s;
}

.ai-more-link:hover {
    background: rgba(212, 175, 55, 0.25);
    transform: translateX(2px);
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    #spacenes-ai-btn {
        bottom: 88px;
        right: 16px;
        width: 58px;
        height: 58px;
    }
    #spacenes-ai-panel {
        right: 0;
        bottom: 88px;
        width: 100%;
        max-width: 100%;
        height: 85vh;
        max-height: 85vh;
        border-radius: 28px 28px 0 0;
        border-bottom: none;
    }
}
