/* ============================================
   MYER'S TRADE — Chat Hub
   AI Assistant + WhatsApp + Live Chat
   ============================================ */

/* --- Chat Launcher Button --- */
.chat-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}
.chat-launcher-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 25px rgba(201,169,110,0.4);
    transition: all 0.3s ease;
    position: relative;
}
.chat-launcher-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 35px rgba(201,169,110,0.6);
}
.chat-launcher-btn i {
    font-size: 1.6rem;
    color: var(--bg-primary);
    transition: transform 0.3s ease;
}
.chat-launcher-btn .icon-close { display: none; }
.chat-launcher.open .chat-launcher-btn .icon-chat { display: none; }
.chat-launcher.open .chat-launcher-btn .icon-close { display: block; }
.chat-launcher.open .chat-launcher-btn {
    background: var(--bg-tertiary);
    border: 1px solid rgba(201,169,110,0.3);
}
.chat-launcher.open .chat-launcher-btn i { color: var(--accent-gold); }

/* Notification dot */
.chat-launcher-btn::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ff4444;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    animation: notifPulse 2s ease infinite;
}
.chat-launcher.open .chat-launcher-btn::after,
.chat-launcher.seen .chat-launcher-btn::after { display: none; }
@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Greeting bubble */
.chat-greeting {
    background: var(--bg-tertiary);
    border: 1px solid rgba(201,169,110,0.15);
    color: var(--text-white);
    padding: 14px 20px;
    border-radius: 16px 16px 4px 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 280px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    animation: greetSlideIn 0.4s ease;
}
.chat-greeting:hover { border-color: rgba(201,169,110,0.4); }
.chat-greeting strong { color: var(--accent-gold); }
.chat-launcher.open .chat-greeting { display: none; }
.chat-greeting.dismissed { display: none; }
@keyframes greetSlideIn {
    from { opacity: 0; transform: translateY(10px) translateX(10px); }
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

/* --- Chat Panel --- */
.chat-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    max-height: 600px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: panelSlideUp 0.3s ease;
}
.chat-launcher.open .chat-panel { display: flex; }
@keyframes panelSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel Header */
.chat-header {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    padding: 20px 22px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.chat-header-logo {
    width: 40px;
    height: 40px;
    border: 1px solid var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    color: var(--accent-gold);
    flex-shrink: 0;
}
.chat-header-info h4 {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-white);
    margin-bottom: 2px;
}
.chat-header-info span {
    font-size: 0.72rem;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-header-info span::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #25D366;
    border-radius: 50%;
    display: inline-block;
}

/* Tab Bar */
.chat-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 3px;
}
.chat-tab {
    flex: 1;
    padding: 9px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
.chat-tab i { font-size: 0.8rem; }
.chat-tab:hover { color: var(--text-light); background: rgba(255,255,255,0.04); }
.chat-tab.active {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

/* --- Chat Body --- */
.chat-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
    max-height: 420px;
}
.chat-view.active { display: flex; }

/* ===== AI ASSISTANT TAB ===== */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(201,169,110,0.3) transparent;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(201,169,110,0.3); border-radius: 4px; }

.ai-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.84rem;
    line-height: 1.6;
    animation: msgFadeIn 0.3s ease;
}
@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg.bot {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-white);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}
.ai-msg.user {
    align-self: flex-end;
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}
.ai-msg a {
    color: var(--accent-gold);
    text-decoration: underline;
}
.ai-msg.user a { color: var(--bg-primary); }

/* Quick action chips */
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}
.ai-chip {
    padding: 7px 14px;
    background: rgba(201,169,110,0.1);
    border: 1px solid rgba(201,169,110,0.2);
    border-radius: 20px;
    color: var(--accent-gold);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.ai-chip:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-color: var(--accent-gold);
}

/* Typing indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--bg-tertiary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}
.ai-typing span {
    width: 7px;
    height: 7px;
    background: var(--accent-gold);
    border-radius: 50%;
    animation: typingBounce 1.4s ease infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* AI Input */
.ai-input-bar {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-primary);
}
.ai-input-bar input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 11px 16px;
    color: var(--text-white);
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
}
.ai-input-bar input:focus { border-color: rgba(201,169,110,0.4); }
.ai-input-bar input::placeholder { color: var(--text-muted); }
.ai-input-bar button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-gold);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.ai-input-bar button:hover { background: var(--accent-gold-light); }

/* ===== WHATSAPP TAB ===== */
.wa-view {
    padding: 22px 18px;
    overflow-y: auto;
}
.wa-agent {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.wa-agent-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
}
.wa-agent-info h4 {
    font-size: 0.92rem;
    color: var(--text-white);
    font-weight: 600;
    margin-bottom: 2px;
}
.wa-agent-info p {
    font-size: 0.75rem;
    color: var(--text-light);
}
.wa-agent-info .wa-status {
    font-size: 0.7rem;
    color: #25D366;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}
.wa-agent-info .wa-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #25D366;
    border-radius: 50%;
}

.wa-templates-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.wa-template {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    color: var(--text-white);
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    line-height: 1.5;
}
.wa-template:hover {
    border-color: rgba(37,211,102,0.3);
    background: rgba(37,211,102,0.05);
}
.wa-template i {
    color: #25D366;
    margin-right: 8px;
}

.wa-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    background: #25D366;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 18px;
}
.wa-open-btn:hover { background: #1fb855; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(37,211,102,0.4); }
.wa-open-btn i { font-size: 1.1rem; }

/* ===== LIVE CHAT TAB ===== */
.live-view {
    padding: 22px 18px;
    overflow-y: auto;
}
.live-intro {
    text-align: center;
    margin-bottom: 20px;
}
.live-intro-icon {
    width: 56px;
    height: 56px;
    background: rgba(201,169,110,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 1.4rem;
    color: var(--accent-gold);
}
.live-intro h4 {
    font-size: 1rem;
    color: var(--text-white);
    margin-bottom: 6px;
}
.live-intro p {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.6;
}

.live-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.live-form input,
.live-form textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-white);
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
}
.live-form input:focus,
.live-form textarea:focus { border-color: rgba(201,169,110,0.4); }
.live-form input::placeholder,
.live-form textarea::placeholder { color: var(--text-muted); }
.live-form textarea { resize: none; height: 90px; }
.live-form-submit {
    padding: 13px;
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.live-form-submit:hover { background: var(--accent-gold-light); }
.live-form-success {
    text-align: center;
    padding: 30px 10px;
    display: none;
}
.live-form-success i {
    font-size: 2.5rem;
    color: #25D366;
    margin-bottom: 14px;
}
.live-form-success h4 {
    font-size: 1rem;
    color: var(--text-white);
    margin-bottom: 8px;
}
.live-form-success p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* ===== EXIT INTENT POPUP ===== */
.exit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
    animation: exitFadeIn 0.3s ease;
}
.exit-overlay.show { display: flex; }
@keyframes exitFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.exit-popup {
    background: var(--bg-secondary);
    border: 1px solid rgba(201,169,110,0.2);
    border-radius: 20px;
    max-width: 440px;
    width: 90%;
    padding: 40px 36px;
    text-align: center;
    position: relative;
    animation: exitSlideUp 0.4s ease;
}
@keyframes exitSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.exit-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.exit-popup-close:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
.exit-popup-icon {
    width: 64px;
    height: 64px;
    background: rgba(201,169,110,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.6rem;
    color: var(--accent-gold);
}
.exit-popup h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--text-white);
    margin-bottom: 10px;
    line-height: 1.3;
}
.exit-popup h3 em { color: var(--accent-gold); font-style: italic; }
.exit-popup p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 24px;
}
.exit-form {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.exit-form input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: var(--text-white);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
}
.exit-form input:focus { border-color: rgba(201,169,110,0.4); }
.exit-form input::placeholder { color: var(--text-muted); }
.exit-form button {
    padding: 14px 24px;
    background: var(--accent-gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.exit-form button:hover { background: var(--accent-gold-light); }
.exit-popup .exit-skip {
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.2s ease;
}
.exit-popup .exit-skip:hover { color: var(--text-light); }

/* ===== QUICK QUOTE STICKY BAR ===== */
.quick-quote-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--accent-gold);
    color: var(--bg-primary);
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}
.quick-quote-bar.visible { transform: translateY(0); }
.quick-quote-bar span { display: flex; align-items: center; gap: 8px; }
.quick-quote-bar a {
    background: var(--bg-primary);
    color: var(--accent-gold);
    padding: 7px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s ease;
}
.quick-quote-bar a:hover { background: var(--bg-tertiary); }
.quick-quote-bar .qqb-close {
    background: none;
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}
.quick-quote-bar .qqb-close:hover { opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .chat-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
    }
    .chat-launcher {
        bottom: 20px;
        right: 20px;
    }
    .chat-launcher-btn {
        width: 58px;
        height: 58px;
    }
    .chat-greeting { max-width: 240px; font-size: 0.8rem; }
    .exit-form { flex-direction: column; }
    .quick-quote-bar { font-size: 0.75rem; gap: 12px; padding: 8px 15px; flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 480px) {
    .chat-view { max-height: 65vh; }
    .wa-template { font-size: 0.78rem; padding: 12px 14px; }
}
