/* gallery.css - стили для галереи щенков */

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    animation: modalFadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
}

.modal-container {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 95vh;
    width: 900px;
    overflow: hidden;
    animation: modalSlideIn 0.4s ease;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--line);
    background: var(--accent-glow);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: var(--accent-dark);
    font-size: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--accent-dark);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Основное изображение - фиксированная высота для правильного масштабирования */
.gallery-main {
    width: 100%;
    height: 60vh; /* Основная высота — 60% экрана */
    min-height: 300px;
    max-height: 600px;
    border-radius: 12px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Теперь можно hidden — обрезки не будет, т.к. contain */
    padding: 15px;
    box-sizing: border-box;
}

/* Изображение - масштабируется внутри контейнера без обрезки */
.gallery-main img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: white;
    display: block;
}

/* Миниатюры */
.gallery-thumbs {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.5rem;
    background: var(--accent-glow);
    border-radius: 10px;
    max-height: 100px;

}

.gallery-thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    opacity: 0.7;
    flex-shrink: 0;
}

.gallery-thumb:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.gallery-thumb.active {
    border-color: var(--accent);
    opacity: 1;
    transform: scale(1.05);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Информация о щенке */
.gallery-info {
    background: var(--accent-glow);
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid var(--accent);

}

/* Остальные стили без изменений (футер, анимации, медиа-запросы) */
.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--line);
    background: var(--accent-glow);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-shrink: 0;
}

.modal-footer .btn {
    min-width: 140px;
    text-align: center;
}

/* Анимации */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Адаптивность */
@media (max-width: 768px) {
    .modal-container {
        max-width: 95%;
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 1rem;
        gap: 1rem;
    }
    
    .gallery-main {
        height: 50vh; /* Меньше на планшетах/мобильных */
        min-height: 250px;
        max-height: 450px;
    }
    
    .gallery-thumb {
        width: 60px;
        height: 60px;
    }
    
    .gallery-thumbs {
        max-height: 90px;
    }
    

    }
}

@media (max-width: 480px) {
    .gallery-main {
        height: 40vh; /* Ещё меньше на телефонах */
        min-height: 200px;
    }
    
    .gallery-thumb {
        width: 50px;
        height: 50px;
    }
    
    .gallery-thumbs {
        max-height: 80px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        min-width: unset;
    }
}

/* Загрузка и другие */
.gallery-main img.loading {
    opacity: 0.5;
}

.gallery-error {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    color: var(--muted);
    text-align: center;
    padding: 2rem;
}

.gallery-error::before {
    content: "🖼️";
    font-size: 3rem;
    opacity: 0.5;
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .modal {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .modal-container {
        background: var(--dark);
        border: 1px solid var(--accent-dark);
    }
    
    .gallery-main img {
        background: #2a2a2a;
    }
}