/* Модальное окно - СНАЧАЛА СКРЫТО */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    /* ВАЖНО: скрыто по умолчанию */
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Нельзя кликать пока скрыто */
}

.modal-overlay.show {
    display: flex;
    /* Показываем только с классом .show */
    opacity: 1;
    pointer-events: auto;
    /* Разрешаем клики когда открыто */
}

.modal-container {
    background: white;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
    /* Чтобы скругления работали */
}

.modal-overlay.show .modal-container {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.modal-icon {
    font-size: 32px;
    margin-right: 15px;
    flex-shrink: 0;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    font-size: 15px;
    color: #475569;
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body strong {
    color: #e70000;
    font-weight: 600;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.modal-button {
    padding: 12px 32px;
    background: #e70000;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.modal-button:hover {
    background: #cc0000;
    transform: translateY(-1px);
}

.modal-button:active {
    transform: translateY(0);
}

/* Анимация для иконки */
@keyframes successPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.modal-overlay.show .modal-icon {
    animation: successPulse 0.6s ease-in-out;
}

/* Адаптивность модального окна */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 15px;
    }

    .modal-container {
        max-width: 90%;
    }

    .modal-header {
        padding: 18px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-body {
        padding: 18px;
    }

    .modal-footer {
        padding: 18px;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-end;
        /* На мобильных снизу */
    }

    .modal-container {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        /* Выезжает снизу */
    }

    .modal-overlay.show .modal-container {
        transform: translateY(0);
    }

    .modal-header {
        padding: 16px;
    }

    .modal-title {
        font-size: 17px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-body p {
        font-size: 14px;
    }

    .modal-footer {
        padding: 16px;
    }

    .modal-button {
        width: 100%;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 360px) {
    .modal-header {
        padding: 14px;
    }

    .modal-body {
        padding: 14px;
    }

    .modal-body p {
        font-size: 13px;
    }

    .modal-footer {
        padding: 14px;
    }

    .modal-button {
        padding: 10px 24px;
        font-size: 14px;
    }
}

/* Ландшафтная ориентация */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-overlay {
        align-items: center;
        /* В ландшафте по центру */
        padding: 10px;
    }

    .modal-container {
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 16px;
        transform: translateY(0) scale(0.9);
        transform-origin: center;
    }

    .modal-overlay.show .modal-container {
        transform: translateY(0) scale(1);
    }
}

/* Безопасные зоны для iPhone с вырезом */
@supports (padding: max(0px)) {
    .modal-overlay {
        padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    }

    @media (max-width: 480px) {
        .modal-overlay {
            padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        }

        .modal-container {
            margin-bottom: env(safe-area-inset-bottom);
            /* Отступ от нижнего выреза */
        }
    }
}

/* Для touch-устройств убираем hover-эффекты */
@media (hover: none) and (pointer: coarse) {
    .modal-button:hover {
        transform: none;
    }

    .modal-close:hover {
        opacity: 0.7;
    }
}