/* Исправление стилей модальных окон для iOS устройств */

/* Увеличиваем z-index для модальных окон */
.modal {
    z-index: 9999 !important;
}

.modal-backdrop {
    z-index: 9998 !important;
}

/* Исправляем позиционирование на мобильных устройствах */
@media (max-width: 768px) {
    .modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .modal-dialog {
        margin: 60px 15px 120px 15px !important;
        max-height: calc(100vh - 180px) !important;
        width: calc(100% - 30px) !important;
        max-width: none !important;
    }
    
    .modal-content {
        max-height: 100% !important;
        border-radius: 8px !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 280px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Специальные стили для iOS */
@supports (-webkit-touch-callout: none) {
    .modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .modal-dialog {
        margin: 60px 15px 120px 15px !important;
        max-height: calc(100vh - 180px) !important;
        width: calc(100vw - 30px) !important;
        max-width: none !important;
    }
    
    .modal-content {
        max-height: 100% !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 280px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 20px !important;
    }
    
    .modal-header {
        padding: 20px 20px 15px 20px !important;
        border-bottom: 1px solid #dee2e6 !important;
    }
    
    .modal-footer {
        padding: 15px 20px 20px 20px !important;
        border-top: 1px solid #dee2e6 !important;
    }
}

/* Исправляем backdrop для iOS */
@supports (-webkit-touch-callout: none) {
    .modal-backdrop {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
    }
}

/* Улучшаем скролл внутри модального окна */
.modal-body {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
}

/* Предотвращаем скролл основного контента при открытом модальном окне */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Стили для модальных окон с аккордеоном (города) */
#citiesModal .modal-body {
    padding: 0 !important;
}

#citiesModal .accordion-item {
    border: none !important;
    margin-bottom: 0 !important;
}

#citiesModal .accordion-button {
    padding: 15px 20px !important;
    background-color: #f8f9fa !important;
    border: none !important;
    border-bottom: 1px solid #dee2e6 !important;
}

#citiesModal .accordion-button:not(.collapsed) {
    background-color: #e9ecef !important;
    color: #495057 !important;
}

#citiesModal .accordion-body {
    padding: 15px 20px !important;
    background-color: #ffffff !important;
}

/* Стили для модального окна специализаций */
#specsModal .modal-body {
    padding: 20px !important;
}

#specsModal .form-check {
    margin-bottom: 10px !important;
    padding-left: 0 !important;
}

#specsModal .form-check-label {
    padding-left: 10px !important;
    cursor: pointer !important;
}

/* Улучшаем кнопки в модальных окнах */
.modal-footer .btn {
    min-width: 80px !important;
    height: 40px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

/* Анимации для плавного открытия/закрытия */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out !important;
    transform: translate(0, -20px) !important;
}

.modal.show .modal-dialog {
    transform: none !important;
}

/* Исправляем проблемы с фокусом */
.modal:focus {
    outline: none !important;
}

.modal-content:focus {
    outline: none !important;
}

/* Улучшаем доступность */
.modal[aria-hidden="false"] {
    display: block !important;
}

.modal[aria-hidden="true"] {
    display: none !important;
}
