/* GigaChat Widget Styles */

:root {
    --gigachat-primary: #00a98f; /* Фирменный цвет Сбера */
    --gigachat-primary-light: #e6f7f4;
    --gigachat-bg: var(--card-bg);
    --gigachat-header-bg: var(--bg-color);
    --gigachat-border: var(--border-color);
    --gigachat-user-msg-bg: var(--primary-blue);
    --gigachat-user-msg-text: #ffffff;
    --gigachat-bot-msg-bg: var(--background-color-light);
    --gigachat-bot-msg-text: var(--text-color);
}

/* --- Кнопка-триггер --- */
.gigachat-trigger {
    position: fixed;
    bottom: 100px; /* Располагаем над виджетом контактов */
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--gigachat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transition: transform 0.2s ease-out, background-color 0.2s;
}

.gigachat-trigger:hover {
    transform: scale(1.1);
    background-color: #008a74;
}

/* --- Окно чата --- */
.gigachat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 370px;
    max-width: calc(100% - 40px);
    height: 70vh;
    max-height: 600px;
    background-color: var(--gigachat-bg);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease, visibility 0.3s;
}

.gigachat-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* --- Шапка чата --- */
.gigachat-header {
    padding: 1rem 1.5rem;
    background-color: var(--gigachat-header-bg);
    border-bottom: 1px solid var(--gigachat-border);
    text-align: center;
    position: relative;
}

.gigachat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-color);
}

.gigachat-header p {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-color-secondary);
}

.gigachat-close {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-color-secondary);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.gigachat-close:hover {
    opacity: 1;
}

/* --- Область сообщений --- */
.gigachat-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gigachat-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    line-height: 1.5;
}

.gigachat-message p {
    margin: 0;
}

.gigachat-message--user {
    background-color: var(--gigachat-user-msg-bg);
    color: var(--gigachat-user-msg-text);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.gigachat-message--bot {
    background-color: var(--gigachat-bot-msg-bg);
    color: var(--gigachat-bot-msg-text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.gigachat-message--typing {
    color: var(--text-color-secondary);
    font-style: italic;
}

/* --- Поле ввода --- */
.gigachat-input-area {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid var(--gigachat-border);
    gap: 0.5rem;
}

#gigachat-input {
    flex-grow: 1;
    border: 1px solid var(--gigachat-border);
    border-radius: 20px;
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    background-color: var(--bg-color);
    color: var(--text-color);
}

#gigachat-send {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background-color: var(--gigachat-primary);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#gigachat-send:hover {
    background-color: #008a74;
}

#gigachat-send:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* --- Стили для блока согласия --- */
.gigachat-consent {
    padding: 0 0.75rem 0.75rem; /* Отступы, чтобы соответствовать полю ввода */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gigachat-consent label {
    font-size: 0.8rem; /* Уменьшаем размер шрифта */
    color: var(--text-color-secondary); /* Делаем текст менее ярким */
    line-height: 1.4;
    cursor: pointer;
}

.gigachat-consent a {
    color: var(--text-color-secondary);
    text-decoration: underline;
}

.gigachat-consent-error {
    font-size: 0.8rem;
    color: var(--text-red);
    padding: 0 0.75rem 0.5rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    height: 1em; /* Резервируем место, чтобы чат не "прыгал" */
}

@media (max-width: 480px) {
    body:has(.cookie-consent.is-visible) .gigachat-trigger {
        bottom: 250px;
    }

    body:has(.cookie-consent.is-visible) .gigachat-window {
        bottom: 250px;
        height: calc(100dvh - 275px);
        max-height: none;
    }
}
