/* Чат-консультант (include/ai_chat.php). Справа внизу — виджет JivoSite, поэтому чат слева */
.lr-ai-chat {
    --lr-ai-accent: var(--main_color, #ffd600);
    --lr-ai-text: #252525;
    --lr-ai-muted: #7a7a7a;
    --lr-ai-line: #e6e6e6;
    --lr-ai-bot-bg: #f4f4f4;
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    font-size: 14px;
    line-height: 1.45;
    color: var(--lr-ai-text);
}

.lr-ai-chat__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 24px;
    background: var(--lr-ai-accent);
    color: var(--lr-ai-text);
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
    cursor: pointer;
}

.lr-ai-chat.is-open .lr-ai-chat__toggle {
    display: none;
}

.lr-ai-chat__panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(600px, calc(100vh - 40px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
    overflow: hidden;
}

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

.lr-ai-chat__header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--lr-ai-line);
}

.lr-ai-chat__header > div {
    flex: 1;
    min-width: 0;
}

.lr-ai-chat__title {
    font-weight: 700;
    font-size: 15px;
}

.lr-ai-chat__subtitle {
    color: var(--lr-ai-muted);
    font-size: 12px;
}

.lr-ai-chat__reset {
    border: 0;
    background: none;
    color: var(--lr-ai-muted);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
    padding: 2px 0;
}

.lr-ai-chat__close {
    border: 0;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--lr-ai-muted);
    cursor: pointer;
    padding: 0 2px;
}

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

.lr-ai-chat__msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 12px;
    overflow-wrap: anywhere;
}

.lr-ai-chat__msg p,
.lr-ai-chat__msg ul,
.lr-ai-chat__msg ol {
    margin: 0 0 6px;
}

.lr-ai-chat__msg > :last-child {
    margin-bottom: 0;
}

.lr-ai-chat__msg ul,
.lr-ai-chat__msg ol {
    padding-left: 18px;
}

.lr-ai-chat__msg--user {
    align-self: flex-end;
    background: var(--lr-ai-accent);
    white-space: pre-wrap;
}

.lr-ai-chat__msg--bot {
    align-self: flex-start;
    background: var(--lr-ai-bot-bg);
}

.lr-ai-chat__msg--error {
    background: #fdecec;
    color: #a12a2a;
}

.lr-ai-chat__msg--typing {
    color: var(--lr-ai-muted);
    font-style: italic;
}

.lr-ai-chat__products {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.lr-ai-chat__product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--lr-ai-line);
    border-radius: 8px;
    color: var(--lr-ai-text);
    text-decoration: none;
}

.lr-ai-chat__product:hover {
    border-color: var(--lr-ai-accent);
}

.lr-ai-chat__product img,
.lr-ai-chat__product-noimg {
    flex: none;
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    background: #fafafa;
}

.lr-ai-chat__product-name {
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lr-ai-chat__product-price {
    font-weight: 700;
    font-size: 13px;
}

.lr-ai-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--lr-ai-line);
}

.lr-ai-chat__form textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 9px 12px;
    border: 1px solid var(--lr-ai-line);
    border-radius: 8px;
    font: inherit;
    outline: none;
}

.lr-ai-chat__form textarea:focus {
    border-color: var(--lr-ai-accent);
}

.lr-ai-chat__form button {
    flex: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: var(--lr-ai-accent);
    color: var(--lr-ai-text);
    cursor: pointer;
}

.lr-ai-chat__form button:disabled {
    opacity: .5;
    cursor: default;
}

/* Телефон: снизу панель навигации сайта, окно — на весь экран */
@media (max-width: 768px) {
    .lr-ai-chat {
        left: 12px;
        bottom: 76px;
    }

    .lr-ai-chat__toggle span {
        display: none;
    }

    .lr-ai-chat__toggle {
        padding: 12px;
    }

    .lr-ai-chat.is-open {
        inset: 0;
        z-index: 2147483000;
    }

    /* Полоса JivoSite перекрывала бы поле ввода открытого чата */
    body.lr-ai-chat-open jdiv {
        display: none !important;
    }

    .lr-ai-chat__panel {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}
