/**
 * Modal AI - Универсальное модальное окно
 * Префикс классов: modal-ai__
 */

/* Блокировка прокрутки body */
body.modal-ai__body-locked {
    overflow: hidden !important;
}

/* Overlay (фон затемнения) */
.modal-ai {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.modal-ai.show {
    opacity: 1;
    visibility: visible;
}

.modal-ai__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* Контейнер модального окна */
.modal-ai__container {
    position: relative;
    background: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    width: 100%;
    max-width: 600px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1;
}

/* Заголовок */
.modal-ai__header {
    padding: 16px 20px;
    border-bottom: 2px solid #9B0023;
    flex-shrink: 0;
    position: relative;
}

.modal-ai__title {
    margin: 0;
    font-size: 16px;
    font-weight: normal;
    color: #000000;
    line-height: 1.5;
}

/* Кнопка закрытия */
.modal-ai__close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #000000;
    transition: opacity 0.2s ease;
}

.modal-ai__close:hover {
    opacity: 0.7;
}

.modal-ai__close::before,
.modal-ai__close::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background: #000000;
    border-radius: 1px;
}

.modal-ai__close::before {
    transform: rotate(45deg);
}

.modal-ai__close::after {
    transform: rotate(-45deg);
}

/* Контентная область */
.modal-ai__body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

/* Футер (опционально) */
.modal-ai__footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Индикатор загрузки */
.modal-ai__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100px;
}

.modal-ai__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(155, 0, 35, 0.1);
    border-top-color: #9B0023;
    border-radius: 50%;
    animation: modal-ai__spin 0.8s linear infinite;
}

@keyframes modal-ai__spin {
    to {
        transform: rotate(360deg);
    }
}

/* Сообщение об ошибке */
.modal-ai__error {
    padding: 20px;
    text-align: center;
    color: #e74c3c;
    font-size: 14px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .modal-ai {
        padding: 10px 0;
        align-items: flex-start;
    }

    .modal-ai__container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        border-radius: 0;
        margin-top: 10px;
        margin-bottom: 10px;
        max-height: calc(100vh - 20px);
    }

    .modal-ai__header {
        padding: 16px 20px;
    }

    .modal-ai__body {
        padding: 20px;
    }

    .modal-ai__footer {
        padding: 16px 20px;
        flex-direction: column;
    }

    .modal-ai__footer button {
        width: 100%;
    }
}

/* Кастомный скроллбар для webkit браузеров */
.modal-ai__body::-webkit-scrollbar {
    width: 6px;
}

.modal-ai__body::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.modal-ai__body::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 3px;
}

.modal-ai__body::-webkit-scrollbar-thumb:hover {
    background: #999999;
}
