/* Карусель для мобильных устройств */
.mobile-carousel {
    display: none; /* По умолчанию скрыта */
    position: relative;
    overflow: hidden;
    width: 100%;
    border-radius: 7px;
    margin-bottom: 20px;
    background-color: #f5f5f5;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.carousel-slide {
    min-width: 100%;
    height: 400px;
    position: relative;
    flex-shrink: 0;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 7px;
}

/* Индикаторы карусели */
.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    z-index: 20;
    padding: 0 10px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
}

.carousel-dot.active {
    background: white;
    transform: scale(1.2);
    border-color: white;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* Кнопки навигации */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.carousel-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.carousel-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.carousel-nav:disabled:hover {
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.carousel-prev {
    left: 15px;
}

.carousel-next {
    right: 15px;
}

.carousel-nav i {
    font-size: 1.2rem;
    color: #333;
}

/* Галерея для десктопов */
.desktop-gallery {
    display: block; /* По умолчанию показываем десктопную галерею */
}

.apartment-gallery {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 40px;
}

.main-image {
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 500px;
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
}

.main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.main-image:hover img {
    transform: scale(1.03);
}

.thumb-image {
    height: 242px;
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
}

.thumb-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.thumb-image:hover img {
    transform: scale(1.08);
}

.show-all-photos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.3s;
    font-weight: 500;
    width: 100%;
    max-width: 300px;
}

.show-all-photos:hover {
    background: #e8e8e8;
    border-color: #d0d0d0;
    transform: translateY(-2px);
}

/* Мобильная версия (до 768px) */
@media (max-width: 768px) {
    /* Показываем карусель, скрываем десктопную галерею */
    .mobile-carousel {
        display: block;
    }
    
    .desktop-gallery {
        display: none !important;
    }
    
    .carousel-slide {
        height: 300px;
    }
    
    .carousel-nav {
        width: 40px;
        height: 40px;
    }
    
    .carousel-dots {
        bottom: 15px;
    }
    
    /* Адаптация других элементов для мобильных */
    .apartment-detail {
        padding: 100px 0 40px;
    }
    
    .detail-info h1 {
        font-size: 2rem;
    }
    
    .detail-price {
        font-size: 1.8rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .feature-item {
        padding: 12px;
        font-size: 0.9rem;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .carousel-slide {
        height: 250px;
    }
    
    .carousel-nav {
        width: 36px;
        height: 36px;
        top: 40%;
    }
    
    .carousel-prev {
        left: 10px;
    }
    
    .carousel-next {
        right: 10px;
    }
    
    .carousel-dots {
        bottom: 10px;
    }
    
    .carousel-dot {
        width: 8px;
        height: 8px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-info h1 {
        font-size: 1.8rem;
    }
}

/* Десктопная версия (от 769px и выше) */
@media (min-width: 769px) {
    /* Убеждаемся, что десктопная галерея видна */
    .desktop-gallery {
        display: block !important;
    }
    
    .mobile-carousel {
        display: none !important;
    }
    
    /* Оптимизация десктопной галереи */
    .apartment-gallery {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 15px;
    }
    
    .main-image {
        height: 500px;
    }
    
    .thumb-image {
        height: 242px;
    }
}

/* Тёмная тема */
@media (prefers-color-scheme: dark) {
    .mobile-carousel {
        background-color: #1e293b;
    }
    
    .carousel-nav {
        background: rgba(30, 41, 59, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .carousel-nav i {
        color: white;
    }
    
    .show-all-photos {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .show-all-photos:hover {
        background: #374151;
        border-color: #6b7280;
    }
}

/* Для устройств с поддержкой hover */
@media (hover: hover) and (pointer: fine) {
    .carousel-nav:hover {
        background: white;
        transform: translateY(-50%) scale(1.1);
    }
    
    .carousel-dot:hover {
        background: rgba(255, 255, 255, 0.8);
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-carousel {
    animation: fadeIn 0.5s ease-out;
}

/* Улучшение отзывчивости для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .apartment-gallery {
        grid-template-columns: 1.5fr 1fr;
    }
    
    .main-image {
        height: 400px;
    }
    
    .thumb-image {
        height: 193px; /* (400px - 15px) / 2 */
    }
}