/* ============================================================
   chat.css — віджет онлайн-помічника «Друкарня РАЗ»
   ============================================================

   Перенесено з template-styles.css (блок CHATBOT RAZ STYLES).
   Оригінал там навмисно лишився: старі сторінки ще підключають
   template-styles.css і мають продовжувати працювати. Нові сторінки
   вантажать цей файл — він самодостатній, тож коли старий шаблон
   піде, забирати звідси нічого не доведеться.

   Розмітка: includes/chat.php   Поведінка: /assets/chat.js
   Токени беруться з /assets/ui.css, але кожне значення має запасний
   літерал: віджет мусить виглядати правильно й на сторінках, куди
   ui.css ще не дійшов.
   ============================================================ */

#razChatBtn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-brand, #DA1A32), #b8111f);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(218, 26, 50, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform .25s, box-shadow .25s;
}
#razChatBtn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(218, 26, 50, .55); }

/* Крапка «є що сказати» на кнопці: поза робочими годинами вона
   заздалегідь повідомляє, що бот на місці, а менеджер — ні. */
#razChatBtn::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--c-green, #7AB72B);
}
#razChatBtn.raz-btn--offline::after { background: var(--c-gold, #FFC857); }

#razChatWindow {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 370px;
    max-height: 580px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 50px rgba(30, 58, 95, .18);
    display: flex;
    flex-direction: column;
    z-index: 9997;
    overflow: hidden;
    transform: scale(.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), opacity .25s;
}
#razChatWindow.raz-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#razChatHeader {
    background: linear-gradient(135deg, var(--c-navy, #1E3A5F), #2a5080);
    padding: 16px 18px;
    color: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
#razChatHeaderInfo { display: flex; align-items: center; gap: 12px; }
#razChatAvatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--c-brand, #DA1A32);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; letter-spacing: .5px;
    flex-shrink: 0;
}
#razChatTitle { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 7px; }

#razChatStatus { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; opacity: .85; }

#razStatusDot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-green, #7AB72B);
    flex-shrink: 0;
    animation: razPulse 2s infinite;
}
/* Поза робочими годинами крапка не пульсує: рух читається як
   «хтось зараз друкує», а зараз друкує тільки бот. */
#razChatStatus.is-offline #razStatusDot {
    background: var(--c-gold, #FFC857);
    animation: none;
}

@keyframes razPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .4; }
}

/* Хрестик у шапці вікна — для клавіатури й для мобільного, де
   плаваюча кнопка ховається під вікном чату */
#razChatWindowClose {
    background: rgba(255, 255, 255, .14);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s;
}
#razChatWindowClose:hover { background: rgba(255, 255, 255, .28); }

#razChatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#razChatMessages::-webkit-scrollbar { width: 4px; }
#razChatMessages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.raz-msg { display: flex; }
.raz-msg-bot  { justify-content: flex-start; }
.raz-msg-user { justify-content: flex-end; }

.raz-bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
}
.raz-msg-bot .raz-bubble {
    background: #f0f4f9;
    color: var(--g-900, #222);
    border-bottom-left-radius: 4px;
}
.raz-msg-user .raz-bubble {
    background: linear-gradient(135deg, var(--c-brand, #DA1A32), #b8111f);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Примітка в першій репліці — тон пояснення, не вибачення.
   Тут же живе застереження, що листування нікуди не передається. */
.raz-hint {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(30, 58, 95, .10);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--g-700, #667085);
}

/* Телефон менеджера — єдина дія в примітці, тож має читатись як дія */
.raz-hint a {
    color: var(--c-brand, #DA1A32);
    font-weight: 600;
    white-space: nowrap;
}

.raz-typing { display: flex; align-items: center; gap: 5px; padding: 12px 14px; }
.raz-typing span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--c-accent, #3AAFD9);
    animation: razBounce .9s infinite;
}
.raz-typing span:nth-child(2) { animation-delay: .15s; }
.raz-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes razBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-8px); }
}

#razImagePreview {
    padding: 6px 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
#razImageThumb {
    height: 52px;
    border-radius: 8px;
    border: 2px solid #eee;
    object-fit: cover;
}
#razImageRemove {
    background: var(--c-brand, #DA1A32);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#razChatInputArea {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

#razUploadBtn {
    color: var(--g-400, #999);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: color .2s;
    flex-shrink: 0;
}
#razUploadBtn:hover { color: var(--c-brand, #DA1A32); }

#razChatInput {
    flex: 1;
    border: 1.5px solid var(--g-200, #e0e0e0);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 110px;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color .2s;
}
#razChatInput:focus { border-color: var(--c-accent, #3AAFD9); }

#razSendBtn {
    background: var(--c-brand, #DA1A32);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .15s;
}
#razSendBtn:hover    { background: #b8111f; }
#razSendBtn:active   { transform: scale(.93); }
#razSendBtn:disabled { background: var(--g-300, #ccc); cursor: not-allowed; }

.raz-link {
    color: var(--c-navy, #1E3A5F);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color .2s;
}
.raz-link:hover { color: var(--c-brand, #DA1A32); }

@media (max-width: 420px) {
    #razChatWindow { width: calc(100vw - 20px); right: 10px; bottom: 90px; max-height: 70vh; }
    #razChatBtn    { bottom: 20px; right: 16px; width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
    #razChatBtn,
    #razChatWindow { transition: none; }
    #razStatusDot,
    .raz-typing span { animation: none; }
}

/* ============================================================
   ПЕРЕДАЧА МЕНЕДЖЕРУ (assets/chat-handoff.js)
   Смуга над полем вводу: тиха, поки не потрібна, і завжди на місці —
   людина не має вгадувати, як вийти на живого співрозмовника.
   ============================================================ */
.raz-handoff {
    flex-shrink: 0;
    padding: 8px 12px;
    border-top: 1px solid #eee;
    background: var(--g-50, #F7F9FB);
}

.raz-handoff__call {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--g-200, #E3E8EF);
    border-radius: 10px;
    color: var(--c-navy, #1E3A5F);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .18s, color .18s;
}
.raz-handoff__call:hover {
    border-color: var(--c-brand, #DA1A32);
    color: var(--c-brand, #DA1A32);
}

.raz-handoff__form { display: flex; flex-direction: column; gap: 8px; }

.raz-handoff__lead {
    font-size: 12px;
    line-height: 1.45;
    color: var(--g-700, #667085);
}

.raz-handoff__contact,
.raz-handoff__note {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--g-200, #E3E8EF);
    border-radius: 9px;
    font: inherit;
    font-size: 13px;
    color: var(--g-900, #202939);
    background: #fff;
    resize: none;
}
.raz-handoff__contact:focus,
.raz-handoff__note:focus {
    outline: none;
    border-color: var(--c-accent, #3AAFD9);
    box-shadow: 0 0 0 3px rgba(58, 175, 217, .16);
}

.raz-handoff__row { display: flex; gap: 8px; }

.raz-handoff__send,
.raz-handoff__cancel {
    padding: 9px 14px;
    border-radius: 9px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}
.raz-handoff__send {
    flex: 1;
    background: var(--c-brand, #DA1A32);
    color: #fff;
}
.raz-handoff__send:hover:not(:disabled) { background: var(--c-brand-dark, #B81528); }
.raz-handoff__send:disabled { opacity: .6; cursor: default; }
.raz-handoff__cancel {
    background: #fff;
    border-color: var(--g-200, #E3E8EF);
    color: var(--g-700, #667085);
}
.raz-handoff__cancel:hover { border-color: var(--g-400, #9AA4B2); }

.raz-handoff__err {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--c-danger, #C0392B);
    background: var(--c-danger-bg, #FFF0EF);
    border: 1px solid var(--c-danger-line, #F5C6C2);
    border-radius: 8px;
    padding: 8px 10px;
}
.raz-handoff__err[hidden],
.raz-handoff__form[hidden],
.raz-handoff__call[hidden] { display: none; }

/* Підтвердження про передачу — не слова ШІ, а факт системи,
   тож і виглядає інакше: зелена смуга замість звичайної репліки. */
.raz-bubble--system {
    background: var(--c-ok-bg, #F2F9F4) !important;
    border: 1px solid var(--c-ok-line, #CFE8D6);
    border-left: 3px solid var(--c-ok, #2C6B41);
    color: var(--c-ok, #2C6B41) !important;
}
