/* RRH Assistant chat widget (js/rrh-ai-chat.js). Sits above the WhatsApp button. */
.rrh-ai {
    --ai-navy: var(--t-navy, #0e2747);
    --ai-navy-deep: var(--t-navy-deep, #0a1c34);
    --ai-blue: var(--t-blue, #1d5bc6);
    --ai-yellow: var(--t-yellow, #ecce27);
    --ai-yellow-dark: var(--t-yellow-dark, #d9b912);
    --ai-ink: var(--t-ink, #142033);
    --ai-text: var(--t-text, #3b4656);
    --ai-muted: var(--t-muted, #687384);
    --ai-line: var(--t-line, #e4e7ec);
    --ai-surface: #f3f5f8;
    --ai-wa: #128c4a;
    font-family: var(--t-font, "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
    font-size: 14px;
    line-height: 1.5;
}

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

.rrh-ai button {
    font: inherit;
}

/* ---------- Launcher: a labelled pill on desktop, a round button on phones ---------- */
.rrh-ai-launcher {
    position: fixed;
    right: 18px;
    bottom: 86px;
    z-index: 1031;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 20px 0 15px;
    border: 2px solid var(--ai-navy);
    border-radius: 999px;
    color: var(--ai-navy);
    background: var(--ai-yellow); /* yellow like the site header: shows on the navy hero and on white pages */
    box-shadow: 0 8px 22px rgba(10, 28, 52, .28);
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease;
}

.rrh-ai-launcher svg {
    flex: 0 0 auto;
}

.rrh-ai-launcher__label {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .01em;
}

.rrh-ai-launcher:hover {
    background: var(--ai-yellow-dark);
    transform: translateY(-1px);
}

.rrh-ai-launcher:focus-visible {
    outline: 3px solid var(--ai-blue);
    outline-offset: 3px;
}

.rrh-ai.is-open .rrh-ai-launcher {
    color: var(--ai-yellow);
    background: var(--ai-navy);
    border-color: var(--ai-navy);
}

/* ---------- One-time hint ---------- */
.rrh-ai-teaser {
    position: fixed;
    right: 18px;
    bottom: 150px;
    z-index: 1031;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    max-width: 250px;
    padding: 4px 4px 4px 0;
    border: 1px solid var(--ai-line);
    border-radius: 14px 14px 4px 14px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(10, 28, 52, .18);
    animation: rrhAiPop .25s ease-out;
}

.rrh-ai-teaser[hidden] {
    display: none;
}

.rrh-ai-teaser__text {
    padding: 8px 4px 8px 14px;
    border: 0;
    color: var(--ai-ink);
    background: none;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}

.rrh-ai-teaser__close {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    color: var(--ai-muted);
    background: none;
    cursor: pointer;
}

.rrh-ai-teaser__close:hover,
.rrh-ai-teaser__close:focus-visible {
    color: var(--ai-ink);
    background: var(--ai-surface);
    outline: none;
}

@keyframes rrhAiPop {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to { opacity: 1; transform: none; }
}

/* ---------- Panel ---------- */
.rrh-ai-panel {
    position: fixed;
    right: 18px;
    bottom: 150px;
    z-index: 9990; /* above the language button (9990, earlier in the page), below its open panel (9991+) */
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 36px);
    height: 620px;
    max-height: calc(100vh - 170px);
    overflow: hidden;
    border-radius: 18px;
    color: var(--ai-text);
    background: var(--ai-surface);
    box-shadow: 0 24px 60px rgba(10, 28, 52, .28), 0 0 0 1px rgba(10, 28, 52, .06);
    animation: rrhAiIn .2s ease-out;
    transform-origin: bottom right;
}

.rrh-ai-panel[hidden] {
    display: none;
}

@keyframes rrhAiIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.rrh-ai-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 11px;
    padding: 13px 10px 13px 14px;
    border-bottom: 3px solid var(--ai-yellow);
    color: #fff;
    background: var(--ai-navy);
}

.rrh-ai-avatar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: var(--ai-navy);
    background: var(--ai-yellow);
}

.rrh-ai-avatar svg {
    width: 21px;
    height: 21px;
}

.rrh-ai-titles {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.rrh-ai-titles strong {
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.25;
}

.rrh-ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.rrh-ai-status::before {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3ddc84;
    box-shadow: 0 0 0 3px rgba(61, 220, 132, .18);
}

.rrh-ai-iconbtn {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    color: rgba(255, 255, 255, .85);
    background: transparent;
    cursor: pointer;
}

.rrh-ai-iconbtn:hover,
.rrh-ai-iconbtn:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    outline: none;
}

/* ---------- Conversation ---------- */
.rrh-ai-log {
    position: relative; /* so message offsetTop is measured inside the log */
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px 8px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

.rrh-ai-welcome {
    margin-bottom: 16px;
}

.rrh-ai-welcome__title {
    margin: 2px 0 6px;
    color: var(--ai-navy);
    font-family: inherit;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.rrh-ai-welcome__text {
    margin: 0 0 14px;
    color: var(--ai-text);
    font-size: 13.5px;
}

.rrh-ai-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.rrh-ai-shortcut {
    padding: 7px 13px;
    border: 1px solid #cfd8e6;
    border-radius: 999px;
    color: var(--ai-navy);
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.rrh-ai-shortcut:hover,
.rrh-ai-shortcut:focus-visible {
    border-color: var(--ai-navy);
    background: #fffbe3;
    outline: none;
}

.rrh-ai-msg {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 12px;
}

.rrh-ai-msg--user {
    align-items: flex-end;
}

.rrh-ai-bubble {
    max-width: 90%;
    padding: 10px 13px;
    border-radius: 16px;
    overflow-wrap: anywhere;
}

.rrh-ai-msg--assistant .rrh-ai-bubble {
    border: 1px solid var(--ai-line);
    border-top-left-radius: 5px;
    color: var(--ai-text);
    background: #fff;
}

.rrh-ai-msg--user .rrh-ai-bubble {
    border-top-right-radius: 5px;
    color: #fff;
    background: var(--ai-navy);
    white-space: pre-wrap;
}

.rrh-ai-msg--error .rrh-ai-bubble {
    border-color: #f0c7c7;
    background: #fff5f5;
}

.rrh-ai-bubble p,
.rrh-ai-bubble ul,
.rrh-ai-bubble ol {
    margin: 0 0 7px;
}

.rrh-ai-bubble > :last-child {
    margin-bottom: 0;
}

.rrh-ai-bubble ul,
.rrh-ai-bubble ol {
    padding-left: 18px;
}

.rrh-ai-bubble li {
    margin-bottom: 5px;
}

.rrh-ai-bubble li::marker {
    color: var(--ai-yellow-dark);
}

.rrh-ai-bubble a {
    color: var(--ai-blue);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.rrh-ai-bubble strong {
    color: var(--ai-ink);
    font-weight: 600;
}

.rrh-ai-retry {
    margin-top: 6px;
    padding: 6px 14px;
    border: 1px solid var(--ai-navy);
    border-radius: 999px;
    color: var(--ai-navy);
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.rrh-ai-retry:hover,
.rrh-ai-retry:focus-visible {
    color: #fff;
    background: var(--ai-navy);
    outline: none;
}

/* ---------- Product cards: a swipeable strip under an answer ---------- */
.rrh-ai-products {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
}

.rrh-ai-cards {
    display: flex;
    gap: 8px;
    width: calc(100% + 28px);
    margin: 0 -14px;
    padding: 2px 14px 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 14px;
    scrollbar-width: thin;
}

.rrh-ai-card {
    display: flex;
    flex: 0 0 150px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ai-line);
    border-radius: 12px;
    color: var(--ai-ink);
    background: #fff;
    text-decoration: none;
    scroll-snap-align: start;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rrh-ai-card:hover,
.rrh-ai-card:focus-visible {
    border-color: var(--ai-navy);
    box-shadow: 0 4px 14px rgba(10, 28, 52, .12);
    color: var(--ai-ink);
    text-decoration: none;
    outline: none;
}

.rrh-ai-card__media {
    position: relative;
    display: block;
    flex: 0 0 auto;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #eef1f5;
}

.rrh-ai-card__media img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rrh-ai-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px 10px;
}

.rrh-ai-card__name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rrh-ai-card__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    margin-top: auto;
    padding-top: 2px;
}

.rrh-ai-card__price b {
    color: var(--ai-navy);
    font-size: 15px;
    font-weight: 600;
}

.rrh-ai-card__price s {
    color: var(--ai-muted);
    font-size: 12px;
}

.rrh-ai-card__moq {
    color: var(--ai-muted);
    font-size: 11.5px;
}

/* One product: lay the card out sideways so it does not look lonely */
.rrh-ai-cards.is-single .rrh-ai-card {
    flex: 1 1 auto;
    flex-direction: row;
    max-width: 100%;
}

.rrh-ai-cards.is-single .rrh-ai-card__media {
    flex: 0 0 92px;
    width: 92px;
    aspect-ratio: auto;
}

.rrh-ai-cards.is-single .rrh-ai-card__body {
    justify-content: center;
}

.rrh-ai-quote {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 1px solid #b9e4c9;
    border-radius: 999px;
    color: var(--ai-wa);
    background: #eaf8f0;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.rrh-ai-quote:hover,
.rrh-ai-quote:focus-visible {
    border-color: var(--ai-wa);
    color: #fff;
    background: var(--ai-wa);
    text-decoration: none;
    outline: none;
}

/* ---------- Typing ---------- */
.rrh-ai-typing .rrh-ai-bubble {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ai-muted);
    font-size: 13px;
}

.rrh-ai-dots {
    display: inline-flex;
    gap: 4px;
}

.rrh-ai-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ai-navy);
    opacity: .3;
    animation: rrhAiDot 1s infinite ease-in-out;
}

.rrh-ai-dots i:nth-child(2) { animation-delay: .15s; }
.rrh-ai-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes rrhAiDot {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Composer ---------- */
.rrh-ai-form {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    gap: 8px;
    margin: 0 10px;
    padding: 6px 6px 6px 4px;
    border: 1px solid var(--ai-line);
    border-radius: 16px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rrh-ai-form:focus-within {
    border-color: var(--ai-navy);
    box-shadow: 0 0 0 3px rgba(14, 39, 71, .10);
}

.rrh-ai-input {
    flex: 1 1 auto;
    min-height: 38px;
    max-height: 110px;
    padding: 8px 10px;
    border: 0;
    color: var(--ai-ink);
    background: transparent;
    font: inherit;
    font-size: 16px; /* 16px stops iOS from zooming in */
    line-height: 1.35;
    resize: none;
}

.rrh-ai-input:focus {
    outline: none;
}

.rrh-ai-input::placeholder {
    color: #8b95a4;
}

.rrh-ai-send {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    color: var(--ai-navy);
    background: var(--ai-yellow);
    cursor: pointer;
    transition: background-color .15s ease, opacity .15s ease;
}

.rrh-ai-send:hover:not(:disabled),
.rrh-ai-send:focus-visible {
    background: var(--ai-yellow-dark);
    outline: none;
}

.rrh-ai-send:disabled {
    color: #9aa3b1;
    background: #eceff3;
    cursor: default;
}

.rrh-ai-input:disabled {
    opacity: .6;
}

.rrh-ai-foot {
    flex: 0 0 auto;
    padding: 7px 14px 10px;
    color: var(--ai-muted);
    font-size: 11.5px;
    text-align: center;
}

.rrh-ai-foot a {
    color: var(--ai-wa);
    font-weight: 500;
}

/* ---------- Phones: round launcher above WhatsApp, chat as a full-screen sheet ---------- */
@media (max-width: 575.98px) {
    .rrh-ai-launcher {
        right: 14px;
        bottom: 76px;
        justify-content: center;
        width: 52px;
        height: 52px;
        padding: 0;
        border-radius: 50%;
    }

    .rrh-ai-launcher__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .rrh-ai-teaser {
        right: 14px;
        bottom: 138px;
        max-width: calc(100vw - 28px);
    }

    .rrh-ai-panel {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation-name: rrhAiUp;
    }

    .rrh-ai-head {
        padding-top: max(13px, env(safe-area-inset-top));
    }

    .rrh-ai.is-open .rrh-ai-launcher,
    .rrh-ai.is-open .rrh-ai-teaser {
        display: none;
    }

    /* The full-screen chat covers the page, so the language button would only sit on top of it */
    html.rrh-ai-open #rrh-lang {
        display: none;
    }

    html.rrh-ai-open,
    html.rrh-ai-open body {
        overflow: hidden;
    }
}

@keyframes rrhAiUp {
    from { transform: translateY(24px); opacity: .6; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .rrh-ai-launcher,
    .rrh-ai-panel,
    .rrh-ai-teaser,
    .rrh-ai-dots i,
    .rrh-ai-log {
        animation: none;
        transition: none;
        scroll-behavior: auto;
    }
}

@media print {
    .rrh-ai {
        display: none;
    }
}
