﻿/* Комментарий: Эталонный стиль для галереи и аватаров во всем приложении */
/* Комментарий: Базовые переменные для галереи */
.css-gallery {
    --gallery-height: 400px;
    --preview-size: 80px;
    --preview-gap: 10px;
    --border-color: #fff;
    --border-hover: #42a5f5;
    --transition-speed: 0.3s;
    --border-radius: 16px;
}

/* Комментарий: Стили для состояния загрузки */
.gallery-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--gallery-height);
}

/* Комментарий: Основной контейнер галереи */
.gallery-container {
    position: relative;
    height: var(--gallery-height);
    overflow: hidden;
    border-radius: var(--border-radius);
    aspect-ratio: 1/1;
}

/* Комментарий: Стили для пустой галереи */
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: var(--gallery-height);
    background: #f5f5f5;
    border-radius: var(--border-radius);
    color: #9e9e9e;
}

/* Комментарий: Контейнер для элементов галереи */
.gallery-items {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Комментарий: Стили для отдельного элемента галереи */
.gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    border: none !important;
    overflow: hidden;
}

    .gallery-item.active {
        opacity: 1;
        z-index: 1;
        border: 2px solid var(--border-color) !important;
        border-radius: var(--border-radius) !important;
        overflow: hidden;
    }

/* Комментарий: Изображение в галерее */
.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    box-shadow: none !important;
    border: none !important;
    display: block;
}

/* Комментарий: Контейнер для аватара */
.avatar-container {
    width: 100%;
    height: var(--gallery-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: visible; /* Комментарий: Отключение обрезки для предотвращения обрезки аватара */
    background: #f0f0f0;
    box-shadow: none !important;
    border: 2px solid var(--border-color) !important;
}

/* Комментарий: Изображение аватара */
.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%; /* Комментарий: Добавлено для круглой формы изображения */
    box-shadow: none !important;
    border: none !important;
    max-width: 100%; /* Комментарий: Ограничение ширины контейнером */
    max-height: 100%; /* Комментарий: Ограничение высоты контейнером */
}

/* Комментарий: Контейнер для миниатюр */
.gallery-labels-container {
    width: 100%;
    padding: 10px 0 10px;
    display: flex;
    justify-content: center;
    z-index: 20;
}

/* Комментарий: Стили для панели миниатюр */
.gallery-labels {
    display: flex;
    gap: var(--preview-gap);
    z-index: 10;
    padding: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    box-shadow: none !important;
}

    .gallery-labels::-webkit-scrollbar {
        display: none;
    }

/* Комментарий: Стили для отдельной миниатюры */
.gallery-label {
    cursor: pointer;
    width: var(--preview-size);
    height: var(--preview-size);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
    flex-shrink: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

    .gallery-label:hover {
        border-color: var(--border-hover);
        transform: scale(1.05);
    }

    .gallery-label.active {
        border-color: var(--border-hover);
        box-shadow: 0 0 8px rgba(66, 165, 245, 0.8);
    }

    .gallery-label img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

/* Комментарий: Стили для кнопки "Показать все" */
.view-all-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid transparent;
    font-size: calc(var(--preview-size) * 0.6);
}

    .view-all-button:hover {
        background: rgba(255, 255, 255, 0.2);
        border-color: var(--border-hover);
        transform: scale(1.05);
    }

/* Комментарий: Контейнер для аватара в ячейке */
.avatar-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Комментарий: Режим аватара */
.avatar-mode .avatar-container {
    width: var(--gallery-height); /* Комментарий: Согласование ширины с высотой для квадратной формы */
    height: var(--gallery-height);
    border-radius: 50%;
    background: transparent !important;
    box-shadow: none !important;
    border: 2px solid var(--border-color) !important;
    margin: 0 auto;
}

/* Комментарий: Прозрачная галерея */
.transparent-gallery .gallery-container {
    background: transparent !important;
    box-shadow: none !important;
    border: none;
}

.transparent-gallery .gallery-item {
    background: transparent !important;
    box-shadow: none !important;
}

.transparent-gallery .gallery-image {
    border-radius: 0 !important;
    box-shadow: none !important;
}

.transparent-gallery .gallery-labels {
    background: transparent !important;
    backdrop-filter: none !important;
}

.transparent-gallery .gallery-item.active,
.transparent-gallery .avatar-container,
.transparent-gallery .avatar-mode .avatar-container {
    border: none !important;
}

/* Комментарий: Стили для стрелок навигации */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

    .nav-arrow:hover {
        background: rgba(0, 0, 0, 0.5);
        transform: translateY(-50%) scale(1.1);
    }

    .nav-arrow.left {
        left: 10px;
    }

    .nav-arrow.right {
        right: 10px;
    }

    .nav-arrow i {
        font-size: 24px;
    }

/* Комментарий: Стили для видео-контейнеров */
.video-poster-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Комментарий: Кнопка воспроизведения на основном изображении */
.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(89,74,226,1);
    border-radius: 50%;
    width: 15%;
    height: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
}

    .video-play-button:hover {
        background: rgba(89,74,226,1);
        transform: translate(-50%, -50%) scale(1.1);
    }

    .video-play-button .mud-icon {
        color: white;
        font-size: 40px;
    }

/* Комментарий: Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .css-gallery {
        --gallery-height: auto;
        --preview-size: clamp(40px, 5vw, 60px);
    }

    .gallery-container {
        height: auto;
        aspect-ratio: unset;
    }

    .gallery-items {
        height: auto;
        aspect-ratio: unset;
    }

    .gallery-item {
        position: relative;
        display: none;
        height: auto;
        overflow: hidden;
    }

        .gallery-item.active {
            display: flex;
            opacity: 1;
            overflow: hidden;
        }

    .gallery-image {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .gallery-labels-container {
        padding: 10px 0 10px;
    }

    .avatar-mode .avatar-container {
        width: var(--gallery-height); /* Комментарий: Согласование ширины с высотой */
        height: var(--gallery-height);
        border: 2px solid var(--border-color) !important;
    }

    .transparent-gallery .gallery-container {
        height: auto !important;
    }

    .nav-arrow {
        display: flex !important;
        width: 30px;
        height: 30px;
    }

        .nav-arrow i {
            font-size: 18px;
        }

    .video-play-button {
        width: 15%;
        height: 15%;
    }

        .video-play-button .mud-icon {
            font-size: 30px;
        }
}

/* Комментарий: Темная тема */
@media (prefers-color-scheme: dark) {
    .css-gallery {
        --border-color: #555;
    }

    .gallery-label {
        border-color: #555;
    }

        .gallery-label.active {
            border-color: #42a5f5;
            box-shadow: 0 0 8px rgba(66, 165, 245, 0.8);
        }

    .gallery-empty {
        background: #121212;
        color: #b0b0b0;
    }

    .gallery-label {
        background: #333;
    }

    .nav-arrow {
        background: rgba(0, 0, 0, 0.5);
    }

        .nav-arrow:hover {
            background: rgba(0, 0, 0, 0.7);
        }
}

/* Комментарий: Стили для видео-постеров с разными соотношениями сторон */
.gallery-item.video-poster {
    position: relative;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: var(--gallery-height);
}

    .gallery-item.video-poster .gallery-image {
        object-fit: contain;
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        background-color: #000;
    }

    /* Комментарий: Удаление фиксированных aspect-ratio для видео-постеров */
    .gallery-item.video-poster.widescreen,
    .gallery-item.video-poster.standard,
    .gallery-item.video-poster.vertical,
    .gallery-item.video-poster.square {
        aspect-ratio: unset;
    }
