/* ==========================================================================
   JARVIS TECH - INTERACTIVE FAQ CHATBOT & LEAD WIDGET
   ========================================================================== */
:root {
    --chat-primary: #059669;
    --chat-primary-hover: #047857;
    --chat-dark: #0f172a;
    --chat-header-bg: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    --chat-accent: #10b981;
    --chat-bg: #ffffff;
    --chat-border: #e2e8f0;
    --chat-bubble-bot: #ffffff;
    --chat-bubble-user: #059669;
    --chat-text-main: #1e293b;
    --chat-text-muted: #64748b;
}

.jarvis-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* Teaser Speech Bubble */
.jarvis-chat-teaser {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 285px;
    background: #ffffff;
    color: var(--chat-text-main);
    padding: 12px 14px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--chat-border);
    font-size: 13px;
    line-height: 1.45;
    animation: jarvisChatPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    user-select: none;
}

.jarvis-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 32px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #ffffff transparent;
}

.jarvis-chat-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 15px;
    color: #94a3b8;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 4px;
}
.jarvis-chat-teaser-close:hover { color: #334155; background: #f1f5f9; }

/* Floating Launcher Button */
.jarvis-chat-launcher {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 8px 18px 8px 10px;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.38);
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}
.jarvis-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(16, 185, 129, 0.48);
}

.jarvis-chat-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}
.jarvis-chat-icon-wrap svg { width: 24px; height: 24px; fill: #ffffff; }

.jarvis-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.jarvis-chat-label-box {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.jarvis-chat-label-title { font-size: 14px; font-weight: 700; line-height: 1.25; }
.jarvis-chat-label-sub {
    font-size: 11px;
    color: #d1fae5;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.jarvis-chat-pulse-dot {
    width: 7px;
    height: 7px;
    background: #a7f3d0;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #6ee7b7;
    animation: jarvisPulse 2s infinite;
}

/* Chat Modal Window */
.jarvis-chat-modal {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.28);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 999999;
    border: 1px solid var(--chat-border);
    animation: jarvisChatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.jarvis-chat-modal.is-open { display: flex; }

/* Chat Header */
.jarvis-chat-header {
    background: var(--chat-header-bg);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.jarvis-chat-header-profile { display: flex; align-items: center; gap: 10px; }
.jarvis-chat-header-avatar {
    width: 40px;
    height: 40px;
    background: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.35);
}
.jarvis-chat-header-meta h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}
.jarvis-chat-header-meta p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #a7f3d0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.jarvis-chat-header-actions { display: flex; align-items: center; gap: 6px; }
.jarvis-header-action-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.85;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.2s;
}
.jarvis-header-action-btn:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* Navigation Tabs */
.jarvis-chat-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}
.jarvis-chat-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--chat-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}
.jarvis-chat-tab.active {
    color: var(--chat-primary);
    background: #ffffff;
    border-bottom: 2px solid var(--chat-primary);
}

/* Chat View Panels */
.jarvis-chat-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.jarvis-chat-panel.active { display: flex; }

/* Thread / Message Area */
.jarvis-chat-thread {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jarvis-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: jarvisMsgIn 0.25s ease-out;
}
.jarvis-msg.bot { align-self: flex-start; }
.jarvis-msg.user { align-self: flex-end; }

.jarvis-msg-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.jarvis-msg.bot .jarvis-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.jarvis-msg.user .jarvis-msg-bubble {
    background: var(--chat-bubble-user);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.jarvis-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
}
.jarvis-msg.bot .jarvis-msg-time { align-self: flex-start; }
.jarvis-msg.user .jarvis-msg-time { align-self: flex-end; }

/* Typing animation */
.jarvis-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    width: fit-content;
    margin-bottom: 6px;
}
.jarvis-typing-dots span {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    animation: jarvisTyping 1.2s infinite ease-in-out;
}
.jarvis-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.jarvis-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* FAQ Quick Chips list */
.jarvis-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.jarvis-chip-btn {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    line-height: 1.3;
}
.jarvis-chip-btn:hover {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
    transform: translateY(-1px);
}

/* Chat Input Bar */
.jarvis-chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}
.jarvis-chat-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.jarvis-chat-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}
.jarvis-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #10b981;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.jarvis-chat-send-btn:hover { background: #059669; }
.jarvis-chat-send-btn svg { width: 16px; height: 16px; fill: #ffffff; }

/* Lead Form View inside Modal */
.jarvis-lead-panel-content {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
    background: #f8fafc;
}
.jarvis-form-group { margin-bottom: 12px; }
.jarvis-form-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.jarvis-form-label .req { color: #ef4444; }
.jarvis-form-input, .jarvis-form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    color: #0f172a;
    background: #ffffff;
    box-sizing: border-box;
    font-family: inherit;
}
.jarvis-form-input:focus, .jarvis-form-textarea:focus {
    border-color: #10b981;
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}
.jarvis-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    background: #ffffff;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.jarvis-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #334155;
    cursor: pointer;
}
.jarvis-checkbox-item input[type="checkbox"] {
    accent-color: #10b981;
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.jarvis-submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.jarvis-submit-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Success View */
.jarvis-chat-success {
    display: none;
    text-align: center;
    padding: 24px 12px;
}
.jarvis-success-icon {
    width: 52px;
    height: 52px;
    background: #d1fae5;
    color: #059669;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    margin: 0 auto 14px;
}
.jarvis-success-title { font-size: 16px; font-weight: 800; color: #0f172a; margin-bottom: 6px; }
.jarvis-success-desc { font-size: 12.5px; color: #475569; line-height: 1.5; margin-bottom: 16px; }
.jarvis-reset-btn {
    background: #e2e8f0;
    color: #334155;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* Direct Channels Footer */
.jarvis-chat-channels {
    padding: 10px 14px;
    background: #f1f5f9;
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.jarvis-chat-channels-title { font-size: 11px; font-weight: 700; color: #64748b; }
.jarvis-chat-channel-btns { display: flex; gap: 6px; }
.jarvis-channel-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.2s;
}
.jarvis-channel-btn.zalo { background: #0068ff; color: #ffffff; }
.jarvis-channel-btn.hotline { background: #ea580c; color: #ffffff; }
.jarvis-channel-btn:hover { opacity: 0.9; transform: translateY(-1px); }

@keyframes jarvisChatPop { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes jarvisChatSlideUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes jarvisMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes jarvisPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(110, 231, 183, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}
@keyframes jarvisTyping { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

@media (max-width: 480px) {
    .jarvis-chat-container { bottom: 16px; right: 16px; }
    .jarvis-chat-modal { right: 16px; bottom: 84px; width: calc(100vw - 32px); height: calc(100vh - 110px); }
    .jarvis-chat-label-box { display: none; }
    .jarvis-chat-launcher { padding: 8px; border-radius: 50%; }
    .jarvis-chat-icon-wrap { margin-right: 0; }
}
