/* Floating chat widget (project + listing detail pages). Brand colours follow /chat (chat-luxury.css). */
.cw {
    --cw-red: var(--lux-maroon, #c8102e);
    --cw-red-hover: var(--lux-maroon-hover, #a30d26);
    --cw-red-soft: var(--lux-maroon-soft, #fff4f5);
    --cw-ink: #0f172a;
    --cw-muted: #64748b;
    --cw-line: rgba(226, 232, 240, 0.9);
    --cw-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); /* lowest corner: where the quick-contact cluster used to start */
    --cw-top: 72px;
    position: fixed;
    right: 0;
    bottom: 0;
    z-index: 92;
    font-family: "Be Vietnam Pro", Montserrat, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--cw-ink);
    -webkit-font-smoothing: antialiased;
}
.cw *, .cw *::before, .cw *::after { box-sizing: border-box; }
.cw [hidden] { display: none !important; }
.cw svg { width: 1em; height: 1em; fill: currentColor; display: block; }

/* Hide while modals / the gallery lightbox are open */
body.pj-show-lightbox-open .cw,
body.pj-faq-modal-open .cw,
body.pj-modal-open .cw,
body.lux-pj-booking-modal-open .cw,
body.header-search-open .cw,
html.lux-lb-lock .cw {
    visibility: hidden;
    pointer-events: none;
}

/* ───── launcher ───── */
.cw-launcher {
    position: fixed;
    right: 14px;
    bottom: var(--cw-bottom);
    z-index: 92;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #dc1b3a 0%, var(--cw-red) 55%, #a30d26 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(200, 16, 46, 0.38), 0 2px 6px rgba(15, 23, 42, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, bottom 0.2s ease, opacity 0.18s ease, visibility 0.18s;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.cw-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 30px rgba(200, 16, 46, 0.44), 0 2px 6px rgba(15, 23, 42, 0.2); }
.cw-launcher:active { transform: scale(0.96); }
.cw-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--cw-red); }
.cw-launcher__icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; transition: opacity 0.2s ease, transform 0.25s ease; }
.cw-launcher__icon--close { opacity: 0; transform: rotate(-70deg) scale(0.6); font-size: 24px; }
.cw.is-open .cw-launcher { opacity: 0; visibility: hidden; pointer-events: none; transform: scale(0.6); }
.cw.is-open .cw-launcher__icon--open { opacity: 0; transform: rotate(70deg) scale(0.6); }
.cw.is-open .cw-launcher__icon--close { opacity: 1; transform: none; }
.cw-launcher__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cw-launcher::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(200, 16, 46, 0.45); animation: cw-pulse 2.8s ease-out infinite; pointer-events: none; }
.cw.is-open .cw-launcher::after, .cw.is-seen .cw-launcher::after { animation: none; opacity: 0; }
@keyframes cw-pulse { 0% { transform: scale(1); opacity: 0.9; } 70%, 100% { transform: scale(1.5); opacity: 0; } }

/* ───── panel ───── */
.cw-panel {
    position: fixed;
    right: 14px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px)); /* the launcher is hidden while the panel is open, so the panel uses its spot */
    z-index: 95;
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 28px);
    height: min(720px, calc(100vh - 20px - env(safe-area-inset-bottom, 0px) - var(--cw-top)));
    height: min(720px, calc(100dvh - 20px - env(safe-area-inset-bottom, 0px) - var(--cw-top)));
    min-height: 0;
    overflow: hidden;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28), 0 6px 18px rgba(15, 23, 42, 0.12);
    transform-origin: bottom right;
    animation: cw-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
@keyframes cw-pop { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }

.cw-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, #d4132f 0%, var(--cw-red) 50%, #9e0c24 100%);
    color: #fff;
}
.cw-head__avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.45);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.02em;
}
.cw-head__text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; gap: 2px; }
.cw-head__text strong { font-size: 15px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-head__text span { font-size: 12px; line-height: 1.3; opacity: 0.88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-head__close {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cw-head__close:hover { background: rgba(255, 255, 255, 0.3); }

/* ───── tabs ───── */
.cw-tabs {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 12px 14px 4px;
    padding: 4px;
    border-radius: 999px;
    background: #f1f5f9;
}
.cw-tabs__thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    transition: transform 0.22s ease;
}
.cw-tabs[data-active="human"] .cw-tabs__thumb { transform: translateX(100%); }
.cw-tab {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--cw-muted);
    font-weight: 600; font-size: 13px; line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.18s ease;
    white-space: nowrap;
}
.cw-tab.is-on { color: var(--cw-red); }
.cw-tab__icon { font-size: 15px; display: inline-flex; }

/* ───── panes / thread ───── */
.cw-pane, .cw-human { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.cw-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 6px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.cw-scroll::-webkit-scrollbar { width: 6px; }
.cw-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.cw-thread { display: flex; flex-direction: column; gap: 10px; }
.cw-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.cw-row--me { justify-content: flex-end; }
.cw-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cw-red-soft);
    color: var(--cw-red);
    font-size: 14px;
    font-weight: 800;
}
.cw-avatar--agent { background: #0f172a; color: #fff; font-size: 11px; letter-spacing: 0.03em; }
.cw-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.cw-bubble--them { background: #fff; border: 1px solid var(--cw-line); border-bottom-left-radius: 6px; color: #1e293b; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05); }
.cw-bubble--me { background: var(--cw-red); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 12px rgba(200, 16, 46, 0.18); }
.cw-bubble--error { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.cw-bubble--recalled { font-style: italic; color: #94a3b8; }
.cw-bubble img, .cw-bubble video { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; }
.cw-bubble strong { font-weight: 700; }
.cw-bubble.is-streaming::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; background: var(--cw-red); border-radius: 2px; animation: cw-caret 0.9s steps(2) infinite; }
@keyframes cw-caret { 50% { opacity: 0; } }
.cw-time { display: block; margin-top: 3px; font-size: 10px; opacity: 0.6; }
.cw-typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.cw-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: cw-bounce 1.1s ease-in-out infinite; }
.cw-typing i:nth-child(2) { animation-delay: 0.15s; }
.cw-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }
.cw-intro {
    margin: 0 0 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--cw-red-soft);
    color: #7f1d2d;
    font-size: 13px;
    line-height: 1.5;
}
.cw-empty { margin: 18px 0; text-align: center; color: var(--cw-muted); font-size: 13px; }

/* ───── suggestions / composer ───── */
.cw-suggest { display: flex; gap: 8px; padding: 6px 14px 4px; overflow-x: auto; scrollbar-width: none; }
.cw-suggest::-webkit-scrollbar { display: none; }
.cw-suggest[hidden] { display: none; }
.cw-chip {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid #fecdd3;
    border-radius: 999px;
    background: #fff;
    color: var(--cw-red);
    font-weight: 600; font-size: 12.5px; line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.cw-chip:hover { background: var(--cw-red); color: #fff; }
.cw-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid #f1f5f9; background: #fff; }
.cw-input {
    flex: 1 1 auto;
    min-height: 42px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 21px;
    background: #f8fafc;
    color: var(--cw-ink);
    font-weight: 400; font-size: 14px; line-height: 1.45;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.cw-input:focus { border-color: var(--cw-red); background: #fff; box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12); }
.cw-send {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--cw-red);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.cw-send:hover { background: var(--cw-red-hover); }
.cw-send:active { transform: scale(0.94); }
.cw-send:disabled, .cw-input:disabled { opacity: 0.55; cursor: not-allowed; }
.cw-foot { margin: 0; padding: 0 16px 10px; background: #fff; color: #94a3b8; font-size: 10.5px; line-height: 1.4; text-align: center; }

/* ───── person tab ───── */
.cw-notice { margin: 8px 14px 0; padding: 10px 12px; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 12.5px; line-height: 1.45; }
.cw-guest { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 16px; }
.cw-guest h3 { margin: 4px 0 4px; font-size: 16px; font-weight: 700; }
.cw-guest > p { margin: 0 0 12px; color: var(--cw-muted); font-size: 13px; line-height: 1.5; }
.cw-field { display: block; margin-bottom: 10px; }
.cw-field > span { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: #334155; }
.cw-field input { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #f8fafc; font-weight: 400; font-size: 14px; line-height: 1.2; font-family: inherit; color: var(--cw-ink); outline: none; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; }
.cw-field input:focus { border-color: var(--cw-red); background: #fff; box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12); }
.cw-field.has-error input { border-color: #ef4444; background: #fff5f5; }
.cw-field__err { display: none; margin-top: 4px; font-size: 11.5px; font-style: normal; color: #dc2626; }
.cw-field.has-error .cw-field__err { display: block; }
.cw-btn { width: 100%; min-height: 46px; margin-top: 4px; border: 0; border-radius: 14px; background: linear-gradient(135deg, #d4132f, var(--cw-red)); color: #fff; font-weight: 700; font-size: 14px; line-height: 1; font-family: inherit; cursor: pointer; box-shadow: 0 8px 18px rgba(200, 16, 46, 0.25); transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s; }
.cw-btn:hover { transform: translateY(-1px); }
.cw-btn:disabled { opacity: 0.6; cursor: wait; }
.cw-link { display: block; width: 100%; margin: 10px 0 0; padding: 6px; border: 0; background: transparent; color: var(--cw-red); font-weight: 600; font-size: 13px; line-height: 1.3; font-family: inherit; cursor: pointer; text-align: center; }
.cw-guest__note { margin: 8px 0 0; color: #94a3b8; font-size: 11px; line-height: 1.5; text-align: center; }
.cw-openchat { display: inline-flex; align-items: center; gap: 6px; align-self: center; margin: 2px 0 6px; padding: 4px 10px; color: var(--cw-red); font-size: 12px; font-weight: 600; text-decoration: none; }
.cw-openchat svg { font-size: 13px; }
.cw-openchat:hover { text-decoration: underline; }

/* ───── pages with the chat button: the quick Call / Zalo / Contact buttons are hidden (markup kept; remove body.cw-on to restore) ───── */
body.cw-on .pj-contact-fab__actions { display: none !important; }
/* the scroll-to-top / scroll-down pair stays, lifted just above the chat button instead of overlapping it */
body.cw-on .pj-contact-fab { bottom: calc(28px + 56px + 10px + env(safe-area-inset-bottom, 0px)); }
body.cw-open .pj-contact-fab { visibility: hidden; pointer-events: none; }

@media (max-width: 899px) {
    .cw { --cw-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
    .cw-launcher { right: 12px; }
    body.cw-on .pj-contact-fab { bottom: calc(18px + 52px + 10px + env(safe-area-inset-bottom, 0px)); }
}

/* ───── mobile: bottom sheet that never covers the site header ───── */
@media (max-width: 640px) {
    .cw-launcher { width: 52px; height: 52px; }
    .cw-launcher__icon { font-size: 24px; }
    .cw-panel {
        left: auto;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        width: calc(100vw - 24px);
        max-width: 400px;
        min-height: 0;
        height: calc(100vh - var(--cw-top) - 12px - env(safe-area-inset-bottom, 0px));
        height: calc(100dvh - var(--cw-top) - 12px - env(safe-area-inset-bottom, 0px));
        max-height: none;
        border-radius: 22px;
        animation: cw-sheet 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
    }
    @keyframes cw-sheet { from { opacity: 0; transform: translateY(36px); } to { opacity: 1; transform: none; } }
    .cw-input, .cw-field input { font-size: 16px; }
    .cw-bubble { font-size: 15px; max-width: 86%; }
}

@media (prefers-reduced-motion: reduce) {
    .cw *, .cw-panel { animation: none !important; transition: none !important; }
}
