/* ==========================================================================
   Haven Stays & Hospitality — floating widgets
   Design & development: Sohrab Khan · msoohrab.com

   Two independent widgets share one dock so they stack neatly and never
   overlap: a WhatsApp lead form, and an "Ask Haven" answers chat.
   Delete either script and the other keeps working on its own.

   Palette is Haven navy + gold; the WhatsApp side keeps WhatsApp green so
   the handoff is recognisable.
   ========================================================================== */

:root {
    --wa-green: #25D366;
    --wa-dark:  #128C7E;
    --wa-deep:  #075E54;
}

.fw-dock {
    position: fixed;
    right: clamp(.9rem, .5rem + 1vw, 1.5rem);
    bottom: clamp(.9rem, .5rem + 1vw, 1.5rem);
    z-index: 800;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: flex-end;
}

/* --- launcher buttons -------------------------------------------------- */
.fw-btn {
    position: relative;
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 0;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform .26s var(--ease), box-shadow .26s var(--ease);
}
.fw-btn:hover { transform: scale(1.08); }
.fw-btn:active { transform: scale(.97); }
.fw-btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 4px; }
.fw-btn svg { position: absolute; transition: opacity .25s, transform .25s; }
.fw-btn .ic-close { opacity: 0; transform: rotate(-90deg) scale(.55); }
.fw-btn.open .ic-main { opacity: 0; transform: rotate(90deg) scale(.55); }
.fw-btn.open .ic-close { opacity: 1; transform: rotate(0) scale(1); }

.fw-btn.wa {
    background: linear-gradient(145deg, var(--wa-green), #14A85A);
    color: #fff;
    box-shadow: 0 10px 26px rgba(18, 140, 126, .45);
}
.fw-btn.chat {
    background: linear-gradient(150deg, var(--navy-700), var(--navy-900));
    color: var(--gold-400);
    border: 2px solid var(--gold-500);
    box-shadow: 0 10px 26px rgba(11, 37, 69, .42);
}

/* pulse ring — drops away once the widget has been seen this session */
.fw-btn .fw-ring {
    position: absolute; inset: -5px;
    border-radius: 50%;
    pointer-events: none;
    border: 2px solid currentColor;
    opacity: .5;
    animation: fwRing 2.4s ease-out infinite;
}
.fw-btn.wa .fw-ring { color: var(--wa-green); }
.fw-btn.chat .fw-ring { color: var(--gold-500); }
.fw-btn.open .fw-ring, .fw-btn.seen .fw-ring { display: none; }
@keyframes fwRing {
    0%   { transform: scale(.92); opacity: .5; }
    70%  { transform: scale(1.28); opacity: 0; }
    100% { transform: scale(1.28); opacity: 0; }
}

.fw-badge {
    position: absolute; top: -2px; right: -2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #E8412F; color: #fff;
    border: 2px solid #fff;
    font-size: .63rem; font-weight: 800;
    display: grid; place-items: center;
    z-index: 3;
}
.fw-btn.open .fw-badge, .fw-btn.seen .fw-badge { display: none; }

/* hover label pill to the left of each launcher */
.fw-label {
    position: absolute;
    right: calc(100% + 12px); top: 50%;
    transform: translateY(-50%) translateX(8px);
    background: #fff; color: var(--navy-800);
    padding: 9px 16px;
    border-radius: var(--r-pill);
    white-space: nowrap;
    font-size: .82rem; font-weight: 600;
    box-shadow: var(--sh-lg);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .25s var(--ease), transform .25s var(--ease), visibility .25s;
}
.fw-btn:hover .fw-label { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); }
.fw-btn.open .fw-label { display: none; }

/* --- teaser bubble ----------------------------------------------------- */
.fw-teaser {
    position: fixed;
    right: clamp(.9rem, .5rem + 1vw, 1.5rem);
    bottom: 160px;
    z-index: 799;
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: var(--sh-lg);
    border: 1px solid var(--line);
    padding: 15px 42px 15px 17px;
    max-width: 262px;
    font-size: .85rem;
    line-height: 1.55;
    color: var(--ink);
    opacity: 0; visibility: hidden;
    transform: translateY(12px);
    transition: all .35s var(--ease);
}
.fw-teaser.show { opacity: 1; visibility: visible; transform: translateY(0); }
.fw-teaser strong { color: var(--navy-800); }
.fw-teaser-x {
    position: absolute; top: 7px; right: 7px;
    width: 26px; height: 26px;
    border: 0; border-radius: 50%;
    background: var(--sand-100); color: var(--ink-soft);
    display: grid; place-items: center;
    font-size: .78rem;
}

/* --- panel ------------------------------------------------------------- */
.fw-panel {
    position: fixed;
    right: clamp(.9rem, .5rem + 1vw, 1.5rem);
    bottom: 160px;
    /* Above the sticky header (900) and the mobile action bar (810) — on phones
       this panel goes full-screen and must cover both. Still below the nav
       drawer (960) so the menu always wins. */
    z-index: 940;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 610px;
    max-height: calc(100dvh - 190px);
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 26px 70px rgba(11, 37, 69, .34);
    display: flex;
    flex-direction: column;
    opacity: 0; visibility: hidden;
    transform: translateY(20px) scale(.97);
    transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s;
}
.fw-panel.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.fw-head {
    color: #fff;
    padding: 15px 18px;
    display: flex; align-items: center; gap: 13px;
    flex-shrink: 0;
}
.fw-panel.wa   .fw-head { background: linear-gradient(135deg, var(--wa-dark), var(--wa-deep)); }
.fw-panel.chat .fw-head { background: linear-gradient(135deg, var(--navy-700), var(--navy-900)); border-bottom: 2px solid var(--gold-500); }

.fw-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .28);
    display: grid; place-items: center;
    color: #fff;
}
.fw-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fw-panel.chat .fw-avatar { color: var(--gold-400); border-color: rgba(200, 164, 92, .55); }

.fw-head-txt { flex: 1; min-width: 0; }
/* base.css sets `strong { color: var(--ink-soft) }` globally, which is dark
   ink — it has to be overridden here or the title vanishes into the header. */
.fw-head-txt strong {
    display: block;
    font-family: var(--f-display);
    font-size: 1.02rem; font-weight: 600; line-height: 1.3;
    color: #fff;
}
.fw-panel.chat .fw-head-txt strong { color: var(--gold-400); }
.fw-status { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: rgba(255, 255, 255, .82); }
.fw-online { width: 8px; height: 8px; border-radius: 50%; background: #5FD68B; box-shadow: 0 0 0 3px rgba(95, 214, 139, .28); }

.fw-x {
    width: 34px; height: 34px;
    border-radius: 50%; border: 0;
    flex-shrink: 0;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    display: grid; place-items: center;
    transition: background .2s;
}
.fw-x:hover { background: rgba(255, 255, 255, .3); }

.fw-body {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    padding: 18px 16px 20px;
    display: flex; flex-direction: column; gap: 12px;
}
.fw-panel.wa .fw-body {
    background: #EFEAE2;
    background-image: radial-gradient(rgba(7, 94, 84, .05) 1px, transparent 1px);
    background-size: 18px 18px;
}
.fw-panel.chat .fw-body { background: var(--ivory); }
.fw-body::-webkit-scrollbar { width: 6px; }
.fw-body::-webkit-scrollbar-thumb { background: rgba(11, 37, 69, .22); border-radius: 6px; }

/* --- messages ---------------------------------------------------------- */
.fw-msg {
    max-width: 90%;
    font-size: .89rem; line-height: 1.6;
    animation: fwIn .35s var(--ease);
    position: relative;
}
@keyframes fwIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.fw-msg.bot {
    background: #fff; color: var(--ink);
    border-radius: 12px 12px 12px 3px;
    padding: 13px 15px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    align-self: flex-start;
}
.fw-msg.user {
    border-radius: 12px 12px 3px 12px;
    padding: 11px 15px 19px;
    align-self: flex-end;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.fw-panel.wa   .fw-msg.user { background: #D9FDD3; color: #10281F; }
.fw-panel.chat .fw-msg.user { background: linear-gradient(135deg, var(--navy-600), var(--navy-800)); color: #fff; }
.fw-panel.chat .fw-msg.user .fw-time { color: rgba(255, 255, 255, .75); }

.fw-msg .fw-time {
    position: absolute; bottom: 5px; right: 12px;
    font-size: .63rem; color: var(--ink-soft);
    opacity: .8; font-weight: 500;
}
.fw-panel.wa   .fw-msg.bot strong { color: var(--wa-deep); }
.fw-panel.chat .fw-msg.bot strong { color: var(--navy-800); }
.fw-msg.bot p + p { margin-top: 9px; }
.fw-msg.bot ul { margin-top: 8px; list-style: none; }
.fw-msg.bot ul li { padding-left: 18px; position: relative; margin-bottom: 5px; font-size: .86rem; }
.fw-msg.bot ul li::before { content: "\2713"; position: absolute; left: 0; font-size: .7rem; font-weight: 800; }
.fw-panel.wa   .fw-msg.bot ul li::before { color: var(--wa-green); }
.fw-panel.chat .fw-msg.bot ul li::before { color: var(--gold-600); }
.fw-msg.bot a { font-weight: 600; text-decoration: underline; }
.fw-panel.wa   .fw-msg.bot a { color: var(--wa-dark); }
.fw-panel.chat .fw-msg.bot a { color: var(--gold-700); }

/* --- quick-reply chips ------------------------------------------------- */
.fw-chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: stretch; animation: fwIn .4s var(--ease); }
.fw-chip {
    background: #fff;
    border-radius: var(--r-pill);
    padding: 9px 15px;
    font-size: .81rem; font-weight: 500;
    transition: all .22s var(--ease);
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 38px;
}
.fw-panel.wa   .fw-chip { border: 1.5px solid rgba(18, 140, 126, .4); color: var(--wa-deep); }
.fw-panel.wa   .fw-chip:hover { background: var(--wa-dark); border-color: var(--wa-dark); color: #fff; }
.fw-panel.chat .fw-chip { border: 1.5px solid var(--gold-300); color: var(--navy-800); }
.fw-panel.chat .fw-chip:hover { background: var(--navy-800); border-color: var(--navy-800); color: var(--gold-400); }

.fw-typing {
    display: flex; gap: 5px;
    align-self: flex-start;
    background: #fff;
    padding: 14px 17px;
    border-radius: 12px 12px 12px 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.fw-typing span { width: 8px; height: 8px; border-radius: 50%; opacity: .4; animation: fwBounce 1.2s infinite; }
.fw-panel.wa   .fw-typing span { background: var(--wa-dark); }
.fw-panel.chat .fw-typing span { background: var(--gold-600); }
.fw-typing span:nth-child(2) { animation-delay: .16s; }
.fw-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes fwBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* --- in-widget lead form ----------------------------------------------- */
.fw-form {
    background: #fff;
    border-radius: 14px;
    padding: 18px 17px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
    align-self: stretch;
    animation: fwIn .35s var(--ease);
}
.fw-form h5 { font-family: var(--f-display); font-size: 1.02rem; color: var(--navy-800); margin-bottom: 4px; }
.fw-form-sub { font-size: .78rem; color: var(--ink-soft); margin-bottom: 14px; }
.fw-field { margin-bottom: 11px; }
.fw-field label { display: block; font-size: .75rem; font-weight: 600; color: var(--navy-800); margin-bottom: 5px; }
.fw-field label .req { color: #E8412F; }
.fw-form input, .fw-form select, .fw-form textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    background: var(--sand-100);
    font-family: var(--f-body);
    font-size: .87rem;
    min-height: 42px;
}
.fw-form textarea { min-height: 70px; resize: vertical; }
.fw-form input:focus, .fw-form select:focus, .fw-form textarea:focus { outline: none; background: #fff; }
.fw-panel.wa   .fw-form input:focus, .fw-panel.wa   .fw-form select:focus, .fw-panel.wa   .fw-form textarea:focus { border-color: var(--wa-green); box-shadow: 0 0 0 3px rgba(37, 211, 102, .15); }
.fw-panel.chat .fw-form input:focus, .fw-panel.chat .fw-form select:focus, .fw-panel.chat .fw-form textarea:focus { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(200, 164, 92, .18); }
.fw-form input.err, .fw-form select.err, .fw-form textarea.err { border-color: #E8412F; background: #FEF3F1; }

.fw-consent { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 15px; }
.fw-consent input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.fw-panel.wa   .fw-consent input[type="checkbox"] { accent-color: var(--wa-green); }
.fw-panel.chat .fw-consent input[type="checkbox"] { accent-color: var(--gold-600); }
.fw-consent label { font-size: .71rem; line-height: 1.5; color: var(--ink-soft); cursor: pointer; font-weight: 400; margin: 0; }
.fw-consent a { text-decoration: underline; font-weight: 600; color: var(--gold-700); }
.fw-consent.err label { color: #B4432F; }

.fw-submit {
    width: 100%;
    padding: 13px;
    border: 0; border-radius: 10px;
    font-family: var(--f-body);
    font-weight: 600; font-size: .92rem;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    transition: background .2s var(--ease), transform .18s var(--ease), filter .2s;
    min-height: 48px;
}
.fw-submit:active { transform: scale(.98); }
.fw-submit.wa { background: var(--wa-green); color: #063E2C; }
.fw-submit.wa:hover { background: #1FBF5B; }
.fw-submit.brand { background: linear-gradient(135deg, var(--gold-600), var(--gold-400)); color: var(--navy-900); }
.fw-submit.brand:hover { filter: brightness(1.06); }

.fw-done { text-align: center; padding: 8px 4px; }
.fw-done .fw-tick {
    width: 54px; height: 54px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--gold-100); color: var(--gold-700);
    display: grid; place-items: center;
    font-size: 1.4rem;
}
.fw-done h5 { margin-bottom: 6px; }
.fw-done p { font-size: .85rem; color: var(--ink-soft); }

/* --- footer ------------------------------------------------------------ */
.fw-foot { flex-shrink: 0; background: #fff; border-top: 1px solid var(--line); }
.fw-input-row { display: flex; gap: 8px; padding: 10px 12px; align-items: center; }
.fw-input-row input {
    flex: 1; min-width: 0;
    border: 1.5px solid var(--line);
    background: var(--sand-100);
    border-radius: var(--r-pill);
    padding: 11px 16px;
    font-family: var(--f-body);
    font-size: .87rem;
    min-height: 42px;
}
.fw-input-row input:focus { outline: none; border-color: var(--gold-500); background: #fff; }
.fw-send {
    width: 42px; height: 42px;
    flex-shrink: 0;
    border-radius: 50%; border: 0;
    display: grid; place-items: center;
    transition: background .2s var(--ease), transform .2s var(--ease);
    background: var(--navy-800); color: var(--gold-400);
}
.fw-send:hover { background: var(--navy-900); transform: scale(1.06); }
.fw-powered {
    display: flex; justify-content: center; align-items: center; gap: 7px;
    padding: 8px 14px 11px;
    border-top: 1px solid var(--line);
    font-size: .69rem; color: var(--ink-soft);
}
.fw-panel.wa .fw-powered svg { color: var(--wa-green); }
.fw-panel.chat .fw-powered svg { color: var(--gold-600); }

/* --- keep the back-to-top clear of the dock ---------------------------- */
.floaters { right: calc(clamp(.9rem, .5rem + 1vw, 1.5rem) + 70px); }

@media (prefers-reduced-motion: reduce) {
    .fw-btn .fw-ring { animation: none; }
    .fw-msg, .fw-chips, .fw-form { animation: none; }
}

/* --- responsive -------------------------------------------------------- */
/* 768px is where responsive.css turns on .mobile-bar and lifts .floaters —
   the dock has to move in the same breakpoint or it sits under the bar. */
@media (max-width: 768px) {
    .fw-dock   { bottom: 84px; }
    .fw-panel  { bottom: 84px; max-height: calc(100dvh - 108px); }
    .fw-teaser { display: none; }
    .fw-label  { display: none; }
}

@media (max-width: 640px) {
    /* full-screen panel on phones — a 380px card in a 360px viewport is worse
       than no card at all */
    .fw-panel {
        right: 0; left: 0; bottom: 0;
        width: 100%; max-width: 100%;
        height: 100dvh; max-height: 100dvh;
        border-radius: 0;
    }
    .fw-dock { right: 15px; bottom: 84px; gap: 12px; }
    .fw-btn { width: 52px; height: 52px; }
    .fw-btn svg.ic-main { width: 26px; height: 26px; }
}
