/* Chatbot Speed Bubble (the initial floating icon) */
#mxchat-speed-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #68fcff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: transform 0.3s ease, background-color 0.2s ease;
    pointer-events: auto;
}

#mxchat-speed-bubble:hover {
    background-color: #4ac9e6;
    transform: scale(1.1);
}

#mxchat-speed-bubble img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

#mxchat-speed-bubble.active {
    transform: scale(0);
}

/* Chatbot Main Window Container */
#mxchat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: min(500px, calc(100vh - 40px));
    max-height: calc(100vh - 40px);
    background-color: #f5f5f5;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 901;
    overflow: hidden;
}

/* When iOS keyboard is open, we translate the widget up by the keyboard offset */
#mxchat-widget-container.mxchat-avoid-keyboard {
    transform: translateY(calc(-1 * var(--mxchat-keyboard-offset, 0px)));
    will-change: transform;
}

#mxchat-widget-container.open {
    display: flex;
}

/* Header Section of Chat Window */
.mxchat-header {
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: #fff;
    padding: 15px 20px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 10px rgba(93, 209, 255, 0.959);
}

.mxchat-center-logo {
    position: relative;
    max-height: 40px;
    width: auto;
    max-width: 80%;
    object-fit: contain;
    z-index: 1;
}

/* Language Toggle */
.mxchat-language-toggle {
    display: flex;
    gap: 8px;
    padding: 8px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    justify-content: center;
    flex-shrink: 0;
    border-bottom: 1px solid #dee2e6;
}

.mxchat-lang-btn {
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: #fff;
    border: 2px solid transparent;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 8px rgba(104, 252, 255, 0.3);
    min-width: 80px;
    text-align: center;
}

.mxchat-lang-btn.active {
    background: linear-gradient(135deg, #4ac9e6 0%, #3ba8c4 100%);
    border: 2px solid #fff;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 201, 230, 0.4);
}

.mxchat-lang-btn:hover {
    background: linear-gradient(135deg, #4ac9e6 0%, #3ba8c4 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 201, 230, 0.4);
}

/* Close button */
.mxchat-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    font-size: 1.8em;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.mxchat-close-btn:hover {
    transform: scale(1.2) rotate(90deg);
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Display Area */
.mxchat-conversation {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    width: 100%; /* Ensure full width */
    box-sizing: border-box; /* Include padding in width calculation */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* Individual Message Bubbles */
.mxchat-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mxchat-message.bot {
    align-self: flex-start;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #2c3e50;
    border-bottom-left-radius: 2px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mxchat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: #fff;
    border-bottom-right-radius: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 8px rgba(104, 252, 255, 0.3);
}

/* Slightly bigger styling for contact info message */
.mxchat-message.bot.mxchat-contact-info {
    /* Do not change font size; instead allow wider bubble */
    max-width: 100%;
    line-height: 1.4;
}

/* Keep email on one line inside contact info */
.mxchat-message.bot.mxchat-contact-info a {
    white-space: nowrap;
}

/* Options List Styling */
.mxchat-option-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0; /* Add top margin to separate from message */
    width: 100%; /* Full width of container */
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Space between options */
    box-sizing: border-box; /* Include padding in width */
}

.mxchat-option-item {
    padding: 8px 12px;
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: #fff;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(104, 252, 255, 0.3);
    white-space: nowrap; /* Prevent text wrapping */
    max-width: 100%; /* Ensure it fits within container */
}

.mxchat-option-item:hover {
    background: linear-gradient(135deg, #4ac9e6 0%, #3ba8c4 100%);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 4px 12px rgba(74, 201, 230, 0.4);
}

.mxchat-option-item.clicked {
    background: linear-gradient(135deg, #3ba8c4 0%, #2e8b9e 100%);
    transform: scale(0.98);
}

/* Input Area */
.mxchat-input-area {
    display: flex;
    flex-direction: row; /* Changed to row for side-by-side layout */
    padding: 15px;
    border-top: 1px solid #eee;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    flex-shrink: 0;
    align-items: center;
    gap: 10px; /* Space between input and button */
    position: relative;
    min-height: 70px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.mxchat-input-row {
    display: flex;
    width: 100%;
    gap: 10px;
    align-items: center;
}

#mxchat-user-input {
    flex-grow: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    transition: all 0.3s ease;
    background: #fff;
}

/* Larger input appearance for email step */
#mxchat-user-input.mxchat-large-input {
    font-size: 1.05em;
    padding: 14px 18px;
}

#mxchat-user-input:focus {
    border-color: #68fcff;
    box-shadow: 0 0 0 3px rgba(104, 252, 255, 0.2);
    transform: scale(1.02);
}

/* Avoid iOS Safari keyboard/focus glitches when scaling inputs */
.mxchat-ios #mxchat-user-input:focus {
    transform: none;
}

#mxchat-user-input[readonly] {
    background-color: #f8f8f8;
    cursor: not-allowed;
}

/* Option Button Styling */
.mxchat-option-button {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #4ac9e6 0%, #3ba8c4 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(74, 201, 230, 0.3);
    position: relative;
    overflow: visible;
    margin-bottom: 8px;
    word-wrap: break-word;
    white-space: normal;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    user-select: none;
}

.mxchat-option-button:hover {
    background: linear-gradient(135deg, #3ba8c4 0%, #2e8b9e 100%);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 16px rgba(59, 168, 196, 0.4);
}

.mxchat-option-button:active {
    transform: scale(0.99);
}

#mxchat-options-container {
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 8px;
    order: 2;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#mxchat-submit-btn {
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(104, 252, 255, 0.3);
    position: relative;
    overflow: hidden;
    height: 46px; /* Match input height */
}

#mxchat-submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#mxchat-submit-btn:hover {
    background: linear-gradient(135deg, #4ac9e6 0%, #3ba8c4 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(74, 201, 230, 0.4);
}

#mxchat-submit-btn:hover::before {
    left: 100%;
}

#mxchat-submit-btn:active {
    transform: scale(0.98);
}

#mxchat-error-message {
    width: 100%;
    text-align: center;
    margin-top: 8px;
    font-size: 0.85em;
    font-weight: 600;
    color: #d32f2f;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    padding: 8px 12px;
    border-radius: 8px;
    order: 3;
    border: 1px solid #ef9a9a;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.2);
}

/* Footer and Promo Button */
.mxchat-footer {
    padding: 10px 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    flex-shrink: 0;
    border-top: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mxchat-footer-text {
    font-size: 0.8em;
    color: #6c757d;
}

.mxchat-branding-link {
    font-size: 0.8em;
    color: #68fcff;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mxchat-branding-link:hover {
    color: #4ac9e6;
    text-decoration: underline;
    transform: scale(1.05);
}

.mxchat-tail-logo {
    max-height: 20px;
    width: auto;
    opacity: 0.7;
}

.mxchat-promo-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #68fcff 0%, #4ac9e6 100%);
    color: white;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(104, 252, 255, 0.3);
    position: relative;
    overflow: hidden;
}

/* FIREWORK/BANG Animation */
@keyframes bang {
    from {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Confetti Container */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    #mxchat-widget-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    #mxchat-speed-bubble {
        bottom: 10px;
        right: 10px;
    }

    .mxchat-header,
    .mxchat-footer {
        border-radius: 0;
    }
}