/**
 * Conversational Chatbot Stylesheet
 * Contains modal overlay, message history, bubble styles, mascot animations, and typing indicators.
 */

.xd-chat-modal-overlay {
    --chat-blue: #005eff;
    --chat-green: #beff01;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.xd-chat-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.xd-chat-modal {
    width: 90%;
    max-width: 480px;
    height: 580px;
    background: var(--bg-secondary, #151d30);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
html[data-theme="light"] .xd-chat-modal {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}
.xd-chat-modal-overlay.active .xd-chat-modal {
    transform: translateY(0) scale(1);
}

/* Mobile close button */
.xd-chat-mobile-close {
    display: none;
}

/* Header */
.xd-chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    display: flex;
    justify-content: space-between;
    align-items: center;
}
html[data-theme="light"] .xd-chat-header {
    border-color: rgba(0, 0, 0, 0.08);
}
.xd-chat-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.xd-chat-status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--chat-green);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px rgba(190, 255, 1, 0.8);
    animation: status-pulse 2s infinite ease-in-out;
}
@keyframes status-pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}
.xd-chat-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
html[data-theme="light"] .xd-chat-title {
    color: #0f172a;
}
.xd-chat-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s ease;
}
.xd-chat-close-btn:hover {
    color: var(--text-primary, #fff);
}
html[data-theme="light"] .xd-chat-close-btn:hover {
    color: #0f172a;
}

/* Chat History Area */
.xd-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.xd-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}
.xd-message.ai {
    align-self: flex-start;
}
.xd-message.user {
    align-self: flex-end;
}
.xd-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.xd-message.ai .xd-message-bubble {
    background: var(--bg-primary, #0b0f19);
    color: var(--text-secondary, #cbd5e1);
    border-top-left-radius: 4px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.04));
}
html[data-theme="light"] .xd-message.ai .xd-message-bubble {
    background: #f1f5f9;
    color: #334155;
    border-color: rgba(0, 0, 0, 0.04);
}
.xd-message.user .xd-message-bubble {
    background: var(--chat-blue);
    color: #ffffff;
    border-top-right-radius: 4px;
}

/* Interactive Input Options */
.xd-chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}
.xd-option-btn {
    background: transparent;
    border: 1px solid var(--chat-blue);
    color: var(--text-primary, #fff);
    padding: 8px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}
html[data-theme="light"] .xd-option-btn {
    color: #334155;
    border-color: var(--chat-blue);
}
.xd-option-btn:hover {
    background: var(--chat-green);
    color: #0b0f19 !important;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(190, 255, 1, 0.3);
}

/* Typing Indicator */
.xd-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-primary, #0b0f19);
    border-radius: 12px;
    width: fit-content;
}
html[data-theme="light"] .xd-typing-indicator {
    background: #f1f5f9;
}
.xd-typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted, #64748b);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.xd-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.xd-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Footer / Input Area */
.xd-chat-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    background: var(--bg-secondary, #151d30);
    display: flex;
    gap: 10px;
}
html[data-theme="light"] .xd-chat-footer {
    border-color: rgba(0, 0, 0, 0.08);
    background: #ffffff;
}
.xd-chat-input {
    flex: 1;
    background: var(--bg-primary, #0b0f19);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    color: var(--text-primary, #fff);
    padding: 10px 16px;
    border-radius: 30px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}
html[data-theme="light"] .xd-chat-input {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}
.xd-chat-input:focus {
    border-color: var(--chat-blue);
}
.xd-chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chat-blue);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}
.xd-chat-send-btn:hover {
    background: var(--chat-green);
    color: #0b0f19;
    transform: scale(1.05);
}
.xd-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Greeting Mascot Layout */
.xd-chat-greeting-box {
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
    margin-bottom: 12px;
    width: 100%;
}
.xd-chat-mascot-wrap {
    width: 115px;
    height: 115px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.xd-chat-mascot {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0, 94, 255, 0.3));
    animation: mascot-float 4s ease-in-out infinite;
}
.xd-chat-speech-bubble {
    flex: 1;
    max-width: 290px;
    background: var(--bg-primary, #0b0f19);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 16px;
    padding: 12px 14px;
    position: relative;
    border-bottom-left-radius: 4px;
}
html[data-theme="light"] .xd-chat-speech-bubble {
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.08);
}
@keyframes mascot-float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

/* Responsive Mobile Styles */
@media (max-width: 768px) {
    /* Hide top header to save space */
    .xd-chat-header {
        display: none !important;
    }
    /* Custom close button in top right of messages or body */
    .xd-chat-mobile-close {
        display: flex !important;
        position: absolute;
        top: 15px;
        right: 15px;
        z-index: 9999;
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 50%;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        backdrop-filter: blur(4px);
    }
    html[data-theme="light"] .xd-chat-mobile-close {
        background: rgba(255, 255, 255, 0.8);
        border-color: rgba(0, 0, 0, 0.1);
        color: #0f172a;
    }
    .xd-chat-modal {
        height: 100%;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }
    /* Keep Mascot and Speech bubble side-by-side on mobile */
    .xd-chat-greeting-box {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-top: 10px;
    }
    .xd-chat-mascot-wrap {
        width: 65px;
        height: 65px;
        position: relative;
        top: 0;
        left: 0;
        z-index: 2;
        border-radius: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }
    .xd-chat-speech-bubble {
        margin-top: 0;
        flex: 1;
        max-width: calc(100% - 73px); /* 65px mascot + 8px gap */
        border-bottom-left-radius: 4px;
        border-top-left-radius: 16px;
    }
    
    /* Make options wrap like tags on mobile (similar to desktop) but more compact */
    .xd-chat-options {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    .xd-option-btn {
        width: auto;
        text-align: center;
        padding: 6px 12px;
        font-size: 12px;
    }
}
