/**
 * Единые стили для всех модальных окон на сайте
 */

/* Базовые стили для всех модальных окон */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.modal-overlay.active,
.modal-overlay.flex {
    display: flex;
}

.modal-overlay.hidden {
    display: none !important;
}

/* Контейнер модального окна */
.modal-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    overflow-x: hidden;
}

@media (min-width: 640px) {
    .modal-container {
        max-width: 32rem;
        border-radius: 1rem;
    }
}

@media (min-width: 768px) {
    .modal-container {
        max-width: 42rem;
        border-radius: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .modal-container {
        max-width: 48rem;
    }
}

/* Кнопка закрытия */
.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 100000;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 9999px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.modal-close:hover {
    color: #374151;
    background: #f3f4f6;
    transform: scale(1.1);
}

.modal-close svg {
    width: 1.25rem;
    height: 1.25rem;
    pointer-events: none;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .modal-close {
        top: 1rem;
        right: 1rem;
        width: 2.25rem;
        height: 2.25rem;
    }
    
    .modal-close svg {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* Контент модального окна */
.modal-content {
    padding: 1rem;
}

@media (min-width: 640px) {
    .modal-content {
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .modal-content {
        padding: 2rem;
    }
}

@media (min-width: 1024px) {
    .modal-content {
        padding: 2.5rem;
    }
}

/* Lightbox для изображений */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
}

.lightbox-overlay.active,
.lightbox-overlay.flex {
    display: flex;
}

.lightbox-overlay.hidden {
    display: none !important;
}

.lightbox-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    width: 100%;
    overflow: auto;
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 0.5rem;
    margin: 0 auto;
    display: block;
}

.lightbox-title {
    color: white;
    text-align: center;
    margin-top: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100000;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 9999px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.lightbox-close:hover {
    color: #111827;
    background: white;
    transform: scale(1.1);
    box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.4);
}

.lightbox-close svg {
    width: 1.5rem;
    height: 1.5rem;
    pointer-events: none;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .lightbox-close {
        top: 1.5rem;
        right: 1.5rem;
        width: 3rem;
        height: 3rem;
    }
    
    .lightbox-close svg {
        width: 1.75rem;
        height: 1.75rem;
    }
}

/* Кнопки навигации в лайтбоксе */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100001;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 9999px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: none;
    outline: none;
}

.lightbox-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 12px -1px rgba(0, 0, 0, 0.15);
}

.lightbox-nav svg {
    width: 1.5rem;
    height: 1.5rem;
    pointer-events: none;
}

.lightbox-nav-prev {
    left: 1rem;
}

.lightbox-nav-next {
    right: 1rem;
}

@media (min-width: 640px) {
    .lightbox-nav {
        width: 3.5rem;
        height: 3.5rem;
    }
    
    .lightbox-nav-prev {
        left: 2rem;
    }
    
    .lightbox-nav-next {
        right: 2rem;
    }
}

/* Счетчик в лайтбоксе */
.lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100001;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Блокировка скролла при открытом модальном окне */
body.modal-open {
    overflow: hidden;
}

/* Анимации */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.modal-overlay.active {
    animation: modalFadeIn 0.2s ease-out;
}

.modal-container {
    animation: modalSlideIn 0.3s ease-out;
}

/* Адаптивность для мобильных */
@media (max-width: 640px) {
    .modal-container {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }
    
    .modal-content {
        padding: 1rem;
    }
    
    .lightbox-container {
        padding: 0.5rem;
    }
    
    .lightbox-image {
        max-height: 80vh;
    }
}

/* Исправление для iPhone */
@supports (-webkit-touch-callout: none) {
    .modal-overlay {
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-container {
        -webkit-overflow-scrolling: touch;
    }
}
