/**
 * Универсальные модальные окна
 * Размеры: small, medium, large
 */

/* Оверлей модального окна */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 30, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: var(--spacing-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Модальное окно */
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex !important;
    flex-direction: column;
    position: relative;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    margin: auto;
    height: auto;
}

/* Модалки подтверждения - не растягиваются по высоте */
.modal-confirm {
    max-height: 80vh;
    height: auto;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Размеры модальных окон */
.modal-small {
    width: 100%;
    max-width: 400px;
}

.modal-medium {
    width: 100%;
    max-width: 600px;
}

.modal-large {
    width: 100%;
    max-width: 900px;
}

/* Шапка модального окна */
.modal-header {
    padding: var(--spacing-xl);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    font-size: var(--text-2xl);
    font-weight: 500;
    color: var(--black);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--text-xl);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--black);
}

/* Тело модального окна */
.modal-body {
    padding: var(--spacing-xl);
    overflow-y: visible;
    flex: 0 0 auto;
}

/* Футер модального окна */
.modal-footer {
    padding: var(--spacing-xl);
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing);
    flex-shrink: 0;
}

.modal-footer .btn {
    min-width: 100px;
}

/* Блокировка скролла body */
body.modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0);
}

/* Адаптивность */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end !important;
        justify-content: center !important;
    }
    
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
    }
    
    .modal-small,
    .modal-medium,
    .modal-large {
        width: 100%;
        max-width: 100%;
    }
    
    /* Модалки подтверждения на мобильных */
    .modal-confirm {
        max-height: 85vh;
        height: auto;
    }
    
    /* Уменьшаем отступы в шапке модального окна */
    .modal-header {
        padding: var(--spacing-lg);
    }
    
    /* Уменьшаем размер заголовка */
    .modal-title {
        font-size: var(--text-xl);
    }
    
    /* Уменьшаем размер кнопки закрытия */
    .modal-close {
        width: 28px;
        height: 28px;
        font-size: var(--text-lg);
    }
    
    /* Уменьшаем отступы в теле модального окна */
    .modal-body {
        padding: var(--spacing-lg);
    }
    
    /* Уменьшаем отступы в футере модального окна */
    .modal-footer {
        padding: var(--spacing-lg);
        gap: var(--spacing-sm);
    }
    
    .modal-overlay.active .modal {
        animation: modalSlideUp 0.3s ease-out;
    }
    
    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 480px) {
    /* Еще больше уменьшаем отступы */
    .modal-header {
        padding: var(--spacing);
    }
    
    .modal-title {
        font-size: var(--text-lg);
    }
    
    .modal-body {
        padding: var(--spacing);
    }
    
    .modal-footer {
        padding: var(--spacing);
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        min-width: auto;
    }
}

/* Bulk-actions внутри модального окна */
.modal-body .bulk-actions-panel {
    position: relative;
    bottom: auto;
    margin-top: var(--spacing-sm);
    border-radius: var(--radius);
    background: var(--gray-50);
}

.modal-body .bulk-actions-buttons {
    display: none;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.modal-body .bulk-actions-buttons.show,
.modal-body .bulk-actions-buttons[style*="flex"] {
    display: flex;
}

