/* ========================================== */
/* КРАТКОЕ ОГЛАВЛЕНИЕ                         */
/* ========================================== */
/*
 * ФАЙЛ: ai-search.css
 * НАЗНАЧЕНИЕ: ИИ поиск с селектором модели и модальным окном для ответов
 *
 * СОДЕРЖАНИЕ:
 * 1. .service-control__ai-search - Контейнер ИИ поиска в панели управления
 * 2. .ai-model-selector - Селектор выбора модели ИИ с dropdown
 * 3. .service-control__ai-input - Поле ввода запроса
 * 4. .service-control__ai-btn - Кнопка отправки запроса
 * 5. .ai-response-modal - Модальное окно для отображения ответа ИИ
 * 6. .ai-message--user / .ai-message--ai - Сообщения в чате с ИИ
 * 7. .ai-response-modal__input-wrapper - Строка ввода для продолжения диалога
 * 8. .ai-loader - Анимация загрузки ответа ИИ
 * 9. .ai-link-wrapper - Контейнер для кликабельной ссылки с кнопкой "+"
 * 10. .ai-link - Кликабельная ссылка в ответе ИИ
 * 11. .ai-link-add-btn - Кнопка добавления ссылки (появляется при hover)
 * 12. .ai-notification - Уведомление о добавлении ссылки (absolute позиционирование в видимой области)
 *
 * ОСОБЕННОСТИ:
 * - Анимации: aiGradientMove (градиент сверху окна), aiLoaderPulse (точки загрузки), messageSlideIn (появление сообщений), notificationSlide (уведомления)
 * - Цвета: темно-зеленый (#1a6b6d), светло-зеленый (#7fc241), градиенты
 * - Адаптивность: есть @media (max-width: 768px)
 * - Чат: поддержка истории сообщений и продолжения диалога
 * - Интеграция: автоматическое добавление ссылок из ответов ИИ в хранилище
 */
/* ========================================== */

/* ========================================== */
/* AI SEARCH STYLES                           */
/* Стили для ИИ поиска в service-control      */
/* ========================================== */

/* Контейнер ИИ поиска в панели управления */
.service-control__ai-search {
    display: flex;
    align-items: center;
    margin: auto;
    gap: 6px;
    flex: 0 0 auto;
    max-width: 350px;
    position: relative;
}

/* ========================================== */
/* AI MODEL SELECTOR                          */
/* Селектор выбора модели ИИ                  */
/* ========================================== */

/* Контейнер селектора модели ИИ */
.ai-model-selector {
    position: relative;
    display: flex;
    align-items: center;
}

/* Иконка робота - кнопка открытия селектора */
.ai-model-selector__icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

/* Эффект наведения на иконку - увеличение */
.ai-model-selector__icon:hover {
    transform: scale(1.1);
}

/* SVG иконка робота */
.ai-model-selector__robot {
    width: 28px;
    height: 28px;
    color: #1a6b6d;
    transition: color 0.3s ease;
}

/* Изменение цвета робота при наведении на иконку */
.ai-model-selector__icon:hover .ai-model-selector__robot {
    color: #7fc241;
}

/* Выпадающий список моделей ИИ */
.ai-model-selector__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid #1a6b6d;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* BUGFIX: не блокировать клики когда скрыт */
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

/* Показ dropdown при наведении на селектор */
.ai-model-selector:hover .ai-model-selector__dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* Отдельная опция в списке моделей */
.ai-model-selector__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(26, 107, 109, 0.1);
}

/* Убираем нижнюю границу у последней опции */
.ai-model-selector__option:last-child {
    border-bottom: none;
}

/* Эффект наведения на опцию - светло-зеленый фон */
.ai-model-selector__option:hover {
    background: rgba(127, 194, 65, 0.1);
}

/* Активная опция - темно-зеленый фон */
.ai-model-selector__option.active {
    background: rgba(26, 107, 109, 0.1);
}

/* Название модели ИИ */
.ai-model-selector__option-name {
    color: #333333;
    font-size: 14px;
    font-weight: 500;
    font-family: Arial, sans-serif;
}

/* Галочка выбранной модели */
.ai-model-selector__option-check {
    color: #7fc241;
    font-size: 18px;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Показ галочки для активной модели */
.ai-model-selector__option.active .ai-model-selector__option-check {
    opacity: 1;
}

/* ========================================== */
/* VOICE INPUT BUTTON (Block #2)             */
/* Кнопка голосового ввода в панели поиска    */
/* ========================================== */

/* Кнопка голосового ввода */
.service-control__voice-btn {
    position: relative;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

/* Подсказка для кнопки голосового ввода */
.service-control__voice-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.service-control__voice-btn:hover::before {
    opacity: 1;
}

/* Hover эффект */
.service-control__voice-btn:hover {
    border-color: #1a6b6d;
    background: linear-gradient(135deg, #ffffff 0%, #f0f8f0 100%);
    transform: scale(1.05);
}

/* Состояние записи - красный фон с пульсацией */
.service-control__voice-btn.recording {
    background: #ff4444 !important;
    border-color: #ff4444 !important;
    animation: voiceBtnPulse 0.5s infinite;
}

@keyframes voiceBtnPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(255, 68, 68, 0);
    }
}

/* Поле ввода запроса к ИИ */
.service-control__ai-input {
    flex: 1;
    height: 34px;
    padding: 0 12px;

    background: #ffffff;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    color: #333333;
    font-size: 13px;
    font-family: Arial, sans-serif;
    transition: all 0.2s ease;
    min-width: 400px;
}

/* Стиль placeholder для поля ввода */
.service-control__ai-input::placeholder {
    color: #999999;
}

/* Фокус на поле ввода - темно-зеленая граница */
.service-control__ai-input:focus {
    outline: none;
    background: #ffffff;
    border-color: #1a6b6d;
    box-shadow: 0 0 0 2px rgba(26, 107, 109, 0.1);
}

/* Кнопка отправки запроса к ИИ */
.service-control__ai-btn {
    height: 34px;
    width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 6px;
    color: #1a6b6d;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

/* Эффект наведения на кнопку - желтый фон и увеличение */
.service-control__ai-btn:hover {
    background: var(--yellow-btn);
    border-color: #1a6b6d;
    transform: scale(1.1);
}

/* Эффект нажатия на кнопку - уменьшение */
.service-control__ai-btn:active {
    transform: scale(0.95);
}

/* ========================================== */
/* HOVER & FOCUS EFFECTS FOR BLOCK #2         */
/* Интерактивные эффекты для поиска ИИ        */
/* ========================================== */

/* Анимация "дыхания" для поля ввода */
@keyframes inputBreathing {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(127, 194, 65, 0.2);
    }
    50% {
        box-shadow: 0 0 8px 3px rgba(127, 194, 65, 0.35);
    }
}

/* AI индикатор (появляется при hover) - круглый, у правого края поля ввода */
/* Контейнер max-width: 350px, но контент ~480px (overflow) */
/* Input заканчивается на 440px от левого края контейнера */
/* Для позиции 12px от правого края input: right = 350 - 428 = -78px */
.service-control__ai-search::after {
    content: 'AI';
    position: absolute;
    top: 50%;
    right: -78px;
    transform: translateY(-50%) scale(0.8);
    font-size: 10px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #7fc241 0%, #1a6b6d 100%);
    width: 18px;
    height: 18px;
    border-radius: 50%; /* Круглый */
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: none;
    /* Центрируем текст внутри круга */
    text-align: center;
    line-height: 18px;
}

/* При hover на контейнер поиска */
.service-control__ai-search:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Поле ввода при hover на контейнер — дыхание и расширение */
.service-control__ai-search:hover .service-control__ai-input {
    animation: inputBreathing 2s ease-in-out infinite;
    border-color: #7fc241;
}

/* Кнопки уменьшаются при hover на контейнер — фокус на поле ввода */
/* Плавная анимация уменьшения (0.5s вместо 0.2s) */
.service-control__ai-search:hover .service-control__voice-btn,
.service-control__ai-search:hover .service-control__ai-btn {
    transform: scale(0.85);
    opacity: 0.7;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

/* Восстанавливаем кнопки при наведении на них самих */
.service-control__ai-search:hover .service-control__voice-btn:hover,
.service-control__ai-search:hover .service-control__ai-btn:hover {
    transform: scale(1.05);
    opacity: 1;
}

/* Фокус на поле — градиентный фон (более заметный зеленый оттенок) */
.service-control__ai-input:focus {
    background: linear-gradient(135deg, #ffffff 0%, #e8f5e9 40%, #d4edda 100%) !important;
    border-color: #1a6b6d !important;
    box-shadow: 0 0 0 3px rgba(26, 107, 109, 0.2), 0 2px 12px rgba(127, 194, 65, 0.3) !important;
    animation: none;
}

/* Кнопки возвращаются при фокусе на поле */
.service-control__ai-input:focus ~ .service-control__ai-btn,
.service-control__ai-search:focus-within .service-control__voice-btn,
.service-control__ai-search:focus-within .service-control__ai-btn {
    transform: scale(1);
    opacity: 1;
}

/* ========================================== */
/* AI SUGGESTIONS DROPDOWN                    */
/* Выпадающий блок с мини AI помощником       */
/* ========================================== */

/* Контейнер dropdown (появляется при фокусе) */
/* Смещен вправо, чтобы начинаться под полем ввода (после кнопки микрофона) */
.ai-search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 40px; /* Отступ от левого края (ширина кнопки микрофона) */
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Показываем при фокусе на контейнере */
.service-control__ai-search:focus-within .ai-search-suggestions {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Держим dropdown видимым при загрузке/показе результатов */
.ai-search-suggestions.loading-active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Скрываем dropdown когда пользователь нажал "Скрыть" */
.ai-search-suggestions.user-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-10px) !important;
}

/* Не показываем dropdown при фокусе если он скрыт пользователем */
.service-control__ai-search:focus-within .ai-search-suggestions.user-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Скрываем если есть текст в поле (пользователь уже печатает) */
.service-control__ai-search.has-text .ai-search-suggestions:not(.loading-active) {
    display: none;
}

/* Мини AI помощник внутри dropdown */
.ai-search-suggestions__helper {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Мини иконка робота */
.ai-search-suggestions__icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: #1a6b6d;
    transition: all 0.3s ease;
}

/* Свечение при загрузке */
.ai-search-suggestions__icon.loading {
    color: #7fc241;
    filter: drop-shadow(0 0 6px rgba(127, 194, 65, 0.6));
    animation: iconPulse 1s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Текст вопроса от помощника */
.ai-search-suggestions__text {
    flex: 1;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

/* Кнопка генерации запросов */
.ai-search-suggestions__btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #7fc241 0%, #5ca030 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* Иконка внутри кнопки */
.ai-search-suggestions__btn-icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* SVG иконка внутри кнопки */
.ai-search-suggestions__btn-icon svg {
    width: 14px;
    height: 14px;
}

/* Анимация загрузки (точки) */
.ai-search-suggestions__btn-icon--loading {
    animation: dotsLoading 1s infinite;
    font-weight: bold;
    letter-spacing: 1px;
}

@keyframes dotsLoading {
    0%, 20% { opacity: 0.3; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.3; }
}

/* Состояние "Обновить" - иконка вращается при наведении */
.ai-search-suggestions__btn--refresh:hover .ai-search-suggestions__btn-icon {
    animation: spinRefresh 0.6s ease;
}

@keyframes spinRefresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ai-search-suggestions__btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(127, 194, 65, 0.4);
}

.ai-search-suggestions__btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Список сгенерированных запросов */
.ai-search-suggestions__list {
    margin-top: 10px;
    display: none;
    flex-direction: column;
    gap: 6px;
}

.ai-search-suggestions__list.visible {
    display: flex;
}

/* Отдельный запрос - с зеленой вертикальной линией слева */
.ai-search-suggestions__item {
    position: relative;
    padding: 10px 14px 10px 18px;
    background: #e8e8e8; /* Более контрастный фон */
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #ddd;
}

/* Зеленая вертикальная линия слева (50% высоты) */
.ai-search-suggestions__item::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 25%;
    height: 50%;
    width: 3px;
    background: linear-gradient(180deg, #7fc241 0%, #1a6b6d 100%);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.ai-search-suggestions__item:hover {
    background: #d4edda; /* Зеленоватый фон при наведении */
    border-color: #7fc241;
    transform: translateX(4px);
}

.ai-search-suggestions__item:hover::before {
    height: 70%;
    top: 15%;
    box-shadow: 0 0 6px rgba(127, 194, 65, 0.5);
}

/* Статус загрузки */
.ai-search-suggestions__status {
    font-size: 12px;
    color: #7fc241;
    font-weight: 500;
    margin-top: 8px;
    display: none;
}

.ai-search-suggestions__status.visible {
    display: block;
}

/* Кнопка-иконка робота для открытия dropdown (когда dropdown скрыт) */
.ai-search-suggestions__toggle {
    position: absolute;
    top: calc(100% + 8px);
    left: 40px;
    width: 36px;
    height: 36px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Скрыта по умолчанию */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-search-suggestions__toggle svg {
    width: 24px;
    height: 24px;
    color: #7fc241; /* Зелёный робот */
}

.ai-search-suggestions__toggle:hover {
    transform: scale(1.1);
    border-color: #7fc241;
    box-shadow: 0 4px 12px rgba(127, 194, 65, 0.3);
}

/* Показываем кнопку-иконку ТОЛЬКО когда:
   1. dropdown скрыт пользователем (user-hidden)
   2. И поле ввода в фокусе (focus-within) */
.service-control__ai-search:focus-within .ai-search-suggestions__toggle.visible {
    display: flex;
}

/* Кнопка "Скрыть" внизу dropdown */
.ai-search-suggestions__hide-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-search-suggestions__hide-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #555;
}

/* ========================================== */
/* AI RESPONSE MODAL                          */
/* Модальное окно для ответа ИИ               */
/* ========================================== */

/* Модальное окно для отображения ответов ИИ - появляется внутри карточки хранилища */
/* ВАЖНО: position: absolute, чтобы не влиять на layout ссылок */
.ai-response-modal {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px; /* Защитная зона для storage-controls */
    background: linear-gradient(135deg, rgba(26, 107, 109, 0.95) 0%, rgba(16, 16, 16, 0.98) 100%);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 500;
}

.ai-response-modal::-webkit-scrollbar {
    width: 8px;
}

.ai-response-modal::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.ai-response-modal::-webkit-scrollbar-thumb {
    background: rgba(127, 194, 65, 0.3);
    border-radius: 4px;
}

.ai-response-modal::-webkit-scrollbar-thumb:hover {
    background: rgba(127, 194, 65, 0.5);
}

.ai-response-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        #1a6b6d 20%,
        #7fc241 50%,
        #1a6b6d 80%,
        transparent 100%);
    animation: aiGradientMove 5s ease-in-out infinite;
}

@keyframes aiGradientMove {
    0%, 100% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(100%);
    }
}

/* Активное состояние модального окна - показ */
.ai-response-modal.active {
    display: block;
    opacity: 1;
}

.ai-response-modal__content {
    width: 100%;
    padding: 30px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at top right, rgba(127, 194, 65, 0.05) 0%, transparent 50%);
}

.ai-response-modal__close {
    position: sticky;
    top: 25px;
    right: 25px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(127, 194, 65, 0.3);
    border-radius: 8px;
    color: #7fc241;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    align-self: flex-end;
    z-index: 1000;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-response-modal__close:hover {
    background: rgba(127, 194, 65, 0.2);
    border-color: #7fc241;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 20px rgba(127, 194, 65, 0.4);
}

.ai-response-modal__title {
    font-size: 28px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 32px;
    font-family: Arial, sans-serif;
    text-shadow: 0 2px 8px rgba(127, 194, 65, 0.3);
    letter-spacing: 0.5px;
    position: relative;
    display: inline-block;
}

.ai-response-modal__title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #7fc241 0%, transparent 100%);
    border-radius: 2px;
}

.ai-response-modal__messages {
    flex: 1 1 auto;
    padding-right: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

/* Яркая полоса прокрутки для лучшей видимости */
.ai-response-modal__messages::-webkit-scrollbar {
    width: 14px;
}

.ai-response-modal__messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 7px;
    border: 1px solid rgba(127, 194, 65, 0.2);
}

.ai-response-modal__messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #9fe05a 0%, #7fc241 100%);
    border-radius: 7px;
    border: 2px solid rgba(159, 224, 90, 0.6);
    box-shadow: 0 2px 10px rgba(127, 194, 65, 0.6);
}

.ai-response-modal__messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #b8ff6d 0%, #9fe05a 100%);
    border-color: rgba(184, 255, 109, 0.8);
    box-shadow: 0 2px 16px rgba(127, 194, 65, 0.9);
}

.ai-response-modal__loader {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.ai-response-modal__loader.hidden {
    display: none;
}

/* Сообщение от пользователя - справа с зеленой подсветкой */
.ai-message--user {
    color: rgba(255, 255, 255, 0.95);
    font-size: 15px;
    line-height: 1.6;
    font-family: Arial, sans-serif;
    padding: 16px 20px;
    background: rgba(127, 194, 65, 0.15);
    border-radius: 12px 12px 4px 12px;
    border-left: 3px solid #7fc241;
    margin-left: auto;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease-out;
}

/* Сообщение от ИИ - слева с темной подсветкой */
.ai-message--ai {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    line-height: 1.8;
    font-family: Arial, sans-serif;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px 12px 12px 4px;
    border-left: 3px solid #1a6b6d;
    max-width: 90%;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================== */
/* AI INPUT WRAPPER                           */
/* Строка ввода для продолжения диалога       */
/* ========================================== */

.ai-response-modal__input-wrapper {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(127, 194, 65, 0.2);
    margin-top: auto;
    max-width: 90%;
}

.ai-response-modal__input-wrapper.visible {
    display: flex;
}

.ai-response-modal__input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(127, 194, 65, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-family: Arial, sans-serif;
    transition: all 0.2s ease;
}

.ai-response-modal__input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.ai-response-modal__input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: #7fc241;
    box-shadow: 0 0 0 2px rgba(127, 194, 65, 0.2);
}

.ai-response-modal__send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7fc241 0%, #1a6b6d 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-response-modal__send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(127, 194, 65, 0.4);
}

.ai-response-modal__send-btn:active {
    transform: scale(0.95);
}

/* Кнопка голосового ввода в модальном окне */
.ai-response-modal__voice-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border: 2px solid #1a6b6d;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-response-modal__voice-btn:hover {
    background: var(--yellow-btn, #ffd700);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(26, 107, 109, 0.3);
}

.ai-response-modal__voice-btn:active {
    transform: scale(0.95);
}

/* Состояние записи - красный фон */
.ai-response-modal__voice-btn.recording {
    background: #ff4444 !important;
    border-color: #ff4444;
    animation: voicePulse 0.5s infinite;
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Tooltip для кнопки голосового ввода */
.ai-response-modal__voice-btn::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.ai-response-modal__voice-btn:hover::before {
    opacity: 1;
}

.ai-response-modal__close-duplicate {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7fc241 0%, #1a6b6d 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 20px;
    margin-left: 10px; /* расстояние от кнопки отправки */
}

.ai-response-modal__close-duplicate:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(127, 194, 65, 0.4);
}

.ai-response-modal__close-duplicate:active {
    transform: scale(0.95) rotate(90deg);
}

/* ========================================== */
/* AI LOADER ANIMATION                        */
/* Современная анимация загрузки              */
/* ========================================== */

/* Анимация загрузки ответа ИИ - три точки с пульсацией */
.ai-loader {
    display: flex;
    gap: 16px;
    align-items: center;
    position: relative;
}

.ai-loader::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(127, 194, 65, 0.1) 0%, transparent 70%);
    animation: aiLoaderGlow 2s ease-in-out infinite;
}

@keyframes aiLoaderGlow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.6;
    }
}

.ai-loader__dot {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #7fc241 0%, #1a6b6d 100%);
    border-radius: 50%;
    animation: aiLoaderPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(127, 194, 65, 0.5);
    position: relative;
    z-index: 1;
}

.ai-loader__dot:nth-child(1) {
    animation-delay: 0s;
}

.ai-loader__dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-loader__dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aiLoaderPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 20px rgba(127, 194, 65, 0.8);
    }
}

/* ========================================== */
/* AI LINK WITH ADD BUTTON                    */
/* Кликабельные ссылки с кнопкой добавления   */
/* ========================================== */

/* Контейнер для ссылки с кнопкой добавления */
.ai-link-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(127, 194, 65, 0.08);
    border-radius: 6px;
    transition: all 0.2s ease;
    margin: 2px 0;
}

.ai-link-wrapper:hover {
    background: rgba(127, 194, 65, 0.15);
}

/* Кликабельная ссылка в ответе ИИ */
.ai-link {
    color: #7fc241;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: break-all;
    border-bottom: 1px solid rgba(127, 194, 65, 0.3);
}

.ai-link:hover {
    color: #9fe05a;
    border-bottom-color: #9fe05a;
}

/* Кнопка добавления ссылки в хранилище - уменьшенная визуально, но с сохранённой областью клика */
.ai-link-add-btn {
    position: relative;
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

/* Визуальный фон кнопки - меньше, чем область клика */
.ai-link-add-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #7fc241 0%, #1a6b6d 100%);
    border-radius: 4px;
    transition: all 0.2s ease;
    z-index: 0;
}

/* Увеличиваем непрозрачность и размер кнопки при наведении на контейнер ссылки */
.ai-link-wrapper:hover .ai-link-add-btn {
    opacity: 1;
}

.ai-link-wrapper:hover .ai-link-add-btn::before {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(127, 194, 65, 0.4);
}

/* SVG иконки плюса внутри кнопки - восстановлен оригинальный размер */
.ai-link-add-btn svg {
    width: 14px;
    height: 14px;
    position: relative;
    z-index: 1;
}

/* При наведении увеличиваем визуальный фон до полного размера */
.ai-link-add-btn:hover::before {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(127, 194, 65, 0.4);
}

.ai-link-add-btn:active::before {
    transform: translate(-50%, -50%) scale(0.9);
}

/* Состояние кнопки после успешного добавления ссылки — жёлтая галочка */
.ai-link-add-btn.ai-link-added {
    opacity: 1;
    cursor: default;
    color: #1a1a1a;
}

.ai-link-add-btn.ai-link-added::before {
    background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.ai-link-add-btn.ai-link-added:hover::before {
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    width: 22px;
    height: 22px;
}

.ai-link-add-btn.ai-link-added svg {
    width: 14px;
    height: 14px;
    color: #1a1a1a;
}

/* Уведомление о добавлении ссылки - absolute позиционирование в контейнере */
.ai-notification {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background: rgba(127, 194, 65, 0.95);
    border: 2px solid #7fc241;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100000;
    pointer-events: none;
    animation: notificationSlide 0.3s ease-out;
}

@keyframes notificationSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================== */
/* RESPONSIVE                                 */
/* ========================================== */

/* Первый диапазон: от 880px до 490px */
@media (max-width: 880px) {
    /* Контейнер ИИ поиска — такая же ширина как на десктопе */
    .service-control__ai-search {
        flex: 0 0 480px;
        max-width: 480px;
        margin: 0 auto;
        order: 2;
        position: relative;
        height: 32px;
        overflow: visible;
    }

    /* AI бейдж на мобильных - позиция учитывает абсолютные кнопки */
    /* Кнопка 44px + offset 3px + отступ 12px = 59px от правого края */
    .service-control__ai-search::after {
        right: 59px;
    }

    /* Поле ввода — заполняет контейнер 32px */
    .service-control__ai-input {
        width: 100%;
        min-width: 0;
        height: 100%;
        font-size: 13px;
        padding: 0 34px;
        border: 1px solid var(--card-border);
        border-radius: 8px;
        box-sizing: border-box;
    }

    /* Кнопка отправки — вписывается в 32px контейнер */
    .service-control__ai-search .service-control__ai-btn {
        width: 26px;
        height: 26px;
        position: absolute;
        right: 3px;
        top: 50%;
        transform: translateY(-50%);
    }

    .service-control__ai-search .service-control__ai-btn:hover {
        transform: translateY(-50%) scale(1.1);
    }

    .service-control__ai-search .service-control__ai-btn:active {
        transform: translateY(-50%) scale(0.95);
    }

    /* Кнопка голосового ввода — вписывается в 32px контейнер */
    .service-control__ai-search .service-control__voice-btn {
        position: absolute;
        left: 4px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 2;
        width: 24px;
        height: 24px;
    }

    /* ВАЖНО: сохраняем translateY(-50%) при hover/active чтобы кнопка не смещалась */
    .service-control__ai-search .service-control__voice-btn:hover {
        transform: translateY(-50%) scale(1.05);
    }

    .service-control__ai-search .service-control__voice-btn:active {
        transform: translateY(-50%) scale(0.95);
    }

    /* Анимация записи на мобильных - сохраняем translateY(-50%) */
    .service-control__ai-search .service-control__voice-btn.recording {
        animation: voiceBtnPulseMobile 0.5s infinite;
    }

    @keyframes voiceBtnPulseMobile {
        0%, 100% {
            transform: translateY(-50%) scale(1);
            box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4);
        }
        50% {
            transform: translateY(-50%) scale(1.05);
            box-shadow: 0 0 0 6px rgba(255, 68, 68, 0);
        }
    }

    /* Отключаем hover-эффекты на мобильных (они вызывают баги) */
    .service-control__ai-search:hover .service-control__voice-btn,
    .service-control__ai-search:hover .service-control__ai-btn {
        transform: translateY(-50%) !important;
        opacity: 1 !important;
    }

    .service-control__ai-search:hover .service-control__ai-input {
        animation: none !important;
    }

    /* ВАЖНО: При фокусе на input сохраняем translateY(-50%) для кнопок */
    .service-control__ai-input:focus ~ .service-control__ai-btn,
    .service-control__ai-search:focus-within .service-control__ai-btn,
    .service-control__ai-search:focus-within .service-control__voice-btn {
        transform: translateY(-50%) !important;
        opacity: 1 !important;
    }


    /* Подсказка для кнопки голосового ввода на мобильных - корректируем позиционирование */
    .service-control__voice-btn::before {
        left: 0 !important; /* Позиционируем относительно левой стороны кнопки */
        right: auto !important;
        transform: translateX(0) !important;
        top: auto !important;
        bottom: calc(100% + 8px) !important;
    }

    /* AI индикатор - скрываем на мобильных */
    .service-control__ai-search::after {
        display: none;
    }

    /* Suggestions dropdown - скрываем на мобильных */
    .ai-search-suggestions {
        display: none !important;
    }

    /* Модальное окно - заполняет всё хранилище */
    /* bottom: 0 чтобы окно было внутри карточки, прокрутка внутри */
    .ai-response-modal {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: none;
        border-radius: 10px;
        overflow-y: auto;
    }

    .ai-response-modal__content {
        padding: 18px 14px;
    }

    .ai-response-modal__title {
        font-size: 22px;
        margin-bottom: 24px;
    }

    /* Кнопка закрытия - увеличиваем для touch */
    .ai-response-modal__close {
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
        font-size: 26px;
    }

    /* Сообщения - оптимальная ширина на планшетах */
    .ai-message--user,
    .ai-message--ai {
        max-width: 92%;
        font-size: 15px;
        padding: 14px 16px;
    }

    /* Поле ввода в модальном окне */
    .ai-response-modal__input-wrapper {
        max-width: 100%;
        padding: 10px;
        gap: 8px;
    }

    .ai-response-modal__input {
        height: 42px;
        font-size: 15px;
        flex: 1;
        min-width: 0;
    }

    /* Кнопка отправки - увеличиваем для touch */
    .ai-response-modal__send-btn {
        width: 42px;
        height: 42px;
        font-size: 17px;
        flex-shrink: 0;
    }

    /* Скрываем дубликат кнопки закрытия на мобильных */
    .ai-response-modal__close-duplicate {
        display: none;
    }

    /* Ссылки с кнопками */
    .ai-link-add-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }

    .ai-link-add-btn::before {
        width: 26px;
        height: 26px;
    }

    .ai-link-add-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Кнопка после добавления — увеличенная для touch */
    .ai-link-add-btn.ai-link-added::before {
        width: 28px;
        height: 28px;
    }

    /* Уведомление */
    .ai-notification {
        font-size: 13px;
        padding: 10px 16px;
    }
}

/* Второй диапазон: от 490px до 340px */
@media (max-width: 490px) {
    /* Контейнер ИИ поиска — высота как у индикатора (32px) */
    .service-control__ai-search {
        height: 32px;
        flex: 1;
        min-width: 0;
        max-width: none;
        box-sizing: border-box;
        overflow: visible;
        margin: 0;
        align-items: center;
    }

    /* ВАЖНО: Сохраняем translateY(-50%) на мобильных */
    .service-control__ai-search:hover .service-control__voice-btn,
    .service-control__ai-search:hover .service-control__ai-btn {
        transform: translateY(-50%) !important;
        opacity: 1 !important;
    }

    .service-control__ai-input:focus ~ .service-control__ai-btn,
    .service-control__ai-search:focus-within .service-control__voice-btn,
    .service-control__ai-search:focus-within .service-control__ai-btn {
        transform: translateY(-50%) !important;
        opacity: 1 !important;
    }

    /* Отключаем анимацию "дыхания" на мобильных */
    .service-control__ai-search:hover .service-control__ai-input {
        animation: none !important;
    }

    /* Отключаем AI badge на мобильных */
    .service-control__ai-search::after {
        display: none !important;
    }

    /* AI бейдж на маленьких экранах - кнопка 40px */
    /* Кнопка 40px + offset 3px + отступ 12px = 55px */
    .service-control__ai-search::after {
        right: 55px;
    }

    /* Поле ввода — заполняет контейнер 32px */
    .service-control__ai-input {
        height: 100%;
        width: 100%;
        min-width: 0 !important;
        max-width: 100% !important;
        font-size: 12px;
        padding: 0 30px;
        border-radius: 8px;
        box-sizing: border-box;
    }

    .service-control__ai-input:focus {
        background: #ffffff !important;
        box-shadow: 0 0 0 2px rgba(26, 107, 109, 0.1) !important;
    }

    /* Кнопка отправки — вписывается в 32px */
    .service-control__ai-search .service-control__ai-btn {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    /* Кнопка микрофона — вписывается в 32px, left = top отступ (5px) */
    .service-control__ai-search .service-control__voice-btn {
        left: 5px;
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .ai-model-selector__icon {
        width: 40px;
        height: 40px;
    }

    .ai-model-selector__robot {
        width: 28px;
        height: 28px;
    }

    /* Dropdown моделей */
    .ai-model-selector__dropdown {
        top: calc(100% + 4px);
        min-width: 150px;
        font-size: 13px;
    }

    .ai-model-selector__option {
        padding: 10px 12px;
    }

    .ai-model-selector__option-name {
        font-size: 13px;
    }

    /* Модальное окно - заполняет всё хранилище */
    /* bottom: 0 чтобы окно было внутри карточки, прокрутка внутри */
    .ai-response-modal {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: none;
        border-radius: 8px;
        overflow-y: auto;
    }

    .ai-response-modal__content {
        padding: 14px 10px;
    }

    .ai-response-modal__title {
        font-size: 18px;
        margin-bottom: 18px;
    }

    /* Кнопка закрытия - компактный размер */
    .ai-response-modal__close {
        top: 8px;
        right: 8px;
        width: 38px;
        height: 38px;
        font-size: 24px;
    }

    /* Сообщения - на всю ширину на маленьких экранах */
    .ai-message--user,
    .ai-message--ai {
        max-width: 96%;
        font-size: 14px;
        padding: 12px 14px;
    }

    /* Поле ввода в модальном окне */
    .ai-response-modal__input-wrapper {
        padding: 8px;
        gap: 6px;
    }

    .ai-response-modal__input {
        height: 40px;
        font-size: 14px;
    }

    /* Кнопка отправки */
    .ai-response-modal__send-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    /* Ссылки с кнопками - компактный размер */
    .ai-link-add-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }

    .ai-link-add-btn::before {
        width: 24px;
        height: 24px;
    }

    .ai-link-add-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Кнопка после добавления — компактный размер */
    .ai-link-add-btn.ai-link-added::before {
        width: 26px;
        height: 26px;
    }

    /* Уведомление */
    .ai-notification {
        font-size: 12px;
        padding: 8px 14px;
    }
}

/* ========================================== */
/* ВРЕМЕННО СКРЫТ ИИ-ПОИСК В БЛОКЕ №2        */
/* Убрать класс service-control--ai-hidden    */
/* с <section> для возврата строки «Спросите ИИ» */
/* ========================================== */

.service-control--ai-hidden .service-control__ai-search {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 880px) {
    .service-control--ai-hidden {
        justify-content: space-between;
    }

    .service-control--ai-hidden .service-control__logo {
        flex: 0 0 auto;
    }

    .service-control--ai-hidden .service-control__actions {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .service-control--ai-hidden .service-control__ai-search {
        display: none !important;
        flex: 0 0 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden;
    }
}

/* type=search: убираем крестик очистки в WebKit */
.service-control__ai-input::-webkit-search-cancel-button,
.ai-response-modal__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}
