/* Chat dock: one button, a choice of AI chat or WhatsApp, and the chat panel.
   Sits where the WhatsApp button used to (views/partials/chat-dock.php). */

.cd {
    position: fixed;
    right: clamp(1rem, 3vw, 1.75rem);
    bottom: clamp(1rem, 3vw, 1.75rem);
    z-index: 170;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .625rem;
    font-family: inherit;
}

/* The round button */
.cd-launch {
    width: 3.5rem; height: 3.5rem; border-radius: 50%; border: 0;
    display: grid; place-items: center; flex: 0 0 auto; cursor: pointer;
    background: var(--coral, #E8552A); color: #fff;
    box-shadow: 0 4px 14px rgba(28, 20, 16, .28);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
    -webkit-tap-highlight-color: transparent;
}
.cd-launch:hover, .cd-launch:focus-visible { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 22px rgba(28, 20, 16, .34); background: var(--coral-dark, #C43F1A); }
.cd-launch:focus-visible { outline: 3px solid var(--ink, #1C1410); outline-offset: 3px; }
.cd-launch__x { display: none; }
/* Open, the dock sits above the site header so the panel's top is never hidden. */
.cd.is-open { z-index: 2000; }
.cd.is-open .cd-launch__chat { display: none; }
.cd.is-open .cd-launch__x { display: block; }

/* The nudge above the button */
.cd-hint {
    position: relative; max-width: 19rem; background: #fff; color: var(--ink, #1C1410);
    border-radius: 14px 14px 4px 14px; box-shadow: 0 6px 24px rgba(28, 20, 16, .18);
    animation: cd-pop .25s ease;
}
.cd-hint[hidden] { display: none; }
.cd-hint__body { display: block; text-align: left; padding: .8rem 2rem .8rem .95rem; }
.cd-hint__text { display: block; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; font-size: .9rem; line-height: 1.4; }
.cd-hint__text[hidden], .cd-hint__typing[hidden], .cd-chips[hidden] { display: none; }
.cd-hint__typing { display: inline-flex; gap: 4px; padding: .3rem 0; }
.cd-hint__typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--stone, #7A6B60); animation: cd-dot 1s infinite ease-in-out; }
.cd-hint__typing span:nth-child(2) { animation-delay: .15s; }
.cd-hint__typing span:nth-child(3) { animation-delay: .3s; }
.cd-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.cd-chips--log { align-self: flex-start; margin-top: 0; }
.cd-chip { border: 1px solid var(--coral, #E8552A); background: #fff; color: var(--coral-dark, #C43F1A); border-radius: 999px; padding: .35rem .7rem; font: inherit; font-size: .8rem; line-height: 1.25; text-align: left; cursor: pointer; }
.cd-chip:hover, .cd-chip:focus-visible { background: var(--coral-pale, #FFF0EB); }
.cd-hint__name { display: block; font-weight: 700; font-size: .78rem; color: var(--coral-dark, #C43F1A); margin-bottom: .15rem; }
.cd-hint__text { font-size: .9rem; line-height: 1.4; }
.cd-hint__close { position: absolute; top: .3rem; right: .35rem; border: 0; background: none; font-size: 1.2rem; line-height: 1; color: var(--muted, #6B5A4F); cursor: pointer; padding: .25rem .4rem; }

/* The two choices */
.cd-menu {
    width: min(19rem, calc(100vw - 2rem)); background: #fff; color: var(--ink, #1C1410);
    border-radius: 16px; box-shadow: 0 10px 32px rgba(28, 20, 16, .22); padding: .9rem; animation: cd-pop .2s ease;
}
.cd-menu[hidden] { display: none; }
.cd-menu__title { margin: 0 0 .6rem; font-weight: 700; font-size: .95rem; }
.cd-menu__opt {
    display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
    padding: .7rem .75rem; border-radius: 12px; border: 1px solid var(--line, #EDE3D6);
    background: var(--off, #FDFAF6); color: inherit; text-decoration: none; font: inherit; cursor: pointer;
}
.cd-menu__opt + .cd-menu__opt { margin-top: .5rem; }
.cd-menu__opt:hover, .cd-menu__opt:focus-visible { background: var(--hover, #F3EBE0); color: inherit; }
.cd-menu__opt b { display: block; font-size: .92rem; }
.cd-menu__opt small { display: block; font-size: .8rem; color: var(--muted, #6B5A4F); }
.cd-menu__ico { width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; color: #fff; }
.cd-menu__ico--ai { background: var(--coral, #E8552A); }
.cd-menu__ico--wa { background: #25D366; }

/* The chat panel */
.cd-panel {
    width: min(23rem, calc(100vw - 2rem)); height: min(32rem, calc(100vh - 7rem));
    display: flex; flex-direction: column; background: #fff; color: var(--ink, #1C1410);
    border-radius: 18px; box-shadow: 0 12px 40px rgba(28, 20, 16, .26); overflow: hidden; animation: cd-pop .2s ease;
}
.cd-panel[hidden] { display: none; }
.cd-panel__head { display: flex; align-items: center; gap: .65rem; padding: .8rem .9rem; background: var(--ink, #1C1410); color: #fff; }
.cd-panel__avatar { width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--coral, #E8552A); font-weight: 800; font-size: .78rem; letter-spacing: .02em; }
.cd-panel__who { flex: 1; line-height: 1.2; }
.cd-panel__who b { display: block; font-size: .95rem; }
.cd-panel__who small { font-size: .78rem; opacity: .8; }
.cd-panel__close { border: 0; background: none; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: .2rem .4rem; }
.cd-person { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .8rem; background: #E9FBEF; border-bottom: 1px solid #C9EFD6; }
.cd-person__text { font-size: .82rem; font-weight: 600; color: #14532D; }
.cd-person__btn { display: inline-flex; align-items: center; gap: .4rem; flex: 0 0 auto; padding: .45rem .8rem; border-radius: 999px; background: #0E7C3A; color: #fff; font-size: .82rem; font-weight: 700; text-decoration: none; box-shadow: 0 2px 6px rgba(14, 124, 58, .3); }
.cd-person__btn:hover, .cd-person__btn:focus-visible { background: #0B6B32; color: #fff; }
.cd-person__btn:focus-visible { outline: 3px solid var(--ink, #1C1410); outline-offset: 2px; }
.cd-panel__log { flex: 1; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .55rem; background: var(--off, #FDFAF6); }
.cd-msg { max-width: 85%; padding: .6rem .8rem; border-radius: 14px; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.cd-msg--ai { align-self: flex-start; background: #fff; border: 1px solid var(--line, #EDE3D6); border-bottom-left-radius: 4px; }
.cd-msg--user { align-self: flex-end; background: var(--coral, #E8552A); color: #fff; border-bottom-right-radius: 4px; }
.cd-msg a { color: var(--coral-dark, #C43F1A); font-weight: 600; }
.cd-msg--note { align-self: center; background: none; color: var(--muted, #6B5A4F); font-size: .8rem; text-align: center; }
.cd-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: .7rem .8rem; background: #fff; border: 1px solid var(--line, #EDE3D6); border-radius: 14px; }
.cd-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--stone, #7A6B60); animation: cd-dot 1s infinite ease-in-out; }
.cd-typing span:nth-child(2) { animation-delay: .15s; }
.cd-typing span:nth-child(3) { animation-delay: .3s; }
.cd-panel__form { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--line, #EDE3D6); background: #fff; }
.cd-panel__form textarea { flex: 1; resize: none; border: 1px solid var(--sand-dark, #D9C9B5); border-radius: 12px; padding: .55rem .7rem; font: inherit; font-size: .92rem; max-height: 6rem; }
.cd-panel__form textarea:focus { outline: 2px solid var(--coral, #E8552A); outline-offset: 0; border-color: transparent; }
.cd-panel__send { width: 2.6rem; border: 0; border-radius: 12px; background: var(--coral, #E8552A); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cd-panel__send:disabled { opacity: .45; cursor: default; }
.cd-panel__foot { margin: 0; padding: .45rem .8rem .6rem; font-size: .72rem; line-height: 1.4; color: var(--muted, #6B5A4F); background: #fff; }
.cd-panel__foot a { color: inherit; text-decoration: underline; }

/* Screenshots in answers, and full size on tap */
.cd-shot { display: block; margin: .5rem 0 .2rem; padding: 0; border: 1px solid var(--line, #EDE3D6); border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in; width: 100%; }
.cd-shot img { display: block; width: 100%; height: auto; }
.cd-shot__cap { display: block; font-size: .76rem; color: var(--muted, #6B5A4F); margin-bottom: .2rem; }
.cd-zoom { position: fixed; inset: 0; z-index: 3000; background: rgba(28, 20, 16, .86); display: grid; place-items: center; padding: 1rem; cursor: zoom-out; }
.cd-zoom img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #fff; }
.cd-zoom__x { position: absolute; top: .75rem; right: .9rem; border: 0; background: none; color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; }

/* "Was this helpful?" under the latest answer */
.cd-rate { align-self: flex-start; display: flex; align-items: center; gap: .3rem; font-size: .76rem; color: var(--muted, #6B5A4F); margin: -.2rem 0 .1rem .2rem; }
.cd-rate button { border: 1px solid var(--line, #EDE3D6); background: #fff; border-radius: 999px; padding: .1rem .45rem; font-size: .85rem; line-height: 1.3; cursor: pointer; }
.cd-rate button:hover, .cd-rate button:focus-visible { background: var(--hover, #F3EBE0); }
.cd-rate a { color: var(--coral-dark, #C43F1A); }
.cd-msg__shot { margin-top: .4rem; }

/* The contact form card in the chat */
.cd-form { align-self: stretch; background: #fff; border: 1px solid var(--line, #EDE3D6); border-left: 4px solid var(--coral, #E8552A); border-radius: 12px; padding: .8rem .85rem; display: grid; gap: .5rem; }
.cd-form__title { margin: 0; font-weight: 700; font-size: .95rem; }
.cd-form label { display: grid; gap: .2rem; font-size: .8rem; font-weight: 600; color: var(--ink, #1C1410); }
.cd-form label small { font-weight: 400; color: var(--muted, #6B5A4F); }
.cd-form input:not([type=checkbox]), .cd-form textarea { border: 1px solid var(--sand-dark, #D9C9B5); border-radius: 8px; padding: .45rem .55rem; font: inherit; font-size: .88rem; font-weight: 400; width: 100%; box-sizing: border-box; }
.cd-form input:focus, .cd-form textarea:focus { outline: 2px solid var(--coral, #E8552A); outline-offset: 0; border-color: transparent; }
.cd-form__tick { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: .45rem !important; font-weight: 400 !important; }
.cd-form__tick input { margin-top: .15rem; }
.cd-form__note { margin: 0; font-size: .74rem; color: var(--muted, #6B5A4F); }
.cd-form__note a { color: inherit; }
.cd-form__err { margin: 0; font-size: .8rem; color: #B42318; font-weight: 600; }
.cd-form__send { border: 0; border-radius: 10px; background: var(--coral, #E8552A); color: #fff; font: inherit; font-weight: 700; padding: .6rem .8rem; cursor: pointer; }
.cd-form__send:hover, .cd-form__send:focus-visible { background: var(--coral-dark, #C43F1A); }
.cd-form__send:disabled { opacity: .6; cursor: default; }

@keyframes cd-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cd-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 480px) {
    .cd-panel { width: calc(100vw - 1.5rem); height: calc(100vh - 6.5rem); height: calc(100dvh - 6.5rem); }
}
@media (prefers-reduced-motion: reduce) {
    .cd-hint, .cd-menu, .cd-panel { animation: none; }
    .cd-typing span { animation: none; }
}
