/**
 * #539: чат-виджет «Итака — чат с агентом». Все классы с префиксом sitechat-,
 * чтобы не задеть стили сайта. Кнопка — справа внизу (место JivoSite, который
 * при включённом чате не выводится); слева внизу живёт .scrolltop1 сайта.
 */
.sitechat-hidden {
    display: none !important;
}

.sitechat-toggle {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 100000;
    width: 3.5rem;
    height: 3.5rem;
    border: none;
    border-radius: 50%;
    background-color: #62A34B;
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.sitechat-toggle:hover {
    background-color: #528a3e;
}

.sitechat-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    min-width: 1.25rem;
    padding: 0 0.25rem;
    border-radius: 0.6rem;
    background-color: #d9534f;
    color: #fff;
    font-size: 0.7rem;
    line-height: 1.25rem;
    text-align: center;
}

.sitechat-window {
    position: fixed;
    right: 1.25rem;
    bottom: 5.25rem;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    width: 22.5rem;
    max-width: calc(100vw - 2.5rem);
    height: 30rem;
    max-height: calc(100vh - 7rem);
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.sitechat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: #62A34B;
    color: #fff;
}

.sitechat-title {
    font-weight: bold;
}

.sitechat-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

.sitechat-close {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.sitechat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.75rem;
    background-color: #f5f6f7;
}

.sitechat-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.6rem;
}

.sitechat-msg-me {
    align-items: flex-end;
}

.sitechat-msg-them {
    align-items: flex-start;
}

.sitechat-bubble {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    /* переводы строк из текста сообщений (HTML агента вычищен на сервере) */
    white-space: pre-line;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sitechat-bubble-me {
    background-color: #62A34B;
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.sitechat-bubble-them {
    background-color: #fff;
    color: #212529;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 0.25rem;
}

/* курсор в конце реплики, которую бот «печатает» */
.sitechat-typing-cursor .sitechat-bubble::after {
    content: '';
    display: inline-block;
    width: 0.1em;
    height: 0.85em;
    margin-left: 0.1em;
    vertical-align: -0.12em;
    background-color: currentColor;
    animation: sitechat-blink 0.9s infinite;
}

/* строка «Имя · ЧЧ:ММ» над пузырём */
.sitechat-msg-meta {
    font-size: 0.7rem;
    color: #9aa3ab;
    margin: 0 0.15rem 0.15rem;
}

/* анимированные точки индикатора «печатает»: прыгают по очереди, как в мессенджерах */
.sitechat-dots span {
    display: inline-block;
    font-weight: 700;
    animation: sitechat-dot 1.2s infinite ease-in-out;
}

.sitechat-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.sitechat-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes sitechat-dot {
    0%, 70%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }
    35% {
        transform: translateY(-0.3em);
        opacity: 1;
    }
}

@keyframes sitechat-blink {
    0%, 60%, 100% {
        opacity: 0.2;
    }
    30% {
        opacity: 1;
    }
}

.sitechat-notice {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    font-size: 0.8rem;
    text-align: center;
}

.sitechat-typing {
    padding: 0.25rem 0.75rem 0.25rem 1rem;
    font-size: 0.75rem;
    color: #6c757d;
    background-color: #f5f6f7;
}

.sitechat-form {
    padding: 0.5rem;
    border-top: 1px solid #dee2e6;
    background-color: #fff;
}

/* honeypot: вне экрана, без позиции fixed, чтобы не ловился краулерами наравне с формами */
.sitechat-hp {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sitechat-name {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ced4da;
    border-radius: 0.4rem;
    font-size: 0.85rem;
}

.sitechat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.sitechat-text {
    flex: 1 1 auto;
    resize: none;
    padding: 0.5rem 0.6rem;
    border: 1px solid #ced4da;
    border-radius: 0.4rem;
    font-size: 0.9rem;
    line-height: 1.3;
    max-height: 7.5rem;
}

.sitechat-send {
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.4rem;
    border: none;
    border-radius: 0.4rem;
    background-color: #62A34B;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.sitechat-send:hover {
    background-color: #528a3e;
}

.sitechat-send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* телефон: окно чата на весь экран, кнопка не мешает контенту */
@media (max-width: 767px) {
    .sitechat-toggle {
        right: 1rem;
        bottom: 1rem;
    }

    .sitechat-window {
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
