/* =====================================================================
   AVTOKAR — Chatbot widget
   Save as: public/assets/css/finder.css
   Uses the site's existing tokens (--color-accent, --color-graphite ...)
   with fallbacks, so it also works if a token is missing.
   z-index: 800  (header 500, mobile menu 499, modal 900, loader 9999)
   ===================================================================== */

.chatbot {
    --cb-accent: var(--color-accent, #b11b38);
    --cb-accent-dark: #8f1630;
    --cb-graphite: var(--color-graphite, #1c1f24);
    --cb-graphite-2: var(--color-graphite-2, #262a31);
    --cb-surface: var(--color-surface, #ffffff);
    --cb-surface-alt: var(--color-surface-alt, #eceae4);
    --cb-bg: var(--color-bg, #f4f2ee);
    --cb-text: var(--color-text, #16181c);
    --cb-muted: var(--color-muted, #5b6067);
    --cb-border: var(--color-border, #dcd9d2);
    --cb-gap: 20px;

    position: fixed;
    right: calc(var(--cb-gap) + env(safe-area-inset-right, 0px));
    bottom: calc(var(--cb-gap) + env(safe-area-inset-bottom, 0px));
    z-index: 800;
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: 15px;
    line-height: 1.5;
    color: var(--cb-text);
}

.chatbot *,
.chatbot *::before,
.chatbot *::after { box-sizing: border-box; }

/* The site sets a global grey colour on <p>; the widget uses <div>s only. */

/* ---------- Launcher button ---------- */
.chatbot-fab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cb-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 28px -8px rgba(177, 27, 56, .65), 0 2px 6px rgba(20, 20, 20, .18);
    transition: transform .2s ease, background .2s ease;
}

.chatbot-fab:hover { background: var(--cb-accent-dark); transform: translateY(-2px); }
.chatbot-fab:focus-visible { outline: 3px solid var(--cb-graphite); outline-offset: 3px; }

.chatbot-fab__icon { position: absolute; transition: opacity .2s ease, transform .25s ease; }
.chatbot-fab__icon--close { opacity: 0; transform: rotate(-70deg) scale(.6); }

.chatbot.is-open .chatbot-fab__icon--chat { opacity: 0; transform: rotate(70deg) scale(.6); }
.chatbot.is-open .chatbot-fab__icon--close { opacity: 1; transform: none; }

/* One quiet attention pulse when the page loads, then nothing. */
.chatbot:not(.is-open):not(.is-seen) .chatbot-fab::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--cb-accent);
    animation: chatbot-pulse 2.4s ease-out 3;
    pointer-events: none;
}

@keyframes chatbot-pulse {
    from { transform: scale(1); opacity: .7; }
    to   { transform: scale(1.7); opacity: 0; }
}

/* ---------- Panel ---------- */
.chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 130px));
    height: min(620px, calc(100dvh - 130px));
    overflow: hidden;
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 16px;
    box-shadow: 0 24px 60px -12px rgba(20, 20, 20, .35), 0 4px 14px rgba(20, 20, 20, .12);

    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.chatbot.is-open .chatbot-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

/* ---------- Header ---------- */
.chatbot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 14px 18px;
    background: var(--cb-graphite);
    color: #fff;
    border-bottom: 3px solid var(--cb-accent);
}

.chatbot-head__title {
    font-family: var(--font-display, inherit);
    font-size: 1.25rem;
    line-height: 1.15;
    letter-spacing: .01em;
}

.chatbot-head__sub {
    margin-top: 2px;
    font-size: .8rem;
    color: rgba(255, 255, 255, .65);
}

.chatbot-close {
    flex: 0 0 auto;
    display: none; /* shown on small screens where the launcher is covered */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
}

.chatbot-close:hover { background: rgba(255, 255, 255, .2); }
.chatbot-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Message log ---------- */
.chatbot-log {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chatbot-msg {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
}

.chatbot-msg.is-user { align-items: flex-end; }
.chatbot-msg.is-bot  { align-items: flex-start; }

.chatbot-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.is-bot .chatbot-bubble {
    background: var(--cb-surface);
    color: var(--cb-text);
    border: 1px solid var(--cb-border);
    border-top-left-radius: 4px;
}

.is-user .chatbot-bubble {
    background: var(--cb-accent);
    color: #fff;
    border-top-right-radius: 4px;
}

/* ---------- Result cards ---------- */
.chatbot-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.chatbot-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: 10px;
    color: var(--cb-text);
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.chatbot-card:hover,
.chatbot-card:focus-visible {
    border-color: var(--cb-accent);
    box-shadow: 0 6px 18px -8px rgba(177, 27, 56, .45);
}

.chatbot-card:focus-visible { outline: 2px solid var(--cb-accent); outline-offset: 2px; }

.chatbot-card__thumb {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: repeating-linear-gradient(135deg, var(--cb-surface-alt), var(--cb-surface-alt) 8px, var(--cb-border) 8px, var(--cb-border) 9px);
}

.chatbot-card__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-card__body { flex: 1 1 auto; min-width: 0; }

.chatbot-card__type {
    font-size: .72rem;
    font-weight: 700;
    color: var(--cb-accent);
}

.chatbot-card__title {
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.chatbot-card__desc {
    margin-top: 2px;
    font-size: .82rem;
    line-height: 1.35;
    color: var(--cb-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chatbot-card__go {
    flex: 0 0 auto;
    display: inline-flex;
    color: var(--cb-muted);
    transition: transform .15s ease, color .15s ease;
}

.chatbot-card:hover .chatbot-card__go { color: var(--cb-accent); transform: translateX(2px); }

/* ---------- Quick chips / link row ---------- */
.chatbot-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chatbot-chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--cb-graphite);
    border-radius: 999px;
    background: transparent;
    color: var(--cb-graphite);
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.chatbot-chip:hover { background: var(--cb-graphite); color: #fff; }
.chatbot-chip:focus-visible { outline: 2px solid var(--cb-accent); outline-offset: 2px; }

/* ---------- Typing indicator ---------- */
.chatbot-typing {
    display: inline-flex;
    gap: 5px;
    padding: 14px 16px;
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: 14px;
    border-top-left-radius: 4px;
}

.chatbot-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-muted);
    animation: chatbot-dot 1.1s ease-in-out infinite;
}
.chatbot-typing i:nth-child(2) { animation-delay: .15s; }
.chatbot-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes chatbot-dot {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%           { opacity: 1;  transform: translateY(-4px); }
}

/* ---------- Input row ---------- */
.chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
}

.chatbot-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--cb-border);
    border-radius: 999px;
    background: var(--cb-bg);
    color: var(--cb-text);
    font: inherit;
    font-size: 16px; /* 16px stops iOS Safari from zooming the page on focus */
}

.chatbot-input::placeholder { color: var(--cb-muted); }
.chatbot-input:focus { outline: none; border-color: var(--cb-accent); box-shadow: 0 0 0 3px rgba(177, 27, 56, .15); }

.chatbot-send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cb-accent);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, opacity .15s ease;
}

.chatbot-send:hover { background: var(--cb-accent-dark); }
.chatbot-send:focus-visible { outline: 2px solid var(--cb-graphite); outline-offset: 2px; }
.chatbot-send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tablet ---------- */
@media (max-width: 960px) and (min-width: 601px) {
    .chatbot-panel { width: min(400px, calc(100vw - 40px)); }
}

/* ---------- Mobile: full-screen sheet ---------- */
@media (max-width: 600px) {
    .chatbot { --cb-gap: 14px; }

    .chatbot-fab { width: 56px; height: 56px; }

    .chatbot-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        transform: translateY(24px);
    }

    .chatbot.is-open .chatbot-panel { transform: none; }

    /* Header needs room for the notch. */
    .chatbot-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
    .chatbot-close { display: inline-flex; }

    /* The full-screen sheet covers the launcher. */
    .chatbot.is-open .chatbot-fab { visibility: hidden; }

    .chatbot-bubble { max-width: 92%; }
}

/* Stop the page scrolling behind the full-screen sheet on phones. */
@media (max-width: 600px) {
    html.chatbot-lock,
    html.chatbot-lock body { overflow: hidden; overscroll-behavior: none; }
}

/* Short landscape phones: keep the panel usable. */
@media (max-height: 480px) and (min-width: 601px) {
    .chatbot-panel { height: calc(100vh - 100px); bottom: 70px; }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot *,
    .chatbot *::before,
    .chatbot *::after {
        animation: none !important;
        transition-duration: .01ms !important;
    }
}