/* Support chat widget. Scoped under .support-chat so it cannot clash with
   the existing /chat page styles (chat.min.css). */

.support-chat {
    font-family: Arial, Helvetica, sans-serif;
}

.support-chat__launcher {
    position: fixed;
    right: 20px;
    bottom: 70px;
    z-index: 10000;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 29px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(67, 56, 202, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.support-chat__launcher:hover,
.support-chat__launcher:focus-visible {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 12px 30px rgba(67, 56, 202, 0.5);
}

.support-chat[data-open="true"] .support-chat__launcher {
    display: none;
}

.support-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #ef4444;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

/* ---- Docked panel: bottom-right corner, above the launcher ---- */

.support-chat__panel {
    position: fixed;
    right: 20px;
    bottom: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 70px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(17, 24, 39, 0.18);
    overflow: hidden;
    transform-origin: bottom right;
    animation: support-chat-in 0.22s ease-out;
}

.support-chat__panel[hidden] {
    display: none;
}

@keyframes support-chat-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---- Header ---- */

.support-chat__header {
    flex-shrink: 0;
    padding: 16px 16px 14px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff;
}

.support-chat__headline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.support-chat__headline-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 22px;
}

.support-chat__headline-text {
    min-width: 0;
    flex: 1;
}

.support-chat__title {
    margin: 0;
    font-size: 1.39rem;
    font-weight: 600;
    line-height: 1.2;
}

.support-chat__status {
    margin: 2px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.03rem;
    color: rgba(255, 255, 255, 0.82);
}

.support-chat__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.28);
}

.support-chat__close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.support-chat__close:hover,
.support-chat__close:focus-visible {
    background: rgba(255, 255, 255, 0.28);
}

.support-chat__intro {
    margin: 14px 0 12px;
    font-size: 1.14rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.92);
}

.support-chat__roles {
    display: grid;
    gap: 8px;
}

.support-chat__role {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.27rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.support-chat__role:hover,
.support-chat__role:focus-visible {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.support-chat__role[aria-pressed="true"] {
    background: #fff;
    border-color: #fff;
    color: #4338ca;
    font-weight: 600;
}

.support-chat__role i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ---- Message log ---- */

.support-chat__log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: #f7f8fc;
}

.support-chat__message {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 13px;
    font-size: 1.15rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.support-chat__message--support {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.support-chat__message--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.support-chat__message-time {
    display: block;
    margin-top: 4px;
    font-size: 0.9rem;
    opacity: 0.65;
}

/* ---- Composer ---- */
/* Повторяет .op-composer операторской панели: рамка-капсула вокруг
   поля и кнопки, фокус-кольцо на всю капсулу, подсказка снизу. */

.support-chat__composer {
    flex-shrink: 0;
    padding: 12px 16px 16px;
    background: #fff;
    border-top: 1px solid #e6e8f0;
}

.support-chat__composer__box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 7px 7px 7px 14px;
    border: 1px solid #e3e6f0;
    border-radius: 14px;
    background: #fafbfe;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.support-chat__composer__box:focus-within {
    background: #fff;
    border-color: #a5b0f5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.support-chat__input {
    flex: 1;
    min-width: 0;
    max-height: 150px;
    padding: 7px 0;
    border: 0;
    background: transparent;
    color: #111827;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.03rem;
    line-height: 1.45;
    resize: none;
    overflow-y: auto;
}

.support-chat__input:focus { outline: none; }
.support-chat__input::placeholder { color: #9aa1b5; }

.support-chat__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 1.03rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.support-chat__send:hover,
.support-chat__send:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.support-chat__send:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.support-chat__hint {
    margin: 7px 2px 0;
    color: #b0b6c6;
    font-size: 0.9rem;
}

/* ---- Narrow screens: панель во всю ширину экрана ---- */

@media (max-width: 768px) {
    .support-chat__panel {
        right: 0;
        /* 100%, а не 100vw: vw включает ширину полосы прокрутки
           и даёт горизонтальный скролл на мобильном. */
        width: 100%;
        max-width: 100%;
        border-radius: 18px 0 0 0;
    }

    .support-chat__launcher {
        right: 12px;
        bottom: 60px;
        width: 52px;
        height: 52px;
        font-size: 24px;
    }
}
