/* modal.css - Модальные окна (формы, попапы) */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    /* КЛЮЧЕВОЕ: включаем скролл на оверлее */
    overflow-y: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 40px;
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-xl);
    position: relative;
    animation: slideIn 0.3s ease;
    /* Убираем ограничение высоты */
    max-height: none;
}

/* Для случаев, когда контент очень длинный */
@media (max-height: 700px) {
    .modal-content {
        margin: 20px auto;
    }
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #E5E7EB;
    background: white;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1A1A1A;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: #1A1A1A;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6B7280;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #D32F2F;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #F5F7FA;
}

.modal-large {
    max-width: 800px;
}

.modal-small {
    max-width: 400px;
}

@media (max-width: 768px) {
    .modal {
        width: 95%;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 12px 20px;
    }
}