/* ============================================================
   CNTL AI-чат — виджет (кнопка-капсула + окно)
   Дизайн согласован 2026-06-11. Подключается из footer.php.
   ============================================================ */

.cntl-chat * { box-sizing: border-box; }

/* Cookie-pill живёт в том же углу — уводим его правее кнопки чата */
body.cntl-chat-ready .cookie-banner { left: 168px; }
@media (max-width: 560px) {
    body.cntl-chat-ready .cookie-banner { left: 1rem; bottom: 5.25rem; }
}

/* ---------- Кнопка-капсула ---------- */
.cntl-chat-btn {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 240;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 13px 20px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: #050505;
    color: var(--text, #EDEDED);
    font: 500 13px/1 'Geist Mono', monospace;
    letter-spacing: 0.04em;
    cursor: pointer;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.45s, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.2s, box-shadow 0.2s;
}
.cntl-chat-btn.is-in { opacity: 1; transform: translateY(0); }
.cntl-chat-btn:hover {
    border-color: rgba(255, 255, 255, 0.34);
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.12);
}
.cntl-chat-btn .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
    animation: cntl-dot 2.4s ease-in-out infinite;
}
@keyframes cntl-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- Окно ---------- */
.cntl-chat-win {
    position: fixed;
    left: 24px;
    bottom: 96px;
    z-index: 245;
    width: 392px;
    height: min(600px, calc(100dvh - 130px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 22px;
    background: linear-gradient(180deg, #0B0B0D 0%, #070708 100%);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.75), 0 0 60px rgba(37, 99, 235, 0.10);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    transform: translateY(18px) scale(0.97);
    transform-origin: 15% 100%;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.34s, transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                visibility 0s linear 0.34s;
}
.cntl-chat-win.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

.cntl-chat-hairline {
    flex-shrink: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--indigo,#1E40AF), var(--violet,#2563EB), var(--cyan,#38BDF8), var(--aqua,#7DD3FC));
    opacity: 0.9;
}

/* шапка */
.cntl-chat-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.cntl-chat-ava {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--indigo,#1E40AF), var(--cyan,#38BDF8));
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
}
.cntl-chat-title { flex: 1; min-width: 0; }
.cntl-chat-title b {
    display: block;
    font-size: 14.5px; font-weight: 600;
    color: #F4F4F4; letter-spacing: 0.01em;
}
.cntl-chat-title span {
    display: flex; align-items: center; gap: 6px;
    margin-top: 2px;
    font: 400 11.5px 'Geist Mono', monospace;
    color: #8b8b90;
}
.cntl-chat-title span i {
    width: 6px; height: 6px; border-radius: 50%;
    background: #4ADE80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
}
.cntl-chat-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid transparent;
    border-radius: 9px;
    background: none;
    color: #777;
    cursor: pointer;
    transition: 0.2s;
}
.cntl-chat-close:hover { border-color: rgba(255,255,255,0.12); color: #ddd; }

/* лента сообщений */
.cntl-chat-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 16px 8px;
    scrollbar-width: none;
    overscroll-behavior: contain;
}
.cntl-chat-body::-webkit-scrollbar { width: 0; height: 0; }

.cntl-chat-msg {
    max-width: 78%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    animation: cntl-msg-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    word-wrap: break-word;
}
@keyframes cntl-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cntl-chat-msg.bot {
    align-self: flex-start;
    background: #131316;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-bottom-left-radius: 6px;
    color: #E6E6E8;
}
.cntl-chat-msg.bot a { color: var(--aqua,#7DD3FC); text-decoration: underline; text-underline-offset: 2px; }
.cntl-chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--indigo,#1E40AF), var(--violet,#2563EB));
    border-bottom-right-radius: 6px;
    color: #fff;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.25);
}
.cntl-chat-ts {
    display: block;
    margin-top: 5px;
    font: 400 9.5px 'Geist Mono', monospace;
    opacity: 0.45;
}

/* «печатает» */
.cntl-chat-typing {
    align-self: flex-start;
    display: flex; gap: 5px;
    padding: 12px 16px;
    background: #131316;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    border-bottom-left-radius: 6px;
}
.cntl-chat-typing s {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--aqua,#7DD3FC);
    text-decoration: none;
    animation: cntl-tp 1.2s infinite;
}
.cntl-chat-typing s:nth-child(2) { animation-delay: 0.2s; }
.cntl-chat-typing s:nth-child(3) { animation-delay: 0.4s; }
@keyframes cntl-tp {
    0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
    30%           { opacity: 1;    transform: translateY(-3px); }
}

/* быстрые ответы */
.cntl-chat-chips {
    flex-shrink: 0;
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 4px 16px 12px;
}
.cntl-chat-chip {
    padding: 8px 13px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    color: #cfd0d4;
    font: 400 11.5px 'Geist Mono', monospace;
    cursor: pointer;
    transition: 0.2s;
}
.cntl-chat-chip:hover { border-color: var(--cyan,#38BDF8); color: var(--aqua,#7DD3FC); }

/* ввод */
.cntl-chat-form {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 10px;
    margin: 0 14px 8px;
    padding: 6px 6px 6px 16px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 999px;
    background: #0F0F12;
}
.cntl-chat-form input {
    flex: 1; min-width: 0;
    border: none; background: none; outline: none;
    color: var(--text,#EDEDED);
    font: 400 13px 'Geist', system-ui, sans-serif;
}
.cntl-chat-form input::placeholder { color: #6b6b70; }
.cntl-chat-send {
    flex-shrink: 0;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: linear-gradient(135deg, var(--violet,#2563EB), var(--cyan,#38BDF8));
    cursor: pointer;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
    transition: transform 0.15s;
}
.cntl-chat-send:hover { transform: scale(1.07); }
.cntl-chat-send:disabled { opacity: 0.4; cursor: default; transform: none; }

.cntl-chat-foot {
    flex-shrink: 0;
    padding: 0 0 10px;
    text-align: center;
    font: 400 9.5px 'Geist Mono', monospace;
    letter-spacing: 0.08em;
    color: #4e4e54;
}

/* ---------- Мобильная версия: окно на весь экран ---------- */
@media (max-width: 560px) {
    .cntl-chat-btn { left: 16px; bottom: 16px; }
    .cntl-chat-win {
        left: 0; right: 0; top: 0; bottom: 0;
        width: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
        transform-origin: 50% 100%;
    }
}

/* ---------- Доступность ---------- */
@media (prefers-reduced-motion: reduce) {
    .cntl-chat-btn, .cntl-chat-win, .cntl-chat-msg,
    .cntl-chat-typing s, .cntl-chat-btn .dot { animation: none; transition: none; }
}
