/* Xuân Long Chat Widget - Premium Design */
:root {
    --xl-primary: #1a6b3c;
    --xl-primary-light: #22874d;
    --xl-primary-dark: #0f4d2a;
    --xl-accent: #d4af37;
    --xl-bg: #f0f2f5;
    --xl-surface: #ffffff;
    --xl-text: #1a1a2e;
    --xl-text-secondary: #6b7280;
    --xl-user-bubble: #1a6b3c;
    --xl-bot-bubble: #ffffff;
    --xl-border: #e5e7eb;
    --xl-shadow: 0 8px 32px rgba(0,0,0,0.12);
    --xl-radius: 16px;
    --xl-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; }

/* Toggle Button */
.chat-toggle {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-dark));
    border: none; color: white; cursor: pointer;
    box-shadow: 0 4px 20px rgba(26,107,60,0.4);
    transition: var(--xl-transition);
    display: flex; align-items: center; justify-content: center;
}
.chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(26,107,60,0.5); }
.chat-toggle svg { width: 28px; height: 28px; }
.chat-toggle .badge {
    position: absolute; top: -4px; right: -4px;
    background: #ef4444; color: white; font-size: 11px; font-weight: 700;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* Chat Window */
.chat-window {
    position: fixed; bottom: 96px; right: 24px; z-index: 9998;
    width: 400px; height: 600px; max-height: calc(100vh - 120px);
    background: var(--xl-bg); border-radius: var(--xl-radius);
    box-shadow: var(--xl-shadow);
    display: flex; flex-direction: column; overflow: hidden;
    transition: var(--xl-transition);
    transform-origin: bottom right;
}
.chat-window.hidden {
    opacity: 0; transform: scale(0.8) translateY(20px); pointer-events: none;
}
@media (max-width: 480px) {
    .chat-window { width: 100vw; height: 100vh; max-height: 100vh; bottom: 0; right: 0; border-radius: 0; }
    .chat-toggle { bottom: 16px; right: 16px; }
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-dark));
    color: white; padding: 16px 20px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.header-info { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.2); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; letter-spacing: 1px;
}
.header-title { font-size: 16px; font-weight: 700; }
.header-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.header-actions { display: flex; gap: 8px; }
.action-btn {
    background: rgba(255,255,255,0.15); border: none; color: white;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
    font-size: 16px; transition: var(--xl-transition);
    display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: rgba(255,255,255,0.25); }

/* Messages */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.welcome-msg { text-align: center; padding: 24px 16px; }
.welcome-avatar { font-size: 48px; margin-bottom: 12px; }
.welcome-msg h2 { font-size: 18px; color: var(--xl-primary); margin-bottom: 6px; }
.welcome-msg p { color: var(--xl-text-secondary); font-size: 14px; margin-bottom: 20px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quick-btn {
    background: white; border: 1.5px solid var(--xl-border); border-radius: 20px;
    padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--xl-text);
    transition: var(--xl-transition); font-family: inherit;
}
.quick-btn:hover { border-color: var(--xl-primary); color: var(--xl-primary); background: #f0fdf4; }

/* Message Bubbles */
.message { display: flex; margin-bottom: 12px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; margin-top: 2px;
}
.message.assistant .msg-avatar { background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-light)); color: white; margin-right: 8px; }
.message.user .msg-avatar { display: none; }
.msg-content {
    max-width: 80%; padding: 10px 14px; border-radius: 16px;
    font-size: 14px; line-height: 1.55; word-wrap: break-word;
    white-space: pre-wrap;
}
.message.user .msg-content {
    background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-light));
    color: white; border-bottom-right-radius: 4px;
}
.message.assistant .msg-content {
    background: var(--xl-bot-bubble); color: var(--xl-text);
    border: 1px solid var(--xl-border); border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.msg-time {
    font-size: 10px; color: var(--xl-text-secondary);
    margin-top: 4px; text-align: right;
}
.message.assistant .msg-time { text-align: left; margin-left: 40px; }

/* Typing indicator */
.typing { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.typing .msg-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.typing-dots { display: flex; gap: 4px; padding: 12px 16px; background: white; border-radius: 16px; border: 1px solid var(--xl-border); }
.typing-dots span { width: 7px; height: 7px; background: #aaa; border-radius: 50%; animation: bounce 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* Input */
.chat-input-area { padding: 12px 16px 8px; background: white; border-top: 1px solid var(--xl-border); flex-shrink: 0; }
.input-wrapper {
    display: flex; align-items: flex-end; gap: 8px;
    background: var(--xl-bg); border-radius: 24px; padding: 4px 4px 4px 16px;
    border: 1.5px solid var(--xl-border); transition: var(--xl-transition);
}
.input-wrapper:focus-within { border-color: var(--xl-primary); box-shadow: 0 0 0 3px rgba(26,107,60,0.1); }
#chat-input {
    flex: 1; border: none; background: none; resize: none;
    font-size: 14px; font-family: inherit; color: var(--xl-text);
    padding: 8px 0; max-height: 100px; outline: none;
}
.send-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-light));
    color: white; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: var(--xl-transition);
}
.send-btn:hover { transform: scale(1.05); }
.send-btn svg { width: 18px; height: 18px; }
.input-footer { text-align: center; font-size: 11px; color: #bbb; margin-top: 6px; }

/* Modal */
.modal {
    position: absolute; inset: 0; background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center; z-index: 10;
    backdrop-filter: blur(4px); transition: var(--xl-transition);
}
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-content {
    background: white; border-radius: var(--xl-radius); width: 90%; max-height: 90%;
    overflow-y: auto; box-shadow: var(--xl-shadow);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--xl-border);
}
.modal-header h3 { font-size: 16px; color: var(--xl-primary); }
.modal-close {
    background: none; border: none; font-size: 20px; cursor: pointer; color: #999;
    width: 32px; height: 32px; border-radius: 8px; transition: var(--xl-transition);
}
.modal-close:hover { background: var(--xl-bg); }
.modal-body { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--xl-text); margin-bottom: 6px; }
.form-group input, .form-group select {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--xl-border);
    border-radius: 10px; font-size: 14px; font-family: inherit;
    transition: var(--xl-transition); outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--xl-primary); box-shadow: 0 0 0 3px rgba(26,107,60,0.1); }
.gender-select { display: flex; gap: 8px; }
.gender-btn {
    flex: 1; padding: 10px; border: 1.5px solid var(--xl-border); border-radius: 10px;
    background: white; cursor: pointer; font-size: 14px; font-family: inherit;
    transition: var(--xl-transition);
}
.gender-btn.active { border-color: var(--xl-primary); background: #f0fdf4; color: var(--xl-primary); font-weight: 600; }
.fs-check-btn {
    width: 100%; padding: 12px; background: linear-gradient(135deg, var(--xl-primary), var(--xl-primary-light));
    color: white; border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: var(--xl-transition); font-family: inherit;
}
.fs-check-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,107,60,0.3); }
.fs-result { padding: 20px; border-top: 1px solid var(--xl-border); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.fs-result.hidden { display: none; }
