.modal {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Inter", Arial, sans-serif;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.show {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 10px;
    width: 320px;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    position: relative;
    color: #333;
    max-height: 90vh; /* Ограничиваем высоту */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

/* Контейнер для контента внутри модалки */
.modal-body {
    flex-grow: 1;
    overflow-y: auto; /* Добавляем прокрутку, если не помещается */
    max-height: calc(75vh - 100px); /* Немного уменьшили с 80vh до 75vh */
    padding-bottom: 10px; /* Добавляем отступ снизу */
}

/* Адаптивное сжатие модалки при малых экранах */
@media (max-height: 700px) {
    .modal-content {
        width: 280px;
        padding: 15px;
        font-size: 14px;
    }
}

@media (max-height: 600px) {
    .modal-content {
        width: 260px;
        padding: 10px;
        font-size: 13px;
    }
}

@media (max-height: 500px) {
    .modal-content {
        width: 240px;
        padding: 8px;
        font-size: 12px;
    }
}

/* Контейнер с формой и кнопкой "Оформить" */
.modal-body {
    flex-grow: 1;
    overflow-y: auto;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.close:hover {
    color: #000;
}

h2 {
    font-size: 20px;
    color: #111;
    text-align: center;
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
}

input, select {
    width: 100%;
    padding: 8px;
    margin-bottom: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

input:focus, select:focus {
    border-color: #007bff;
    outline: none;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

.checkbox-container input {
    width: auto;
}

.modal-button {
    width: 100%;
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    text-decoration: none;
    transition: all 0.3s ease;
    background: #00aaff;
    color: white;
    border: none;
    margin-bottom: 5px; /* Добавлен отступ снизу для кнопки */
    position: relative; /* Обеспечивает видимость кнопки */
}

.modal-button:hover {
    background: #0077cc;
}

/* Категории услуг */
.service-category {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 8px;
    color: #00aaff;
    cursor: pointer;
    transition: color 0.3s ease;
}

.service-category.active {
    color: #0077cc;
}

/* Стили для кнопок выбора услуги */
.service-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.service-option {
    flex: 1 1 calc(50% - 8px);
    padding: 10px;
    border: 2px solid #ccc;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
}

.service-option.active {
    border-color: #00aaff;
    background: #00aaff;
    color: white;
}

/* Стили для мобильных устройств */
@media (max-width: 480px) {
    .service-option {
        flex: 1 1 100%;
    }
}
.service-options-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.service-options-container.open {
    max-height: 300px; /* Достаточно места для кнопок */
    overflow: visible; /* Даем доступ к кнопкам */
}

/* Сепаратор между блоками */
.separator-line {
    width: 100%;
    height: 2px;
    background-color: #ddd;
    margin: 12px 0;
}

/* Блок с подарочными данными */
.gift-details {
    display: none;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
}

/* Специальные стили для iOS устройств (iPhone) */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    .modal-content {
        -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
        padding-bottom: 25px; /* Увеличиваем отступ внизу для iOS */
        transform: scale(0.85); /* уменьшаем чуть-чуть */
        transform-origin: top center;
    }
    
    .modal-body {
        -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
        max-height: calc(80vh - 80px); /* Меньшая высота для iOS */
    }
    
    .service-options-container.open {
        max-height: 250px; /* Уменьшаем для iOS */
    }
}

/* Дополнительная медиа-запись специально для iPhone */
@media screen and (max-width: 428px) and (max-height: 926px) {
    .modal-content {
        width: 90%; /* Уменьшаем ширину для лучшего отображения */
        padding: 15px 15px 25px 15px; /* Увеличиваем отступ снизу */
    }
    
    .modal-button {
        padding: 10px 20px;
        margin-top: 5px; /* Добавляем отступ сверху */
    }
}