/* Chasbit AI Chatbot Styles */
:root {
    --chasbit-chat-primary-color: #25D366;
    --chasbit-chat-bot-msg-bg: #ECE5DD;
    --chasbit-chat-user-msg-bg: #DCF8C6;
    --chasbit-chat-user-msg-text: #333333;
    --chasbit-chat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Bubble Callout Container and Callout */
#chasbit-chat-bubble-container {
    /* position, bottom, right, z-index are set inline in PHP */
    /* display: flex; flex-direction: column; align-items: flex-end; are set inline in PHP */
}

#chasbit-chat-bubble-callout {
    background-color: var(--chasbit-chat-primary-color); 
    color: white; 
    padding: 10px 15px;
    padding-right: 35px; /* Space for close button */
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    position: relative; 
    max-width: 220px; 
    opacity: 0; /* Start hidden for animation */
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    display: none; /* JS will control this */
}
#chasbit-chat-bubble-callout.chasbit-callout-visible { /* Class added by JS to show */
    opacity: 1;
    transform: translateY(0) scale(1);
    display: block !important; /* Ensure it shows */
}

.chasbit-callout-text {
    display: block;
}

.chasbit-chat-bubble-callout-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    padding: 5px;
    cursor: pointer;
    transition: color 0.2s ease;
}
.chasbit-chat-bubble-callout-close:hover {
    color: white;
}

.chasbit-chat-bubble-callout-arrow {
    width: 0; height: 0; 
    border-left: 8px solid transparent; border-right: 8px solid transparent;
    border-top: 8px solid var(--chasbit-chat-primary-color);
    position: absolute;
    bottom: -8px; 
    right: 20px; /* Adjust this to point to your bubble icon */
    /* Or for centered arrow: left: 50%; transform: translateX(-50%); */
}


/* Main Chat Bubble Icon */
#chasbit-chat-bubble {
    /* position, bottom, right, z-index are on #chasbit-chat-bubble-container */
    background-color: var(--chasbit-chat-primary-color);
    color: white;
    padding: 10px 15px; /* Default if text is shown */
    border-radius: 25px; 
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex; /* Will be display:none if chat open or open by default */
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    font-family: var(--chasbit-chat-font);
    align-self: flex-end; /* Align to the end of the container if container is column flex */
    /* For a circular icon-only bubble, uncomment and adjust: */
    /* width: 50px; height: 50px; border-radius: 50%; padding: 0; */
}
#chasbit-chat-bubble:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(0,0,0,0.2); }
#chasbit-chat-bubble span { margin-right: 8px; font-size: 14px; font-weight: 500; /* display: none; for icon-only */ }
#chasbit-chat-bubble svg { fill: white; width: 20px; height: 20px; /* margin:0; for icon-only */ }


/* Chat Window (styles mostly unchanged from previous working version) */
#chasbit-chat-window {
    position: fixed; bottom: 20px; right: 20px;
    background-color: #ffffff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
    z-index: 99999; overflow: hidden; font-family: var(--chasbit-chat-font);
    /* Width and Max-height are set by inline styles from PHP */
}
#chasbit-chat-header { background-color: var(--chasbit-chat-primary-color); color: white; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; flex-shrink: 0; }
#chasbit-chat-header span { font-size: 16px; }
#chasbit-chat-close-btn { background: none; border: none; color: white; font-size: 26px; cursor: pointer; line-height: 1; padding: 0 5px; opacity: 0.8; transition: opacity 0.2s; }
#chasbit-chat-close-btn:hover { opacity: 1; }
#chasbit-chat-log { flex-grow: 1; overflow-y: auto; min-height: 0; padding: 15px; background-color: #f7f9fa; display: flex; flex-direction: column; gap: 10px; }
#chasbit-chat-log::-webkit-scrollbar { width: 6px; }
#chasbit-chat-log::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
#chasbit-chat-log::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
#chasbit-chat-log::-webkit-scrollbar-thumb:hover { background: #aaa; }
.chasbit-chat-message { padding: 10px 14px; border-radius: 18px; max-width: 85%; word-wrap: break-word; font-size: 14px; line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.chasbit-chat-message a { color: var(--chasbit-chat-primary-color); text-decoration: underline; }
.chasbit-chat-message ul, .chasbit-chat-message ol { margin-left: 20px; padding-left: 0; }
.chasbit-chat-message li { margin-bottom: 5px; }
.chasbit-chat-bot-message { background-color: var(--chasbit-chat-bot-msg-bg); color: #333; align-self: flex-start; border-bottom-left-radius: 5px; }
.chasbit-chat-bot-message.chasbit-typing-indicator { font-style: italic; color: #666; background-color: transparent; box-shadow: none; padding: 5px 10px; }
.chasbit-chat-user-message { background-color: var(--chasbit-chat-user-msg-bg); color: var(--chasbit-chat-user-msg-text); align-self: flex-end; border-bottom-right-radius: 5px; }
#chasbit-chat-input-area { display: flex; padding: 12px 15px; border-top: 1px solid #e0e0e0; background-color: #ffffff; align-items: center; flex-shrink: 0; }
#chasbit-chat-input { flex-grow: 1; border: 1px solid #d1d5db; border-radius: 20px; padding: 10px 18px; font-size: 14px; margin-right: 10px; transition: border-color 0.2s, box-shadow 0.2s; }
#chasbit-chat-input:focus { outline: none; border-color: var(--chasbit-chat-primary-color); box-shadow: 0 0 0 3px rgba(var(--chasbit-chat-primary-color-rgb, 37, 211, 102), 0.25); }
#chasbit-chat-send-btn { background-color: var(--chasbit-chat-primary-color); color: white; border: none; border-radius: 20px; padding: 8px 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s ease, transform 0.1s ease; font-size: 14px; font-weight: 500; min-width: 70px; text-align: center; }
#chasbit-chat-send-btn:hover { opacity: 0.9; }
#chasbit-chat-send-btn:active { transform: scale(0.98); }

@media (max-width: 480px) {
    #chasbit-chat-bubble-container { bottom: 15px; right: 15px; left: 15px; align-items: center; /* Center on mobile */ }
    #chasbit-chat-bubble-callout { /* Adjust callout for centered bubble on mobile */ right: auto; left: 50%; transform: translateX(-50%);}
    #chasbit-chat-bubble-callout .chasbit-chat-bubble-callout-arrow { /* Center arrow */ right: auto; left: 50%; transform: translateX(-50%); }
    #chasbit-chat-bubble { align-self: center; /* Center bubble in container */ }
    #chasbit-chat-window { width: calc(100vw - 20px) !important; bottom: 10px; right: 10px; left: 10px; border-radius: 10px; }
}

/* Pre-Chat Form Styles */
#chasbit-pre-chat-form-area {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0; /* Separator from chat log if shown simultaneously (though usually not) */
    background-color: #f9f9f9; /* Slightly different background */
    display: none; /* JS will control this based on settings and session state */
}
#chasbit-pre-chat-form-area.active { /* Class added by JS to show */
    display: block;
}
.chasbit-pre-chat-message {
    font-size: 14px;
    color: #555;
    margin-bottom: 10px;
    text-align: center;
}
#chasbit-pre-chat-form-area div {
    margin-bottom: 10px;
}
#chasbit-pre-chat-form-area label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 4px;
    color: #333;
}
#chasbit-pre-chat-form-area input[type="text"],
#chasbit-pre-chat-form-area input[type="email"] {
    width: calc(100% - 20px); /* Full width minus padding */
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
#chasbit-pre-chat-submit {
    background-color: var(--chasbit-chat-primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    transition: background-color 0.2s ease;
}
#chasbit-pre-chat-submit:hover {
    opacity: 0.9;
}
.chasbit-pre-chat-errors {
    font-size: 13px;
    padding-top: 5px;
}

/* Ensure chat log and input area are correctly displayed/hidden based on pre-chat form state */
#chasbit-chat-log {
    /* ... existing styles ... */
}
#chasbit-chat-input-area {
    /* ... existing styles ... */
    /* display: none; /* Initially hidden by JS if pre-chat is active */
}
#chasbit-chat-input-area.active { /* Class added by JS to show */
    display: flex !important; /* Ensure it overrides inline style if needed */
}