/* ============================================================
   Консультант P-DTR — плавающий виджет-чат
   Бренд-акцент: красный #E93628 (RGB 233,54,40) — КАНОН_КОНТЕНТА.md
   z-index: FAB 9990, окно 9995 — ниже модалки записи (10000),
   чтобы форма записи всегда была сверху.
   ============================================================ */

.pdtr-cw,
.pdtr-cw * {
    box-sizing: border-box;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.pdtr-cw {
    --cw-red: #E93628;
    --cw-red-dark: #c62a20;
    --cw-ink: #1f2937;
    --cw-muted: #6b7280;
    --cw-line: #e5e7eb;
    --cw-bg: #ffffff;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9990;
}

/* ---------- Плавающая кнопка ---------- */
.pdtr-cw__fab {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, var(--cw-red), var(--cw-red-dark));
    box-shadow: 0 8px 22px rgba(233, 54, 40, 0.42), 0 2px 6px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: pdtr-cw-pulse 2.6s ease-out infinite;
}
.pdtr-cw__fab:hover { transform: scale(1.06); }
.pdtr-cw__fab:active { transform: scale(0.97); }
.pdtr-cw__fab svg { width: 30px; height: 30px; fill: #fff; }
.pdtr-cw__fab-img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.85); }

/* мягкая пульсация-ореол */
@keyframes pdtr-cw-pulse {
    0%   { box-shadow: 0 8px 22px rgba(233,54,40,0.42), 0 0 0 0 rgba(233,54,40,0.45); }
    70%  { box-shadow: 0 8px 22px rgba(233,54,40,0.42), 0 0 0 16px rgba(233,54,40,0); }
    100% { box-shadow: 0 8px 22px rgba(233,54,40,0.42), 0 0 0 0 rgba(233,54,40,0); }
}
@media (prefers-reduced-motion: reduce) {
    .pdtr-cw__fab { animation: none; }
}

/* значок «онлайн» */
.pdtr-cw__dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 13px; height: 13px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* ---------- Облачко-приманка ---------- */
.pdtr-cw__teaser {
    position: absolute;
    right: 0;
    bottom: 92px;
    width: 258px;
    max-width: calc(100vw - 40px);
    background: #fff;
    color: var(--cw-ink);
    font-size: 14px;
    line-height: 1.4;
    padding: 13px 34px 13px 15px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 10px 30px rgba(20, 40, 80, 0.18);
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.pdtr-cw__teaser.is-shown {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.pdtr-cw__teaser-close {
    position: absolute;
    top: 6px; right: 8px;
    background: none; border: none;
    font-size: 18px; line-height: 1;
    color: #9ca3af; cursor: pointer;
    padding: 2px;
}
.pdtr-cw__teaser-close:hover { color: var(--cw-ink); }

/* ---------- Окно чата ---------- */
.pdtr-cw__panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: var(--cw-bg);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 30, 60, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 9995;
}
.pdtr-cw__panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Шапка */
.pdtr-cw__head {
    background: linear-gradient(135deg, var(--cw-red), var(--cw-red-dark));
    color: #fff;
    padding: 15px 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}
.pdtr-cw__avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pdtr-cw__avatar svg { width: 22px; height: 22px; fill: #fff; }
.pdtr-cw__avatar img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.pdtr-cw__head-txt { flex: 1; min-width: 0; }
.pdtr-cw__title { font-size: 15px; font-weight: 700; }
.pdtr-cw__status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; }
.pdtr-cw__status::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80; display: inline-block;
}
.pdtr-cw__close {
    background: none; border: none; color: #fff;
    cursor: pointer; padding: 4px; opacity: 0.85;
    font-size: 22px; line-height: 1;
}
.pdtr-cw__close:hover { opacity: 1; }

/* Лента сообщений */
.pdtr-cw__log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pdtr-cw__msg {
    max-width: 82%;
    padding: 10px 13px;
    font-size: 14px;
    line-height: 1.45;
    border-radius: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.pdtr-cw__msg--bot {
    align-self: flex-start;
    background: #fff;
    color: var(--cw-ink);
    border: 1px solid var(--cw-line);
    border-bottom-left-radius: 4px;
}
.pdtr-cw__msg--user {
    align-self: flex-end;
    background: var(--cw-red);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* «печатает…» */
.pdtr-cw__typing {
    align-self: flex-start;
    display: flex; gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--cw-line);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.pdtr-cw__typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #b6bcc6;
    animation: pdtr-cw-typing 1.2s infinite ease-in-out;
}
.pdtr-cw__typing span:nth-child(2) { animation-delay: 0.18s; }
.pdtr-cw__typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes pdtr-cw-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Мини-форма контакта */
.pdtr-cw__lead {
    padding: 12px 14px;
    border-top: 1px solid var(--cw-line);
    background: #fff;
    display: none;
    flex-direction: column;
    gap: 8px;
}
.pdtr-cw__lead.is-shown { display: flex; }
.pdtr-cw__lead-title {
    font-size: 13px; font-weight: 600; color: var(--cw-ink);
}
.pdtr-cw__lead input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--cw-line);
    border-radius: 10px;
    outline: none;
}
.pdtr-cw__lead input:focus { border-color: var(--cw-red); }
.pdtr-cw__lead-btn {
    padding: 11px;
    background: var(--cw-red);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px; font-weight: 700;
    cursor: pointer;
}
.pdtr-cw__lead-btn:disabled { opacity: 0.6; cursor: default; }
.pdtr-cw__consent {
    font-size: 10.5px; line-height: 1.35; color: var(--cw-muted);
}
.pdtr-cw__consent a { color: var(--cw-red); }

/* Поле ввода */
.pdtr-cw__input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--cw-line);
    background: #fff;
    flex-shrink: 0;
}
.pdtr-cw__input textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--cw-line);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    max-height: 96px;
    outline: none;
}
.pdtr-cw__input textarea:focus { border-color: var(--cw-red); }
.pdtr-cw__send {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--cw-red);
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.pdtr-cw__send:hover { background: var(--cw-red-dark); }
.pdtr-cw__send:disabled { opacity: 0.5; cursor: default; }
.pdtr-cw__send svg { width: 19px; height: 19px; fill: #fff; }

/* ---------- Мобильные ---------- */
@media (max-width: 480px) {
    .pdtr-cw { right: 16px; bottom: 80px; }  /* выше липкой панели «Записаться» на index.php */
    .pdtr-cw__panel {
        right: 0; bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .pdtr-cw__teaser { bottom: 92px; }
}
