body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

.gallery-page {
    position: relative;
    min-height: calc(100vh - 70px);
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    overflow: hidden;
    background: linear-gradient(180deg,
            rgba(9, 182, 162, 0.04) 0%,
            rgba(9, 182, 162, 0.02) 35%,
            rgba(255, 255, 255, 1) 100%);
}

.animated-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 0;
}

.floating-letters {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.letter {
    position: absolute;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 3rem;
    animation: floatLetter 20s linear infinite;
    will-change: transform;
    opacity: 0.012;
}

@keyframes floatLetter {
    0% {
        transform: translate(0, 100vh) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: var(--letter-opacity, 0.05);
    }

    90% {
        opacity: var(--letter-opacity, 0.05);
    }

    100% {
        transform: translate(0, -100px) rotate(360deg);
        opacity: 0;
    }
}

.gallery-section {
    padding: 4rem 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.section-header {
    text-align: center;
    margin-bottom: 0;
}

.gallery-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0;
    color: #2C3E50;
    text-transform: uppercase;
}

.gallery-subtitle {
    display: block;
    font-size: 0.5em;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gallery-container {
    padding: 0 2rem;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Плавная смена контента */
.gallery-container.transitioning .gallery-grid {
    opacity: 0.5;
    pointer-events: none;
}

.gallery-grid {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
    animation: fadeIn 0.4s ease-in-out;
    min-height: 400px;
    transition: opacity 0.3s ease-in-out;
    will-change: opacity;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item {
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid rgba(226, 232, 240, 0.8);
    animation: slideUp 0.5s ease-out backwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item:hover {
    border-color: rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.gallery-image-wrapper {
    position: relative;
    aspect-ratio: var(--gallery-aspect-ratio, 576/320);
    overflow: hidden;
}

/* Формат 3:4 для продуктовых фото */
[data-gallery-type="product-photos"] .gallery-image-wrapper {
    aspect-ratio: 3/4;
}

/* Отладочное отображение имени файла */
.debug-filename {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 10;
    pointer-events: none;
}

.gallery-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image-wrapper img {
    transform: scale(1.05);
}

.gallery-info {
    padding: 1.25rem 1.5rem;
    background: white;
    position: relative;
    z-index: 3;
}

.gallery-model {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.gallery-description {
    font-size: 0.9375rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 4rem 0;
    color: #6B7280;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #079383;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1a202c;
}

.empty-state p {
    font-size: 1rem;
    color: #4a5568;
}

/* Стили для переключателя табов */
.gallery-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    max-width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.gallery-tab {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid transparent;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    z-index: 2;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.gallery-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(9, 182, 162, 0.08) 0%, rgba(7, 147, 131, 0.08) 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: -1;
}

.gallery-tab i {
    font-size: 1.25rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
}

.gallery-tab:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(9, 182, 162, 0.3);
    color: #079383;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(9, 182, 162, 0.12);
}

.gallery-tab:hover::before {
    opacity: 1;
}

.gallery-tab:hover i {
    transform: scale(1.1);
    opacity: 1;
}

.gallery-tab.active {
    background: linear-gradient(135deg, #09B6A2 0%, #079383 100%);
    border-color: transparent;
    color: white;
    box-shadow:
        0 4px 16px rgba(9, 182, 162, 0.3),
        0 2px 8px rgba(7, 147, 131, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: tabActivate 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-tab.active::before {
    display: none;
}

.gallery-tab.active i {
    opacity: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.gallery-tab.active:hover {
    transform: translateY(-1px);
    box-shadow:
        0 6px 20px rgba(9, 182, 162, 0.35),
        0 3px 10px rgba(7, 147, 131, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes tabActivate {
    0% {
        transform: scale(0.97);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.01);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media(max-width: 992px) {
    .gallery-title {
        font-size: 2.75rem;
    }
}

@media(max-width: 768px) {
    .gallery-container {
        padding: 0 1rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .gallery-info {
        padding: 1rem 1.25rem;
    }

    .gallery-tabs {
        gap: 0.75rem;
        padding: 0.375rem;
    }

    .gallery-tab {
        padding: 0.875rem 1.5rem;
        font-size: 0.875rem;
    }

    .gallery-tab i {
        font-size: 1.125rem;
    }

    .gallery-tab span {
        font-size: 0.875rem;
    }
}

@media(max-width: 480px) {
    .gallery-section {
        padding: 3rem 1rem 1.5rem;
    }

    .gallery-title {
        font-size: 2.25rem;
    }

    .gallery-tabs {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.375rem;
        width: calc(100% - 2rem);
        max-width: 100%;
    }

    .gallery-tab {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.25rem;
    }

    .gallery-tab i {
        font-size: 1.125rem;
    }
}

/* ========================================
   СЛАЙДЕР "ДО И ПОСЛЕ" ДЛЯ ПРОДУКТОВЫХ ФОТОГРАФИЙ
   ======================================== */

.image-comparison-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 20px 20px 0 0;
    /* Белый фон для обычных изображений */
    background-color: #ffffff;
    aspect-ratio: 3/4;
}

.comparison-before,
.comparison-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.comparison-before {
    background-color: #ffffff;
    z-index: 1;
}

.comparison-after {
    background-color: #ffffff;
    clip-path: inset(0 0 0 25%);
    z-index: 2;
}

.comparison-before img,
.comparison-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.comparison-label {
    position: absolute;
    top: 0.75rem;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.375rem 0.875rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.comparison-label-before {
    left: 0.75rem;
}

.comparison-label-after {
    right: 0.75rem;
}

.comparison-slider-handle {
    position: absolute;
    top: 0;
    left: 25%;
    width: 3px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.9) calc(50% - 28px),
        transparent calc(50% - 28px),
        transparent calc(50% + 28px),
        rgba(255, 255, 255, 0.9) calc(50% + 28px),
        rgba(255, 255, 255, 0.9) 100%
    );
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 2px 12px rgba(0, 0, 0, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 4;
    transform: translateX(-50%);
    cursor: ew-resize;
    transition: opacity 0.3s ease;
}

/* Расширенная зона захвата для удобства */
.comparison-slider-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 100%;
    cursor: ew-resize;
}

.slider-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.08),
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2C3E50;
    cursor: ew-resize;
    transition: all 0.3s ease;
}

.slider-button svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Hover эффект для кнопки */
.image-comparison-slider:hover .slider-button {
    background: rgba(255, 255, 255, 0.35);
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 6px 20px rgba(0, 0, 0, 0.2),
        0 12px 40px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Состояние перетаскивания */
.image-comparison-slider.dragging {
    cursor: ew-resize;
}

.image-comparison-slider.dragging .comparison-slider-handle {
    opacity: 1;
}

.image-comparison-slider.dragging .slider-button {
    transform: translate(-50%, -50%) scale(1.05);
}

/* Мобильная адаптация */
@media(max-width: 768px) {
    .slider-button {
        width: 48px;
        height: 48px;
    }

    .slider-button svg {
        width: 24px;
        height: 24px;
    }

    .comparison-label {
        font-size: 0.625rem;
        padding: 0.25rem 0.625rem;
    }
}
