/* ============================================================
   CHAT.CSS — виджет онлайн-чата (пастельный брендинг, минимализм)
   Все классы с префиксом .pf-chat, конфликтов со стилями сайта нет.
   ============================================================ */

.pf-chat {
    --chat-accent:    #b89b8a;
    --chat-accent-dk: #9c7f6e;
    --chat-text:      #3d3a38;
    --chat-muted:     #8a8480;
    --chat-border:    #ece6e1;
    --chat-bg:        #faf7f5;
    --chat-card:      #ffffff;
    --chat-shadow:    0 18px 48px rgba(120, 100, 90, 0.22);

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 965;
    font-family: inherit;
}

/* ---------- Круглая кнопка ---------- */
.pf-chat__toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #c8b0a1, var(--chat-accent));
    color: #fff;
    box-shadow: 0 10px 28px rgba(184, 155, 138, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .25s ease, box-shadow .25s ease;
    animation: pf-chat-pulse 3.2s ease-in-out infinite;
}

.pf-chat__toggle:hover { transform: scale(1.06); }
.pf-chat__toggle:active { transform: scale(.97); }
.pf-chat.is-open .pf-chat__toggle { animation: none; }

.pf-chat__toggle-icon svg { width: 26px; height: 26px; display: block; }

/* Мягкая пульсация, чтобы кнопку замечали */
@keyframes pf-chat-pulse {
    0%, 100%   { box-shadow: 0 10px 28px rgba(184, 155, 138, 0.45); }
    50%        { box-shadow: 0 10px 28px rgba(184, 155, 138, 0.45), 0 0 0 12px rgba(184, 155, 138, 0.12); }
}

.pf-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #c46b6b;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(196, 107, 107, 0.5);
}

/* ---------- Окно чата ---------- */
.pf-chat__window {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: var(--chat-card);
    border: 1px solid var(--chat-border);
    border-radius: 18px;
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pf-chat-appear .22s ease;
}

/* Атрибут hidden должен побеждать display:flex */
.pf-chat__window[hidden] { display: none; }

@keyframes pf-chat-appear {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pf-chat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #c8b0a1, var(--chat-accent));
    color: #fff;
}

.pf-chat__head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-chat__head-text strong { font-size: 15px; font-weight: 600; }
.pf-chat__hint { font-size: 12px; opacity: .85; }

.pf-chat__close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background .2s ease;
}
.pf-chat__close:hover { background: rgba(255, 255, 255, 0.3); }

/* ---------- Лента сообщений ---------- */
.pf-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.pf-chat__msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--chat-text);
    word-wrap: break-word;
    white-space: pre-line;
}

.pf-chat__msg--user {
    align-self: flex-end;
    background: var(--chat-accent);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.pf-chat__msg--admin {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 6px;
}

.pf-chat__msg-time {
    display: block;
    font-size: 11px;
    opacity: .7;
    margin-top: 4px;
}

/* Подсказка-приветствие */
.pf-chat__hello {
    align-self: center;
    text-align: center;
    color: var(--chat-muted);
    font-size: 13px;
    line-height: 1.5;
    max-width: 90%;
    padding: 10px 6px;
}

/* ---------- Форма имени и ввода ---------- */
.pf-chat__name,
.pf-chat__form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-card);
}

.pf-chat__name { flex-direction: column; }
.pf-chat__name[hidden],
.pf-chat__form[hidden] { display: none; }

.pf-chat__name label { font-size: 13px; color: var(--chat-muted); }
.pf-chat__name-row { display: flex; gap: 8px; }

.pf-chat__name input,
.pf-chat__form textarea {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--chat-text);
    background: var(--chat-bg);
    outline: none;
    resize: none;
    transition: border-color .2s ease;
}

.pf-chat__name input:focus,
.pf-chat__form textarea:focus { border-color: var(--chat-accent); }

.pf-chat__send {
    flex-shrink: 0;
    min-width: 44px;
    height: 42px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    background: var(--chat-accent);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
}
.pf-chat__send:hover { background: var(--chat-accent-dk); }
.pf-chat__send:disabled { opacity: .6; cursor: default; }
.pf-chat__send svg { width: 20px; height: 20px; }

.pf-chat__error {
    padding: 0 12px 12px;
    font-size: 13px;
    color: #b85c5c;
    background: var(--chat-card);
}

.pf-chat__error[hidden] { display: none; }

/* ---------- Мобильные ---------- */
@media (max-width: 600px) {
    .pf-chat { right: 16px; bottom: 16px; }

    .pf-chat__toggle { width: 54px; height: 54px; }

    .pf-chat__window {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 82vh;
        max-height: 82vh;
        border-radius: 18px 18px 0 0;
    }
}

/* Уважаем настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
    .pf-chat__toggle { animation: none; }
    .pf-chat__window { animation: none; }
    .pf-chat__messages { scroll-behavior: auto; }
}
