/* Travellin Travel Assistant — 1:1 design integration (real backend). */
:root {
    --tv-blue-main: #1d4ed8;
    --tv-blue-light: #2563eb;
    --tv-blue-bg: #eff6ff;
    --tv-gray-bg: #f8fafc;
    --tv-text-dark: #0f172a;
    --tv-text-muted: #64748b;
    --tv-radius: 20px;
}

#tv-ai-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 1. COLLAPSED FLOATING BAR */
#tv-ai-collapsed-bar {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--tv-blue-main);
    color: #fff;
    padding: 10px 18px 10px 12px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(29, 78, 216, 0.4);
    transition: transform 0.2s;
    border: none;
}
#tv-ai-collapsed-bar:hover { transform: translateY(-2px); }

.tv-avatar-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    background: #fff;
    color: var(--tv-blue-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tv-avatar-wrap svg { width: 22px; height: 22px; }
.tv-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
}
.tv-bar-info { text-align: left; line-height: 1.2; }
.tv-bar-title { font-weight: 700; font-size: 0.95rem; display: block; }
.tv-bar-status { font-size: 0.75rem; opacity: 0.9; display: flex; align-items: center; gap: 4px; }
.tv-dot { width: 6px; height: 6px; background: #22c55e; border-radius: 50%; display: inline-block; }
.tv-unread-badge {
    background: #ef4444;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
}

/* 2. WELCOME CARD */
.tv-card-popover {
    display: none;
    width: 280px;
    background: #fff;
    padding: 24px;
    border-radius: 24px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15);
    text-align: center;
    position: relative;
}
.tv-close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--tv-text-muted);
    cursor: pointer;
}
.tv-welcome-avatar {
    width: 64px;
    height: 64px;
    background: var(--tv-blue-main);
    color: #fff;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tv-welcome-avatar svg { width: 36px; height: 36px; }
.tv-card-popover h3 { font-size: 1.25rem; color: var(--tv-text-dark); margin: 0 0 8px; line-height: 1.3; }
.tv-card-popover p { font-size: 0.9rem; color: var(--tv-text-muted); margin: 0 0 20px; }
.tv-btn-primary {
    width: 100%;
    background: var(--tv-blue-main);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
}
.tv-btn-primary:hover { background: var(--tv-blue-light); }

/* 3. EXPANDED CHAT WINDOW */
#tv-ai-chat-window {
    display: none;
    width: 380px;
    height: 620px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    flex-direction: column;
    overflow: hidden;
}
.tv-chat-header {
    background: var(--tv-blue-main);
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tv-header-user { display: flex; align-items: center; gap: 12px; }
.tv-header-user h4 { margin: 0; font-size: 1rem; color: #fff; }
.tv-header-user span { font-size: 0.75rem; opacity: 0.9; }
.tv-green { color: #4ade80; }
.tv-header-actions button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}

.tv-chat-body {
    flex: 1;
    padding: 16px;
    background: var(--tv-gray-bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.tv-msg { display: flex; gap: 10px; max-width: 85%; }
.tv-msg-bot { align-self: flex-start; }
.tv-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.tv-msg-avatar {
    width: 32px;
    height: 32px;
    background: var(--tv-blue-main);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tv-msg-avatar svg { width: 18px; height: 18px; }

.tv-msg-content {
    background: #fff;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.tv-msg-user .tv-msg-content {
    background: var(--tv-blue-main);
    color: #fff;
}
.tv-msg p { margin: 0; font-size: 0.88rem; line-height: 1.4; }
.tv-msg a { color: inherit; }
.tv-time { font-size: 0.68rem; color: var(--tv-text-muted); display: block; margin-top: 4px; }
.tv-msg-user .tv-time { color: rgba(255,255,255,0.8); text-align: right; }

/* Deals button after a bot reply */
.tv-deals-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    background: var(--tv-blue-bg);
    color: var(--tv-blue-main);
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.tv-deals-btn:hover { background: #dbeafe; }

/* Typing indicator */
.tv-typing .tv-msg-content { display: flex; gap: 4px; align-items: center; }
.tv-typing span.tv-typing-dot {
    width: 7px; height: 7px; background: #cbd5e1; border-radius: 50%;
    animation: tv-bounce 1.2s infinite ease-in-out;
}
.tv-typing span.tv-typing-dot:nth-child(2) { animation-delay: .15s; }
.tv-typing span.tv-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes tv-bounce { 0%,80%,100%{ transform: scale(.6); opacity:.5 } 40%{ transform: scale(1); opacity:1 } }

.tv-quick-chips {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}
.tv-quick-chips button {
    white-space: nowrap;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--tv-blue-main);
    font-weight: 600;
    cursor: pointer;
}
.tv-quick-chips button:hover { background: var(--tv-blue-bg); }

.tv-chat-input-area { padding: 12px 16px; background: #fff; }
.tv-input-box {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 4px 8px 4px 16px;
}
.tv-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.88rem;
    color: var(--tv-text-dark);
}

/* Buttons hardened against theme/Elementor global button styles. */
#tv-ai-root .tv-attach-btn {
    background: none !important;
    border: none !important;
    color: var(--tv-text-muted) !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    flex: 0 0 auto !important;
    padding: 0 !important;
    box-shadow: none !important;
}
#tv-ai-root .tv-attach-btn svg { width: 20px; height: 20px; display: block; }
#tv-ai-root .tv-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex: 0 0 auto !important;
    padding: 0 !important;
    background: var(--tv-blue-main) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
}
#tv-ai-root .tv-send-btn svg { width: 18px !important; height: 18px !important; display: block; fill: #fff; }
.tv-input-footer { font-size: 0.68rem; color: var(--tv-text-muted); text-align: center; margin-top: 8px; }

/* IN-ASSISTANT "HOW I CAN HELP YOU" GRID */
.tv-help-block { margin-top: 2px; }
.tv-help-title { font-size: 0.8rem; font-weight: 700; color: var(--tv-text-muted); margin: 2px 2px 8px; }
.tv-help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tv-help-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
    padding: 12px 10px; text-align: center; cursor: pointer;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    font-family: inherit;
}
.tv-help-card:hover { border-color: var(--tv-blue-main); transform: translateY(-2px); box-shadow: 0 8px 16px -6px rgba(29,78,216,.15); }
.tv-help-icon { font-size: 1.4rem; margin-bottom: 6px; line-height: 1; }
.tv-help-card h4 { font-size: 0.82rem; margin: 0 0 4px; color: var(--tv-text-dark); }
.tv-help-card p { font-size: 0.7rem; color: var(--tv-text-muted); margin: 0; line-height: 1.25; }

/* STATE CONTROLS */
.tv-state-collapsed #tv-ai-collapsed-bar { display: flex; }
.tv-state-welcome #tv-ai-welcome-card { display: block; }
.tv-state-chat #tv-ai-chat-window { display: flex; }

/* RESPONSIVE MOBILE VIEW */
@media (max-width: 480px) {
    #tv-ai-root { bottom: 16px; right: 16px; }
    #tv-ai-chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
    }
}

/* Assistant settings panel (Phase 3) */
#tv-ai-gear { background: none; border: none; color: #fff; font-size: 1.1rem; cursor: pointer; padding: 0 6px; line-height: 1; }
.tv-settings { background: #fff; border-top: 1px solid #f1f5f9; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.tv-settings-title { font-size: 0.8rem; font-weight: 700; color: var(--tv-text-muted); }
.tv-set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.85rem; color: var(--tv-text-dark); }
.tv-set-row select { flex: 0 0 auto; max-width: 60%; padding: 6px 8px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.85rem; background: #fff; }
.tv-set-check { justify-content: flex-start; gap: 8px; }
.tv-set-check input { flex: 0 0 auto; }
.tv-set-reset { align-self: flex-start; background: #f1f5f9; border: 1px solid #e2e8f0; color: #0f172a; border-radius: 10px; padding: 8px 14px; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.tv-set-reset:hover { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

/* RTL: assistant flips to the bottom-left */
html[dir="rtl"] #tv-ai-root { right: auto; left: 24px; }
html[dir="rtl"] .tv-msg-user { flex-direction: row; align-self: flex-start; }
html[dir="rtl"] .tv-msg-bot { flex-direction: row-reverse; align-self: flex-end; }
