/* 
 * Master chatbot CSS
 * Updated to style both the "shortcode" chatbot (#ai-chatbot-crm-...)
 * and the "floating" chatbot (#ai-floating-chatbot-...).
 */

:root {
    --chat-bg-color: #f9f9f9;
    --text-color: #333333;
    --bot-bubble-bg: #f5f5f5;
    --bot-bubble-text: #333333;
    --user-bubble-bg: #e0f3ff;
    --user-bubble-text: #333333;
    --button-bg: #4CAF50;
    --button-text: #ffffff;
    --float-icon-bg: #0b93d5;
    --float-icon-color: #ffffff;
}

/* Container styling (both shortcode & floating) */
#ai-chatbot-crm-container,
#ai-floating-chatbot-container {
    background-color: var(--chat-bg-color);
    color: var(--text-color);
    border: 1px solid #ccc;
    padding: 20px;
    max-width: 700px;
    margin: 20px auto;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* The messages area (both) */
#ai-chatbot-crm-messages,
#ai-floating-chatbot-messages {
    height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    word-break: break-word;
    position: relative;
    margin-bottom: 10px;
}

/* Common chat message bubble class (shared by both). */
.ai-chatbot-crm-message {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.5;
    clear: both;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* user vs bot bubble colors */
.ai-chatbot-crm-message.user {
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-text);
    border-left: 3px solid #0b93d5;
    float: right;
    text-align: right;
}
.ai-chatbot-crm-message.bot {
    background-color: var(--bot-bubble-bg);
    color: var(--bot-bubble-text);
    border-left: 3px solid #66a1d2;
    float: left;
    text-align: left;
}
.ai-chatbot-crm-message a {
    color: #0066cc;
    text-decoration: underline;
}
.ai-chatbot-crm-message a:hover {
    text-decoration: none;
    color: #004a99;
}

/* The text input and send button row (both) */
#ai-chatbot-crm-input,
#ai-floating-chatbot-input {
    display: flex;
    align-items: flex-end;
}

/* The message textarea (both) */
#ai-chatbot-crm-message-input,
#ai-floating-chatbot-message-input {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    border-radius: 5px;
    border: 1px solid #ccc;
    resize: none;
    overflow: hidden;
}

/* The send & voice buttons (both) */
#ai-chatbot-crm-input button,
#ai-floating-chatbot-input button {
    padding: 8px 12px;
    font-size: 14px;
    margin-left: 5px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    height: 36px;
    box-sizing: border-box;
}
#ai-chatbot-crm-send-button,
#ai-floating-chatbot-send-button {
    background-color: var(--button-bg);
    color: var(--button-text);
}
.ai-chatbot-voice-btn {
    background-color: #f4c57a;
    color: white;
    transition: background-color 0.2s ease;
}
.ai-chatbot-voice-btn.ai-listening {
    background-color: #e53935 !important; /* indicate active listening */
}

/* Language & voice controls row (both) */
.ai-chatbot-crm-lang-voice-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}
.ai-chatbot-crm-lang-select,
.ai-chatbot-crm-audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* The user info form / initial screen (both) */
#ai-chatbot-crm-user-info,
#ai-floating-chatbot-user-info {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
}
.ai-chatbot-welcome-header h3 {
    margin: 0;
    padding: 0;
    font-size: 1.25em;
    color: #333;
}
.ai-chatbot-welcome-subtext {
    margin: 5px 0 10px;
    font-size: 0.95em;
    color: #666;
}
.ai-chatbot-user-form .ai-chatbot-form-field {
    margin-bottom: 10px;
}
.ai-chatbot-form-field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.95em;
}
.ai-chatbot-form-field input[type="text"],
.ai-chatbot-form-field input[type="email"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.ai-chatbot-consent {
    margin-top: 10px;
}
.ai-chatbot-start-btn {
    margin-top: 5px;
    background-color: var(--button-bg);
    color: var(--button-text) !important;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}
.ai-chatbot-start-btn:hover {
    opacity: 0.9;
}

/* The typing/listening indicators (both) */
#ai-chatbot-crm-typing-indicator,
#ai-floating-chatbot-typing-indicator,
#ai-chatbot-crm-listening-indicator,
#ai-floating-chatbot-listening-indicator {
    margin: 5px 0;
    clear: both;
    font-size: 0.95em;
    color: #666;
    display: none; /* default hidden, toggled in JS */
}

/* The help modal overlay styling is similarly applied. */
#ai-chatbot-crm-help-overlay,
#ai-floating-chatbot-help-overlay {
    display: none;
    position: fixed; 
    top:0; left:0; 
    width:100%; height:100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

/* Chatbot floating button & container */
.ai-chatbot-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    background-color: var(--float-icon-bg);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    text-align: center;
    line-height: 60px;
    color: var(--float-icon-color);
    font-size: 24px;
}
.ai-chatbot-float-icon {
    display: inline-block;
    vertical-align: middle;
}
.ai-chatbot-floating-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 9999;
    width: 360px;
    max-width: 90%;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    max-height: 90vh;
    overflow-y: auto;
}

/* Additional controls & rating UI inside each message. */
.ai-chatbot-crm-controls button {
    background: #eee;
    color: #333;
    border: 1px solid #ccc;
    margin-right: 3px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
}
.ai-chatbot-crm-rating {
    margin-top: 5px;
    display: inline-block;
    margin-left: 10px;
    vertical-align: middle;
}
.ai-chatbot-crm-rating button {
    background: #eee;
    color: #333;
    border: 1px solid #ccc;
    margin-left: 3px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
}
.button-danger {
    background: #dc3232;
    color: #fff;
    border: none;
    cursor: pointer;
}
