/*
 * ШІ-асистент підбору. Кольори й шрифти беруться з теми сайту (змінні --rgb-clr-*, --font-family-*);
 * на іншому сайті достатньо перевизначити --ra-* у його темі.
 */
.ra-root {
    --ra-accent: rgb(var(--rgb-clr-primary, 159, 75, 129));
    --ra-accent-dark: rgb(var(--rgb-clr-primary-dark, 111, 53, 90));
    --ra-accent-soft: rgba(var(--rgb-clr-primary, 159, 75, 129), .09);
    --ra-text: rgb(var(--rgb-clr-n900, 13, 19, 33));
    --ra-muted: rgb(var(--rgb-clr-n200, 110, 113, 122));
    --ra-line: rgb(var(--rgb-clr-n40, 224, 224, 226));
    --ra-bg: #fff;
    --ra-bg-soft: rgb(var(--rgb-clr-n20, 245, 246, 246));
    --ra-font: var(--font-family-secondary, inter, system-ui, sans-serif);
    --ra-font-title: var(--font-family-primary, raleway, system-ui, sans-serif);
    --ra-radius: 16px;
    --ra-shadow: 0 12px 40px rgba(13, 19, 33, .22), 0 2px 8px rgba(13, 19, 33, .08);
    font-family: var(--ra-font);
    color: var(--ra-text);
    -webkit-text-size-adjust: 100%;
}
.ra-root *, .ra-root *::before, .ra-root *::after { box-sizing: border-box; }

/* ---------- Кнопка ---------- */
.ra-launch {
    position: fixed;
    left: 1.25rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 1028;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    height: 3.25rem;
    padding: 0 1.15rem 0 .95rem;
    border: 0;
    border-radius: 999px;
    background: var(--ra-accent);
    color: #fff;
    font: 700 .9375rem/1 var(--ra-font-title);
    letter-spacing: .01em;
    box-shadow: 0 6px 20px rgba(var(--rgb-clr-primary, 159, 75, 129), .38);
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease, opacity .2s ease;
}
.ra-launch:hover { background: var(--ra-accent-dark); }
.ra-launch:active { transform: scale(.97); }
.ra-launch:focus-visible { outline: 3px solid rgba(var(--rgb-clr-primary, 159, 75, 129), .35); outline-offset: 3px; }
.ra-launch svg { width: 1.25rem; height: 1.25rem; flex: none; }
.ra-open .ra-launch,
html.cm-fullscreen-open .ra-launch { opacity: 0; pointer-events: none; }
@media (min-width: 768px) {
    .ra-launch { left: 1.875rem; bottom: calc(1.875rem + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Вікно ---------- */
.ra-panel {
    position: fixed;
    z-index: 1065;
    display: none;
    flex-direction: column;
    background: var(--ra-bg);
    overflow: hidden;
}
.ra-open .ra-panel { display: flex; }

/* Телефон: на весь екран; висоту й зсув задає JS за visualViewport, щоб поле вводу не ховалось під клавіатурою */
.ra-panel {
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    height: var(--ra-vh, 100dvh);
    transform: translateY(var(--ra-vt, 0px));
}
html.ra-lock, html.ra-lock body { overflow: hidden; }

/* Планшет і десктоп: вікно в куті */
@media (min-width: 768px) {
    .ra-panel {
        left: 1.875rem;
        top: auto;
        bottom: calc(1.875rem + env(safe-area-inset-bottom, 0px));
        width: 384px;
        height: min(640px, calc(100vh - 7.5rem));
        height: min(640px, calc(100dvh - 7.5rem));
        transform: none;
        border-radius: var(--ra-radius);
        box-shadow: var(--ra-shadow);
        animation: ra-in .18s ease-out;
    }
}
@keyframes ra-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.ra-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .75rem .75rem 1rem;
    padding-top: calc(.75rem + env(safe-area-inset-top, 0px));
    background: var(--ra-accent);
    color: #fff;
}
@media (min-width: 768px) { .ra-head { padding-top: .75rem; } }
.ra-avatar {
    flex: none;
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex; align-items: center; justify-content: center;
}
.ra-avatar svg { width: 1.25rem; height: 1.25rem; }
.ra-head-text { flex: 1; min-width: 0; }
.ra-title { font: 700 1rem/1.2 var(--ra-font-title); }
.ra-subtitle { font-size: .75rem; opacity: .85; margin-top: .125rem; }
.ra-icon-btn {
    flex: none;
    width: 2.5rem; height: 2.5rem;
    border: 0; border-radius: 50%;
    background: transparent; color: inherit;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.ra-icon-btn:hover { background: rgba(255, 255, 255, .15); }
.ra-icon-btn svg { width: 1.25rem; height: 1.25rem; }

/* ---------- Повідомлення ---------- */
.ra-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    background: var(--ra-bg-soft);
    display: flex;
    flex-direction: column;
    gap: .625rem;
}
.ra-msg {
    max-width: 88%;
    padding: .625rem .875rem;
    border-radius: 14px;
    font-size: .9375rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.ra-msg a { color: inherit; text-decoration: underline; }
.ra-msg-bot { align-self: flex-start; background: var(--ra-bg); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(13, 19, 33, .06); }
.ra-msg-user { align-self: flex-end; background: var(--ra-accent); color: #fff; border-bottom-right-radius: 4px; }
.ra-msg-bot a { color: var(--ra-accent); }

.ra-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.ra-chip {
    border: 1px solid rgba(var(--rgb-clr-primary, 159, 75, 129), .35);
    background: var(--ra-bg);
    color: var(--ra-accent);
    border-radius: 999px;
    padding: .5rem .875rem;
    font: 600 .875rem/1.2 var(--ra-font);
    cursor: pointer;
    transition: background-color .15s ease;
}
.ra-chip:hover { background: var(--ra-accent-soft); }

.ra-typing { align-self: flex-start; display: flex; gap: 4px; padding: .875rem 1rem; background: var(--ra-bg); border-radius: 14px; border-bottom-left-radius: 4px; }
.ra-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ra-muted); animation: ra-dot 1.2s infinite ease-in-out; }
.ra-typing i:nth-child(2) { animation-delay: .15s; }
.ra-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ra-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Картки об'єктів ---------- */
.ra-cards { display: flex; flex-direction: column; gap: .5rem; align-self: stretch; }
.ra-card {
    display: flex;
    gap: .75rem;
    padding: .5rem;
    background: var(--ra-bg);
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(13, 19, 33, .06);
    transition: box-shadow .15s ease;
}
.ra-card:hover { box-shadow: 0 4px 14px rgba(13, 19, 33, .12); }
.ra-card-img {
    flex: none;
    width: 6.5rem; height: 5rem;
    border-radius: 8px;
    object-fit: cover;
    background: var(--ra-line);
}
.ra-card-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.ra-card-price { font: 700 1rem/1.2 var(--ra-font-title); color: var(--ra-accent); }
.ra-card-params { font-size: .8125rem; line-height: 1.3; }
.ra-card-place { font-size: .75rem; color: var(--ra-muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ra-card-more { margin-top: auto; font-size: .75rem; font-weight: 600; color: var(--ra-accent); }

/* ---------- Форма заявки ---------- */
.ra-form { align-self: stretch; background: var(--ra-bg); border-radius: 14px; padding: .875rem; display: flex; flex-direction: column; gap: .5rem; box-shadow: 0 1px 2px rgba(13, 19, 33, .06); }
.ra-form-title { font-weight: 700; font-size: .9375rem; }
.ra-field {
    width: 100%;
    border: 1px solid var(--ra-line);
    border-radius: 10px;
    padding: .625rem .75rem;
    font: 400 16px/1.3 var(--ra-font); /* 16px — iOS не масштабує сторінку при фокусі */
    color: var(--ra-text);
    background: #fff;
}
.ra-field:focus { outline: none; border-color: var(--ra-accent); box-shadow: 0 0 0 3px var(--ra-accent-soft); }
textarea.ra-field { resize: none; min-height: 3.5rem; }
.ra-check { display: flex; gap: .5rem; align-items: flex-start; font-size: .8125rem; line-height: 1.35; color: var(--ra-muted); }
.ra-check input { -webkit-appearance: checkbox; appearance: auto; margin: .15rem 0 0; accent-color: var(--ra-accent); width: 1rem; height: 1rem; flex: none; cursor: pointer; }
.ra-form-error { color: rgb(var(--rgb-clr-error, 202, 55, 55)); font-size: .8125rem; min-height: 0; }
.ra-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.ra-btn {
    border: 0; border-radius: 10px;
    background: var(--ra-accent); color: #fff;
    padding: .75rem 1rem;
    font: 700 .9375rem/1 var(--ra-font-title);
    cursor: pointer;
}
.ra-btn:hover { background: var(--ra-accent-dark); }
.ra-btn[disabled] { opacity: .6; cursor: default; }

/* ---------- Поле вводу ---------- */
.ra-foot {
    flex: none;
    border-top: 1px solid var(--ra-line);
    background: var(--ra-bg);
    padding: .625rem .75rem;
    padding-bottom: calc(.625rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) { .ra-foot { padding-bottom: .625rem; } }
.ra-input-row { display: flex; align-items: flex-end; gap: .5rem; }
.ra-input {
    flex: 1;
    min-width: 0;
    max-height: 7.5rem;
    border: 1px solid var(--ra-line);
    border-radius: 20px;
    padding: .55rem .9rem;
    font: 400 16px/1.35 var(--ra-font);
    color: var(--ra-text);
    background: var(--ra-bg-soft);
    resize: none;
    overflow-y: hidden;
}
.ra-input:focus { outline: none; border-color: var(--ra-accent); background: #fff; }
.ra-send {
    flex: none;
    width: 2.5rem; height: 2.5rem;
    border: 0; border-radius: 50%;
    background: var(--ra-accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.ra-send[disabled] { opacity: .45; cursor: default; }
.ra-send svg { width: 1.125rem; height: 1.125rem; }
.ra-consent { margin-top: .4rem; font-size: .6875rem; line-height: 1.35; color: var(--ra-muted); text-align: center; }
.ra-consent a { color: inherit; }
.ra-form-mode .ra-foot { display: none; }
