/* Сетка каталога */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 20px 0;
}

.catalog-item {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.catalog-item:hover {
    transform: translateY(-5px);
}

.catalog-image img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
}

.catalog-title {
    margin: 10px 0;
    font-size: 16px;
    text-align: center;
}

/* Модальное окно */
.catalog-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: white;
    border-radius: 12px;
    padding: 30px;
    z-index: 1001;
    color: black; /* Цвет текста черный */
    display: flex;
    flex-direction: column;
}
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 1002;
}

.modal-body {
    display: flex;
    height: 100%;
}

.modal-left,
.modal-right {
    flex: 1 1 50%;
    padding: 10px;
}
.modal-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.main-image-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    /*  overflow: hidden;     */
    overflow: hidden; 
}

#modalMainImage {
    max-width: 100%;
    width: 100%; /*     */
    height: 100%; /* :  max-height */
    object-fit: cover; /* :  contain */
}
.thumbnails-container {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.thumbnails img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
}

.thumbnails img.active {
    border-color: #0073aa;
}
.modal-navigation {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none;
}

.nav-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    margin: 0 20px;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Адаптивность */
@media (max-width: 1024px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-body {
        flex-direction: column;
        height: auto;
    }
    
    .modal-left,
    .modal-right {
        flex: none;
    }
    
    .main-image-container {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .catalog-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        height: 90%;
        margin: 2% auto;
        padding: 15px;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin: 0 10px;
    }
}
/*                   */
.modal-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1003;
    border-radius: 12px;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.loading-spinner p {
    margin: 0;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/*                          */
@media (max-width: 768px) {
    .loading-spinner .spinner {
        width: 40px;
        height: 40px;
        border-width: 4px;
    }
    
    .loading-spinner p {
        font-size: 14px;
    }
}