/* =====================================================================
   LR Web Chat - стили
   Используются переменные colors.json шаблона там, где это уместно,
   с безопасными фолбэками, если переменная не объявлена в теме.
   ===================================================================== */

:root {
    --lr-chat-accent: var(--color-accent, #99ff00);
    --lr-chat-bg: var(--sidebar-block, #1c1c22);
    --lr-chat-bg-soft: rgba(255, 255, 255, 0.04);
    --lr-chat-text: #e9e9ec;
    --lr-chat-muted: #9a9aa5;
}

/* ---------- Плавающий виджет ---------- */

.lr-chat-widget {
    position: fixed;
    left: 24px;       /* ← стало */
    bottom: 24px;
    z-index: 9999;
    font-family: Unbounded;
}

.lr-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--lr-chat-accent);
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lr-chat-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.lr-chat-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.lr-chat-window {
    position: absolute;
    left: 0;          
    bottom: 72px;
    width: 340px;
    height: 440px;
    background: var(--lr-chat-bg);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Свёрнутое состояние по умолчанию */
    opacity: 0;
    transform: scale(0.9) translateY(12px);
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* При открытии окно "разворачивается" крупнее */
.lr-chat-widget.is-open .lr-chat-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
    width: 380px;
    height: 520px;
}

.lr-chat-header {
    padding: 14px 16px;
    background: var(--lr-chat-bg-soft);
    color: var(--lr-chat-text);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.lr-chat-close {
    cursor: pointer;
    color: var(--lr-chat-muted);
    font-size: 20px;
    line-height: 1;
}

.lr-chat-close:hover {
    color: var(--lr-chat-text);
}

/* ---------- Общий список сообщений (виджет + страница) ---------- */

.lr-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lr-chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.lr-chat-msg__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.lr-chat-msg__body {
    background: var(--lr-chat-bg-soft);
    border-radius: 12px;
    padding: 6px 10px;
    max-width: 220px;
}

.lr-chat-msg__nickname {
    font-size: 12px;
    font-weight: 600;
    color: var(--lr-chat-accent);
    margin-bottom: 2px;
}

.lr-chat-msg__text {
    font-size: 13px;
    color: var(--lr-chat-text);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.lr-chat-msg__time {
    font-size: 10px;
    color: var(--lr-chat-muted);
    margin-top: 2px;
}

/* ---------- Форма отправки ---------- */

.lr-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.lr-chat-form input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    background: var(--lr-chat-bg-soft);
    color: var(--lr-chat-text);
    outline: none;
}

.lr-chat-form button {
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    background: var(--lr-chat-accent);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.lr-chat-locked {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--lr-chat-muted);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Отдельная страница /chat ---------- */

.lr-chat-page {
    max-width: 720px;
    margin: 24px auto;
    background: var(--lr-chat-bg);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 70vh;
}

.lr-chat-page__header {
    padding: 18px 20px;
    background: var(--lr-chat-bg-soft);
}

.lr-chat-page__header h1 {
    margin: 0;
    font-size: 18px;
    color: var(--lr-chat-text);
}

.lr-chat-page__body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lr-chat-messages--page {
    min-height: 400px;
}

.lr-chat-form--page input {
    border-radius: 10px;
}

.lr-chat-form--page button {
    border-radius: 10px;
    width: auto;
    padding: 0 16px;
    font-size: 13px;
}

/* Мобильная адаптация виджета */
@media (max-width: 480px) {
    .lr-chat-widget.is-open .lr-chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        right: -12px;
    }
}
