/* ========================================================
   VNDOOR AI CONSULTANT CHAT WIDGET (NATURAL & INTERACTIVE)
   ======================================================== */

:root {
    --ai-primary: #007cc2;
    --ai-primary-dark: #005a8e;
    --ai-gradient: linear-gradient(135deg, #0c2340 0%, #007cc2 100%);
    --ai-bg-light: #f8fafc;
    --ai-bubble-user: #007cc2;
    --ai-bubble-ai: #ffffff;
    --ai-text-dark: #1e293b;
    --ai-text-muted: #64748b;
    --ai-shadow: 0 16px 40px -4px rgba(12, 35, 64, 0.28), 0 4px 16px -2px rgba(12, 35, 64, 0.15);
    --ai-radius: 18px;
}

/* Floating Launcher Button */
.vnd-chat-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vnd-chat-launcher:hover {
    transform: translateY(-4px) scale(1.03);
}

.vnd-chat-launcher-pill {
    background: #ffffff;
    color: #0c2340;
    padding: 9px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: vndPillFloat 3s ease-in-out infinite;
    pointer-events: none;
    white-space: nowrap;
}

.vnd-chat-launcher-pill .pulse-dot {
    width: 9px;
    height: 9px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
}

.vnd-chat-launcher-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--ai-gradient);
    border: 3px solid #ffffff;
    box-shadow: 0 8px 25px rgba(0, 124, 194, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.vnd-chat-launcher-btn svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

.vnd-chat-launcher.open .vnd-chat-launcher-btn {
    background: #e11d48;
    transform: rotate(90deg);
    box-shadow: 0 8px 24px rgba(225, 29, 72, 0.4);
}

.vnd-chat-launcher.open .vnd-chat-launcher-pill {
    display: none;
}

/* Chat Dialog Window */
.vnd-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid rgba(226, 232, 240, 0.95);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vnd-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.vnd-chat-header {
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.vnd-header-agent {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vnd-agent-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid #38bdf8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.vnd-agent-avatar svg {
    width: 24px;
    height: 24px;
    color: var(--ai-primary);
}

.vnd-agent-avatar .status-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #ffffff;
}

.vnd-agent-meta h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.vnd-agent-meta span {
    font-size: 11px;
    color: #bae6fd;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.vnd-agent-meta span::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

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

.vnd-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.vnd-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Booking Lead Banner */
.vnd-chat-booking-banner {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    padding: 7px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 600;
    color: #92400e;
}

.btn-lead-pill {
    background: #d97706;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-lead-pill:hover {
    background: #b45309;
}

/* Chat Messages Container */
.vnd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* Message Item */
.vnd-msg-row {
    display: flex;
    gap: 10px;
    max-width: 90%;
}

.vnd-msg-row.ai {
    align-self: flex-start;
}

.vnd-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.vnd-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.vnd-msg-avatar.ai-icon {
    background: #0c2340;
    color: #38bdf8;
}

.vnd-msg-bubble {
    padding: 12px 15px;
    border-radius: 15px;
    font-size: 13.5px;
    line-height: 1.55;
    position: relative;
    word-break: break-word;
}

.vnd-msg-row.ai .vnd-msg-bubble {
    background: #ffffff;
    color: var(--ai-text-dark);
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.vnd-msg-row.user .vnd-msg-bubble {
    background: var(--ai-primary);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 124, 194, 0.28);
}

.vnd-msg-bubble p {
    margin: 0 0 8px 0;
}

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

.vnd-msg-bubble strong {
    font-weight: 700;
}

.vnd-msg-bubble a {
    color: #007cc2;
    text-decoration: underline;
    font-weight: 600;
}

.vnd-msg-row.user .vnd-msg-bubble a {
    color: #ffffff;
}

/* Chat Product Cards in AI Reply */
.vnd-chat-products {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.vnd-chat-product-item {
    display: flex;
    gap: 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.vnd-chat-product-item:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
    transform: translateY(-2px);
}

.vnd-chat-product-img {
    width: 65px;
    height: 65px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #ffffff;
}

.vnd-chat-product-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.vnd-chat-product-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #0c2340;
    margin: 0 0 3px 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vnd-chat-product-price {
    font-size: 12px;
    font-weight: 700;
    color: #e11d48;
}

.vnd-chat-product-badge {
    font-size: 10px;
    color: #0369a1;
    font-weight: 600;
}

/* Lead Drawer inside Chat Widget */
.vnd-lead-drawer {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 2px solid var(--ai-primary);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    padding: 16px;
    z-index: 10;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    max-height: 80%;
    overflow-y: auto;
}

.vnd-lead-drawer.active {
    display: block;
    animation: vndSlideUp 0.25s ease-out;
}

.vnd-lead-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.vnd-lead-drawer-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0c2340;
}

.vnd-lead-drawer-header button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
}

.lead-field {
    margin-bottom: 10px;
}

.lead-field label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 3px;
}

.lead-field input, .lead-field select, .lead-field textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12.5px;
    box-sizing: border-box;
    font-family: inherit;
}

.lead-field input:focus, .lead-field select:focus, .lead-field textarea:focus {
    border-color: var(--ai-primary);
    outline: none;
}

.btn-submit-lead {
    width: 100%;
    padding: 10px;
    background: var(--ai-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
}

.btn-submit-lead:hover {
    background: var(--ai-primary-dark);
}

/* Quick Tools Action Bar */
.vnd-chat-quick-tools {
    display: flex;
    gap: 6px;
    padding: 7px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: none;
}

.vnd-chat-quick-tools::-webkit-scrollbar {
    display: none;
}

.quick-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.quick-tool-btn:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    transform: translateY(-1px);
}

.quick-tool-btn.tool-hotline {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.quick-tool-btn.tool-hotline:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* Form Fields Enhancement inside Drawer */
.lead-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.lead-chips-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.chip-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    font-family: inherit;
    color: #475569;
    cursor: pointer;
    user-select: none;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chip-item:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
    transform: translateY(-1px);
}

.chip-item .check-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    color: transparent;
    background: #e2e8f0;
    transition: all 0.2s ease;
}

.chip-item.active {
    background: #eff6ff;
    border-color: #0284c7;
    color: #0369a1;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.2);
}

.chip-item.active .check-icon {
    background: #0284c7;
    color: #ffffff;
}

/* Estimator Drawer Styles */
.vnd-estimator-drawer {
    border-top: 3px solid #007cc2;
}

.est-result-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 10px;
}

.est-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #334155;
    margin-bottom: 5px;
}

.est-result-row strong {
    color: #0f172a;
    font-weight: 600;
}

.est-result-divider {
    height: 1px;
    background: #cbd5e1;
    margin: 8px 0;
}

.est-result-row.total {
    font-size: 13.5px;
    margin-bottom: 0;
}

.est-result-row.total span {
    font-weight: 700;
    color: #0c2340;
}

.est-result-row.total strong {
    font-size: 15px;
    color: #dc2626;
    font-weight: 800;
}

/* Suggestions Chips */
.vnd-chat-suggestions {
    padding: 8px 14px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.vnd-chat-suggestions::-webkit-scrollbar {
    display: none;
}

.vnd-suggestion-chip {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vnd-suggestion-chip:hover {
    background: #e0f2fe;
    color: #007cc2;
    border-color: #007cc2;
}

/* Typing Indicator */
.vnd-typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 8px 14px;
    background: #ffffff;
    border-radius: 14px;
    border-top-left-radius: 4px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.vnd-typing-indicator.active {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vnd-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: vndDotBounce 1.4s infinite ease-in-out both;
}

.vnd-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.vnd-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Chat Input Bar */
.vnd-chat-input-bar {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 5;
}

.vnd-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 13px;
    outline: none;
    background: #f8fafc;
    font-family: inherit;
    transition: all 0.2s ease;
}

.vnd-chat-input:focus {
    background: #ffffff;
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 3px rgba(0, 124, 194, 0.15);
}

.vnd-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ai-primary);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.vnd-chat-send-btn:hover {
    background: var(--ai-primary-dark);
    transform: scale(1.05);
}

.vnd-chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.vnd-chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Animations */
@keyframes vndPillFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes vndDotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes vndSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .vnd-chat-launcher {
        bottom: 74px; /* Sits nicely above the mobile sticky bottom bar */
        right: 14px;
        z-index: 850;
    }
}

@media (max-width: 576px) {
    .vnd-chat-launcher-pill {
        display: none !important; /* Hide long text on small mobile screens to keep view clean */
    }
    .vnd-chat-launcher-btn {
        width: 50px;
        height: 50px;
        box-shadow: 0 4px 16px rgba(0, 124, 194, 0.4);
    }
    .vnd-chat-launcher-btn svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 640px) {
    .vnd-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        z-index: 99999 !important;
    }
    .vnd-chat-header {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
    }
    .vnd-agent-meta h4 {
        font-size: 13.5px;
    }
    .vnd-agent-meta span {
        font-size: 11px;
    }
    .vnd-header-btn {
        width: 34px;
        height: 34px;
    }
    .vnd-chat-messages {
        padding: 12px 12px 10px;
        gap: 12px;
    }
    .vnd-msg-row {
        max-width: 94%;
    }
    .vnd-msg-bubble {
        font-size: 13.5px;
        padding: 10px 13px;
    }
    .vnd-chat-input-bar {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: #ffffff;
    }
    .vnd-chat-input {
        font-size: 16px !important; /* CRITICAL: Prevents iOS Safari auto-zoom on focus */
        padding: 9px 14px;
    }
    .vnd-suggestion-chip {
        padding: 5px 11px;
        font-size: 11px;
    }
    .vnd-lead-drawer {
        max-height: 90%;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}
