/**
 * AI Exam Live Chat Frontend Styles
 */
#ai-exam-chat-root {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#ai-exam-chat-root.ai-exam-chat-position-right {
    right: 24px;
}

#ai-exam-chat-root.ai-exam-chat-position-left {
    left: 24px;
}

/* Chat Trigger Button */
#ai-exam-chat-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1b74e4;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    position: relative;
}

#ai-exam-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.ai-chat-unread-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Chat Window */
#ai-exam-chat-window {
    position: absolute;
    bottom: 75px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiChatSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#ai-exam-chat-root.ai-exam-chat-position-right #ai-exam-chat-window {
    right: 0;
}

#ai-exam-chat-root.ai-exam-chat-position-left #ai-exam-chat-window {
    left: 0;
}

@keyframes aiChatSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ai-chat-header {
    background: #1b74e4;
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #fff;
}

.ai-chat-titles h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.ai-chat-mode-badge {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 3px;
    font-weight: 500;
}

.ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#ai-chat-switch-mode-btn {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

#ai-chat-switch-mode-btn:hover {
    background: rgba(255, 255, 255, 0.38);
}

#ai-chat-minimize-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.85;
}

#ai-chat-minimize-btn:hover {
    opacity: 1;
}

/* Messages Body */
.ai-chat-messages-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    word-break: break-word;
}

.ai-msg-visitor {
    align-self: flex-end;
}

.ai-msg-visitor .ai-msg-bubble {
    background: #1b74e4;
    color: #ffffff;
    border-radius: 16px 16px 2px 16px;
    padding: 10px 14px;
    font-size: 13.5px;
    box-shadow: 0 1px 3px rgba(27, 116, 228, 0.25);
}

.ai-msg-ai, .ai-msg-human {
    align-self: flex-start;
}

.ai-msg-ai .ai-msg-bubble, .ai-msg-human .ai-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border-radius: 16px 16px 16px 2px;
    padding: 10px 14px;
    font-size: 13.5px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-msg-sender-label {
    font-size: 10px;
    color: #94a3b8;
    margin-bottom: 2px;
    padding-left: 4px;
}

.ai-msg-bubble p {
    margin: 0 0 6px 0;
}

.ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-msg-bubble ul, .ai-msg-bubble ol {
    margin: 4px 0;
    padding-left: 18px;
}

.ai-msg-bubble a {
    color: #1b74e4;
    text-decoration: underline;
    font-weight: 600;
}

/* Quick Suggestion Chips */
.ai-quick-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ai-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    border-radius: 14px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.ai-chip:hover {
    background: #1b74e4;
    color: #ffffff;
    border-color: #1b74e4;
    transform: translateY(-1px);
}

.ai-chip.ai-chip-human {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
    font-weight: 600;
}

.ai-chip.ai-chip-human:hover {
    background: #f59e0b;
    color: #ffffff;
    border-color: #f59e0b;
}

/* Product & Exam Cards */
.ai-product-cards-wrap {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-product-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.ai-product-card:hover {
    transform: translateY(-2px);
    border-color: #1b74e4;
}

.ai-product-card-title {
    font-weight: 700;
    font-size: 13px;
    color: #0f172a;
    line-height: 1.3;
}

.ai-product-card-price {
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}

.ai-product-card-excerpt {
    font-size: 11.5px;
    color: #64748b;
    line-height: 1.3;
}

.ai-product-card-btn {
    display: inline-block;
    text-align: center;
    background: #1b74e4;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 4px;
    transition: background 0.15s ease;
}

.ai-product-card-btn:hover {
    background: #155bb5;
}

/* Typing Indicator */
.ai-chat-typing-indicator {
    padding: 8px 16px;
    background: #f1f5f9;
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid #e2e8f0;
}

.ai-chat-typing-indicator .dot {
    width: 5px;
    height: 5px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiBlink 1.2s infinite ease-in-out;
}

.ai-chat-typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* Footer / Input Bar */
.ai-chat-footer {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
}

#ai-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s ease;
    background: #f8fafc;
}

#ai-chat-input:focus {
    border-color: #1b74e4;
    background: #ffffff;
}

#ai-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1b74e4;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

#ai-chat-send-btn:hover {
    background: #155bb5;
    transform: scale(1.05);
}

@media (max-width: 480px) {
    #ai-exam-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 10px !important;
        left: 10px !important;
    }
}
