/* Scoped Chatbot UI */

:root {
    --rm-chat-launcher-bg: var(--accent-color, #0052cc);
    --rm-chat-launcher-hover: #b89223;
    
    /* Using actual fallback colors for the default light theme */
    --rm-chat-header-bg: var(--secondary-color, #0f172a);
    --rm-chat-header-text: #ffffff;
    --rm-chat-subtitle-text: rgba(255, 255, 255, 0.8);
    
    --rm-chat-panel-bg: var(--card-elevated, #ffffff);
    --rm-chat-panel-border: var(--border-color, #e1e4e8);
    
    --rm-chat-bg: var(--page-bg, #f7f9fa);
    
    --rm-chat-bot-bg: var(--card-bg, #ffffff);
    --rm-chat-bot-border: var(--border-color, #e1e4e8);
    --rm-chat-bot-text: var(--text-dark, #24292e);
    
    --rm-chat-user-bg: var(--primary-color, #1e293b);
    --rm-chat-user-text: #ffffff;
    
    --rm-chat-link-bg: var(--hover-surface, #e6f0ff);
    --rm-chat-link-text: var(--primary-color, #0052cc);
    --rm-chat-link-border: var(--border-color, #cce0ff);
    --rm-chat-link-hover: var(--alt-section-bg, #cce0ff);
    
    --rm-chat-btn-bg: var(--alt-section-bg, #f1f3f5);
    --rm-chat-btn-border: var(--border-color, #e1e4e8);
    --rm-chat-btn-text: var(--text-dark, #495057);
    --rm-chat-btn-hover: var(--border-color, #adb5bd);
    
    --rm-chat-primary-btn-bg: var(--accent-color, #d4af37);
    --rm-chat-primary-btn-text: #ffffff;
    
    --rm-chat-whatsapp-bg: var(--success-color, #25d366);
    --rm-chat-whatsapp-text: #ffffff;
    
    --rm-chat-input-area-bg: var(--card-bg, #ffffff);
    --rm-chat-input-bg: var(--card-elevated, #ffffff);
    --rm-chat-input-text: var(--text-dark, #24292e);
    --rm-chat-input-border: var(--border-color, #dcdfe6);
    --rm-chat-input-border-focus: var(--accent-color, #d4af37);
    
    --rm-chat-send-btn-bg: var(--primary-color, #1e293b);
    --rm-chat-send-btn-text: #ffffff;
    
    --rm-chat-form-bg: var(--card-elevated, #ffffff);
    --rm-chat-form-input-bg: var(--alt-section-bg, #ffffff);
    --rm-chat-form-text: var(--text-dark, #24292e);
    --rm-chat-form-submit-bg: var(--primary-color, #1e293b);
    --rm-chat-form-submit-text: #ffffff;
    --rm-chat-form-cancel: var(--text-light, #6a737d);
}

[data-theme="dark"] {
    --rm-chat-launcher-bg: var(--accent-color, #d4af37);
    --rm-chat-launcher-hover: #b89223;
    
    --rm-chat-header-bg: #121821; 
    --rm-chat-header-text: #f1f5f9;
    --rm-chat-subtitle-text: #cbd5e1;
    
    --rm-chat-panel-bg: #1a222c;
    --rm-chat-panel-border: #334155;
    
    --rm-chat-bg: #0B0F14;
    
    --rm-chat-bot-bg: #161D26;
    --rm-chat-bot-border: #334155;
    --rm-chat-bot-text: #f1f5f9;
    
    --rm-chat-user-bg: #1a4fb5; 
    --rm-chat-user-text: #ffffff;
    
    --rm-chat-link-bg: #1e293b;
    --rm-chat-link-text: #93c5fd;
    --rm-chat-link-border: #334155;
    --rm-chat-link-hover: #161D26;
    
    --rm-chat-btn-bg: #161D26;
    --rm-chat-btn-border: #334155;
    --rm-chat-btn-text: #cbd5e1;
    --rm-chat-btn-hover: #1e293b;
    
    --rm-chat-primary-btn-bg: #1a4fb5;
    --rm-chat-primary-btn-text: #ffffff;
    
    --rm-chat-whatsapp-bg: #20b558;
    --rm-chat-whatsapp-text: #ffffff;
    
    --rm-chat-input-area-bg: #1a222c;
    --rm-chat-input-bg: #0B0F14;
    --rm-chat-input-text: #f1f5f9;
    --rm-chat-input-border: #334155;
    --rm-chat-input-border-focus: #93c5fd;
    
    --rm-chat-send-btn-bg: var(--accent-color, #d4af37);
    --rm-chat-send-btn-text: #ffffff;
    
    --rm-chat-form-bg: #1a222c;
    --rm-chat-form-input-bg: #0B0F14;
    --rm-chat-form-text: #f1f5f9;
    --rm-chat-form-submit-bg: var(--accent-color, #d4af37);
    --rm-chat-form-submit-text: #ffffff;
    --rm-chat-form-cancel: #cbd5e1;
}

.rm-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);
}

.rm-chatbot-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--rm-chat-launcher-bg);
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s;
}

.rm-chatbot-launcher:hover {
    transform: scale(1.05);
    background: var(--rm-chat-launcher-hover);
}

.rm-chatbot-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    height: 540px;
    background: var(--rm-chat-panel-bg);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--rm-chat-panel-border);
}

.rm-chatbot-header {
    background: var(--rm-chat-header-bg);
    color: var(--rm-chat-header-text);
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rm-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-sans, sans-serif);
    color: inherit;
}

.rm-chatbot-subtitle {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--rm-chat-subtitle-text);
}

.rm-chatbot-close-btn {
    background: transparent;
    border: none;
    color: var(--rm-chat-header-text);
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
}
.rm-chatbot-close-btn:hover { opacity: 1; }

.rm-chatbot-messages {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--rm-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rm-message {
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.rm-message.rm-bot { align-self: flex-start; }
.rm-message.rm-bot .rm-message-text {
    background: var(--rm-chat-bot-bg);
    border: 1px solid var(--rm-chat-bot-border);
    color: var(--rm-chat-bot-text);
    padding: 12px 14px;
    border-radius: 12px 12px 12px 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.rm-message.rm-user { align-self: flex-end; }
.rm-message.rm-user .rm-message-text {
    background: var(--rm-chat-user-bg);
    color: var(--rm-chat-user-text);
    padding: 12px 14px;
    border-radius: 12px 12px 0 12px;
}

.rm-bot-links {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rm-bot-link-btn {
    display: inline-block;
    padding: 8px 12px;
    background: var(--rm-chat-link-bg);
    color: var(--rm-chat-link-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    border: 1px solid var(--rm-chat-link-border);
}
.rm-bot-link-btn:hover { background: var(--rm-chat-link-hover); border-color: var(--rm-chat-link-hover); }

.rm-chatbot-quick-actions {
    padding: 12px 16px;
    background: var(--rm-chat-input-area-bg);
    border-top: 1px solid var(--rm-chat-panel-border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rm-quick-btn {
    background: var(--rm-chat-btn-bg);
    border: 1px solid var(--rm-chat-btn-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    color: var(--rm-chat-btn-text);
    transition: all 0.2s ease;
}
.rm-quick-btn:hover { border-color: var(--rm-chat-btn-hover); }

.rm-quick-btn.rm-primary-action {
    background: var(--rm-chat-primary-btn-bg);
    color: var(--rm-chat-primary-btn-text);
    border-color: var(--rm-chat-primary-btn-bg);
    font-weight: 500;
}
.rm-quick-btn.rm-whatsapp-action {
    background: var(--rm-chat-whatsapp-bg);
    color: var(--rm-chat-whatsapp-text);
    border-color: var(--rm-chat-whatsapp-bg);
    display: flex;
    align-items: center;
    font-weight: 500;
}

.rm-chatbot-input-area {
    padding: 14px 16px;
    background: var(--rm-chat-input-area-bg);
    border-top: 1px solid var(--rm-chat-panel-border);
    display: flex;
    gap: 10px;
    align-items: center;
}

.rm-chatbot-input-area input {
    flex-grow: 1;
    background: var(--rm-chat-input-bg);
    color: var(--rm-chat-input-text);
    border: 1px solid var(--rm-chat-input-border);
    padding: 12px;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
}
.rm-chatbot-input-area input:focus { border-color: var(--rm-chat-input-border-focus); }

.rm-chatbot-input-area button {
    background: var(--rm-chat-send-btn-bg);
    color: var(--rm-chat-send-btn-text);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.rm-chatbot-lead-form {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--rm-chat-form-bg);
    padding: 24px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.rm-chatbot-lead-form h4 {
    margin: 0 0 16px;
    font-size: 18px;
    font-family: var(--font-sans, sans-serif);
    color: var(--rm-chat-form-text);
}

.rm-chatbot-lead-form input,
.rm-chatbot-lead-form select {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--rm-chat-form-input-bg);
    color: var(--rm-chat-form-text);
    border: 1px solid var(--rm-chat-panel-border);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.rm-chatbot-lead-form button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: var(--rm-chat-form-submit-bg);
    color: var(--rm-chat-form-submit-text);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}

.rm-cancel-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--rm-chat-form-cancel);
    border: none;
    cursor: pointer;
    font-size: 14px;
}

/* Typing Indicator Animation */
.rm-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: var(--rm-chat-bot-bg);
    border-radius: 12px 12px 12px 0;
    border: 1px solid var(--rm-chat-bot-border);
    align-self: flex-start;
}
.rm-dot {
    width: 6px;
    height: 6px;
    background: var(--rm-chat-form-cancel);
    border-radius: 50%;
    animation: rm-bounce 1.4s infinite ease-in-out both;
}
.rm-dot:nth-child(1) { animation-delay: -0.32s; }
.rm-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes rm-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .rm-chatbot-launcher {
        width: 50px;
        height: 50px;
    }
    
    .rm-chatbot-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        z-index: 9999999;
    }
    
    .rm-chatbot-header {
        border-radius: 0;
    }

    .rm-chatbot-lead-form {
        border-radius: 20px 20px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 24px);
    }
    
    .rm-chatbot-input-area {
        padding-bottom: env(safe-area-inset-bottom, 14px);
    }
}
