/* =============================================
   Modern Florida Home Staging — Chat Widget
   Brand: #ceae54 gold | #1a1a1a black | #efe8e0 cream | #ffffff white
   ============================================= */

/* ---- Widget container (must be transparent) ---- */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: transparent !important;
}

/* ---- Backdrop ---- */
.chatbot-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5) !important;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.chatbot-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* ---- Floating Trigger Button ---- */
.chatbot-trigger {
    position: relative;
    height: 52px;
    padding: 0 20px 0 16px;
    border-radius: 26px;
    background: #ffffff !important;
    border: 2px solid #ceae54;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 0 rgba(206,174,84,0);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1a1a1a !important;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: all 0.3s ease;
    animation: chatPulse 3s ease-in-out infinite;
}
@keyframes chatPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 0 rgba(206,174,84,0.5); }
    50%       { box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 8px rgba(206,174,84,0); }
}
.chatbot-trigger:hover {
    background: #ceae54 !important;
    border-color: #ceae54;
    color: #1a1a1a !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(206,174,84,0.4);
    animation: none;
}
.chatbot-trigger.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}
.chatbot-trigger__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: #1a1a1a;
    transition: color 0.3s;
}
.chatbot-trigger__label { line-height: 1; }

/* ---- Badge ---- */
.chatbot-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: #ceae54 !important;
    color: #1a1a1a !important;
    font-size: 11px;
    font-weight: 700;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

/* ---- Chat Window ---- */
.chatbot-window {
    position: fixed;
    bottom: 20px; right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: #ffffff !important;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.85) translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}
.chatbot-window.size-small  { width: 380px; height: 600px; }
.chatbot-window.size-medium { width: 760px; height: 600px; }
.chatbot-window.size-large  { width: 80vw; height: 90vh; top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); }
.chatbot-window.size-large.open { transform: translate(-50%, -50%) scale(1); }
.chatbot-window.open { opacity: 1; transform: scale(1) translateY(0); pointer-events: all; }
.chatbot-window.minimized .chatbot-body,
.chatbot-window.minimized .chatbot-footer { display: none; }
.chatbot-window.minimized { height: auto; }

/* ---- Header ---- */
.chatbot-header {
    background: #ceae54 !important;
    color: #1a1a1a !important;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: none;
}
.chatbot-header-left { display: flex; align-items: center; gap: 12px; }
.chatbot-logo {
    width: 40px; height: 40px;
    border-radius: 6px;
    background: transparent !important;
    padding: 0;
    object-fit: cover;
    display: block;
}
.chatbot-header-text h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a !important;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.02em;
}
.chatbot-status {
    font-size: 11px;
    color: rgba(0,0,0,0.6) !important;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Montserrat', sans-serif;
}
.status-dot {
    width: 6px; height: 6px;
    background: #1a1a1a !important;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.chatbot-header-actions { display: flex; gap: 4px; }
.chatbot-minimize,
.chatbot-close {
    background: transparent !important;
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    color: rgba(0,0,0,0.65) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    opacity: 0.8;
}
.chatbot-minimize:hover,
.chatbot-close:hover {
    background: rgba(0,0,0,0.12) !important;
    color: #1a1a1a !important;
    opacity: 1;
}

/* ---- Body ---- */
.chatbot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7f5f2 !important;
    position: relative;
    overflow: hidden;
}


/* ---- Welcome Screen ---- */
.chatbot-welcome { text-align: center; padding: 24px 20px; }
.chatbot-welcome h4 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a !important;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: -0.01em;
}
.chatbot-welcome p {
    margin: 0 0 20px;
    color: #3a3a3a !important;
    font-size: 0.9rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
}
.welcome-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.suggestion-btn {
    background: #ffffff !important;
    border: 1px solid #ceae54;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    text-align: left;
    color: #1a1a1a !important;
}
.suggestion-btn:hover {
    background: #ceae54 !important;
    border-color: #ceae54;
    color: #1a1a1a !important;
    transform: translateX(4px);
}

/* ---- Messages ---- */
.chatbot-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f7f5f2 !important;
}
.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-track { background: #f7f5f2 !important; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #ceae54 !important; border-radius: 4px; }
.messages-container { display: flex; flex-direction: column; gap: 16px; }
.messages-spacer { height: 18px; flex-shrink: 0; }

.message { display: flex; gap: 12px; animation: slideIn 0.3s ease; }
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.message-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #1a1a1a !important;
    color: #ceae54 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    font-family: 'Montserrat', sans-serif;
    border: 1px solid #ceae54;
}
.message.user .message-avatar {
    background: #ceae54 !important;
    color: #1a1a1a !important;
    border-color: #ceae54;
}
.message-content {
    flex: 1;
    background: #ffffff !important;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    line-height: 1.6;
    font-size: 14px;
    color: #1a1a1a !important;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
}
.message.user .message-content {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

/* ---- AI-Generated Content ---- */
.message-content div, .message-content .ai-response { color: inherit; background: transparent !important; }
.message-content h1,.message-content h2,.message-content h3,
.message-content h4,.message-content h5,.message-content h6 {
    color: #1a1a1a !important;
    margin: 0.75rem 0 0.4rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
}
.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.1em; }
.message-content p  { color: #1a1a1a !important; margin: 0.4rem 0; line-height: 1.6; }
.message-content ul,.message-content ol { color: #1a1a1a !important; margin: 0.4rem 0; padding-left: 1.5rem; }
.message-content li { color: #1a1a1a !important; margin: 0.2rem 0; }
.message-content a  { color: #ceae54 !important; text-decoration: underline; }
.message-content a:hover { color: #1a1a1a !important; }
.message-content strong, .message-content b { color: #1a1a1a !important; font-weight: 700; }
.message-content em, .message-content i { color: #1a1a1a !important; }
.message-content code { background: #efe8e0 !important; color: #1a1a1a !important; padding: 0.2em 0.4em; border-radius: 4px; font-size: 0.88em; }
.message-content pre  { background: #1a1a1a !important; color: #efe8e0 !important; padding: 1rem; border-radius: 8px; overflow-x: auto; margin: 0.75rem 0; }
.message-content pre code { background: transparent !important; color: #efe8e0 !important; padding: 0; }
.message-content blockquote { background: #efe8e0 !important; color: #5a5a5a !important; border-left: 3px solid #ceae54; padding: 0.75rem 1rem; margin: 0.75rem 0; border-radius: 0 6px 6px 0; }
.message-content table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; background: #ffffff !important; }
.message-content th { background: #1a1a1a !important; color: #ceae54 !important; font-weight: 600; padding: 0.5rem; border: 1px solid #ceae54; }
.message-content td { background: #ffffff !important; color: #1a1a1a !important; padding: 0.5rem; border: 1px solid #efe8e0; }
.message-content hr { border: none; border-top: 1px solid #efe8e0; margin: 1rem 0; }
.message-content span { color: inherit; }
.message-content button { background: #ceae54 !important; color: #1a1a1a !important; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-family: 'Montserrat', sans-serif; font-weight: 600; }
.message-content button:hover { opacity: 0.85; }

/* Images */
.message-content img { max-width: 100%; height: auto; display: block; border-radius: 8px; margin: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.message-content .image-container { max-width: 350px; margin: 0.75rem 0; }
.message-content .image-container img { max-width: 100%; width: 100%; }
.message-content > div:has(> .image-container + .image-container),
.message-content .images-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.message-content > div:has(> .image-container + .image-container) .image-container,
.message-content .images-grid .image-container { flex: 1 1 calc(50% - 0.5rem); min-width: 200px; max-width: 280px; margin: 0; }
.message-content .image-text-flex { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.chatbot-window.size-small .message-content .image-container { max-width: 100%; }
.chatbot-window.size-small .message-content > div:has(> .image-container + .image-container) .image-container,
.chatbot-window.size-small .message-content .images-grid .image-container { flex: 1 1 100%; max-width: 100%; }
.chatbot-window.size-medium .message-content .image-container { max-width: 300px; }
.chatbot-window.size-medium .message-content > div:has(> .image-container + .image-container) .image-container,
.chatbot-window.size-medium .message-content .images-grid .image-container { flex: 1 1 calc(50% - 0.5rem); max-width: 240px; }
.chatbot-window.size-large .message-content .image-container { max-width: 350px; }
.chatbot-window.size-large .message-content > div:has(> .image-container + .image-container) .image-container,
.chatbot-window.size-large .message-content .images-grid .image-container { flex: 1 1 calc(33.333% - 0.75rem); max-width: 280px; }
.chatbot-window.size-medium .message-content .image-text-flex,
.chatbot-window.size-large  .message-content .image-text-flex { flex-direction: row; align-items: flex-start; }
.chatbot-window.size-medium .message-content .image-text-flex img,
.chatbot-window.size-large  .message-content .image-text-flex img { max-width: 250px; flex-shrink: 0; }

/* User message text always white */
.message.user .message-content h1,.message.user .message-content h2,
.message.user .message-content h3,.message.user .message-content h4,
.message.user .message-content p,.message.user .message-content li,
.message.user .message-content strong,.message.user .message-content em,
.message.user .message-content span,.message.user .message-content div,
.message.user .message-content a { color: #ffffff !important; }
.message.user .message-content code { background: rgba(255,255,255,0.15) !important; color: #ffffff !important; }
.message.user .message-content pre  { background: rgba(255,255,255,0.1) !important; color: #ffffff !important; }

/* ---- Scroll to Bottom ---- */
.scroll-to-bottom {
    position: absolute;
    bottom: 80px; right: 20px;
    width: 36px; height: 36px;
    background: #ffffff !important;
    border: 1px solid #ceae54;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
    color: #ceae54 !important;
}
.scroll-to-bottom:hover { background: #ceae54 !important; color: #1a1a1a !important; transform: translateY(-2px); }
.scroll-to-bottom.hidden { opacity: 0; pointer-events: none; }

/* ---- Footer ---- */
.chatbot-footer {
    padding: 14px 16px;
    background: #ffffff !important;
    border-top: 1px solid #efe8e0;
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}
.chatbot-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chatbot-form { display: flex; gap: 8px; align-items: flex-end; }

/* ---- Input ---- */
.chatbot-input {
    flex: 1;
    border: 1.5px solid #efe8e0;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    resize: none;
    min-height: 42px;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    background: #f7f5f2 !important;
    color: #1a1a1a !important;
    overflow-y: hidden;
}
.chatbot-input:focus { border-color: #ceae54; }
.chatbot-input::placeholder { color: #aaa; }

/* ---- Send Button ---- */
.chatbot-send {
    width: 42px; height: 42px;
    background: #ceae54 !important;
    border: none;
    border-radius: 22px;
    color: #1a1a1a !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.chatbot-send:hover:not(:disabled) { background: #1a1a1a !important; color: #ceae54 !important; transform: scale(1.05); }

/* ---- Branding Footer ---- */
.chatbot-branding {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.06);
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.6;
}
.chatbot-branding em {
    font-style: normal;
    color: #5a5a5a !important;
}
.chatbot-branding a {
    color: #5a5a5a !important;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.chatbot-branding a:hover {
    color: #ceae54 !important;
}
.chatbot-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Tool Indicators ---- */
.tool-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(206, 174, 84, 0.1) !important;
    border-left: 3px solid #ceae54;
    border-radius: 6px;
    font-size: 14px;
    color: #5a5a5a !important;
}

.tool-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ceae54;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.tool-spinner.complete {
    border: 2px solid #28a745;
    border-top-color: #28a745;
    animation: none;
    position: relative;
}

.tool-spinner.complete::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #28a745;
    font-size: 12px;
    font-weight: bold;
}

.tool-spinner.error {
    border: 2px solid #dc3545;
    border-top-color: #dc3545;
    animation: none;
    position: relative;
}

.tool-spinner.error::after {
    content: '✗';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #dc3545;
    font-size: 12px;
    font-weight: bold;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.tool-name {
    font-weight: 500;
    color: #1a1a1a !important;
}

.chatbot-powered { text-align: center; font-size: 10px; color: #bbb !important; margin-top: 8px; font-family: 'Montserrat', sans-serif; }

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .chatbot-widget { bottom: 80px; }
    .chatbot-window,
    .chatbot-window.size-small,
    .chatbot-window.size-medium,
    .chatbot-window.size-large {
        width: 100% !important; height: 100dvh !important;
        max-width: 100vw !important; max-height: 100dvh !important;
        bottom: 0 !important; right: 0 !important; top: 0 !important; left: 0 !important;
        border-radius: 0 !important; transform: none !important; position: fixed !important;
    }
    .chatbot-window.size-large.open { transform: none !important; }
    .chatbot-backdrop { display: none !important; }
    .chatbot-header { border-radius: 0; padding: 12px 16px; }
    .chatbot-footer { border-radius: 0; padding: 12px 16px; }
    .chatbot-messages { padding: 12px; }
    .chatbot-minimize { display: none !important; }
    .service-grid { grid-template-columns: 1fr !important; gap: 0.75rem; margin: 0.75rem 0; }
    .messages-container { gap: 12px; }
    .message-content .image-container { max-width: 100%; }
    .message-content > div:has(> .image-container + .image-container) .image-container,
    .message-content .images-grid .image-container { flex: 1 1 100%; max-width: 100%; }
    .message-content .image-text-flex { flex-direction: column !important; }
}

/* Contact capture form */
.contact-capture-form input {
    font-family: 'Montserrat', sans-serif !important;
}

.contact-capture-form button:hover {
    opacity: 0.9;
}

/* System messages */
.message.system .message-content {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}
