/**
 * Фотогалерея мероприятия: сетка превью, лайтбокс, панель управления фотографа.
 *
 * Источник: раздел мероприятия (/events/{id}/gallery) и кабинет должностного лица
 * (/official/event/{id}/gallery). Имена классов — .event-gallery, .gallery-*.
 */

.event-gallery__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.gallery-event-meta {
    color: var(--md-on-surface-variant, #5f6368);
    font-size: 14px;
    margin-top: 4px;
}

/* ── Статистика ─────────────────────────────────────────────── */
.gallery-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.gallery-stat {
    background: var(--md-surface, #fff);
    border: 1px solid var(--md-outline, #dadce0);
    border-radius: 12px;
    padding: 10px 18px;
    min-width: 110px;
    text-align: center;
}

.gallery-stat__value {
    display: block;
    font-size: 22px;
    font-weight: 600;
    color: var(--md-on-surface, #1f1f1f);
    line-height: 1.2;
}

.gallery-stat__label {
    font-size: 12px;
    color: var(--md-on-surface-variant, #5f6368);
}

/* ── Панели управления ──────────────────────────────────────── */
.gallery-panel {
    margin-bottom: 16px;
}

.gallery-dropzone {
    position: relative;
    border: 2px dashed var(--md-outline, #dadce0);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.gallery-dropzone.is-dragover {
    border-color: var(--md-primary, #1a73e8);
    background: #e8f0fe;
}

.gallery-dropzone__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.gallery-dropzone__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--md-on-surface-variant, #5f6368);
    font-size: 14px;
}

.gallery-dropzone__label i {
    font-size: 36px;
    color: var(--md-primary, #1a73e8);
}

.gallery-dropzone__label small {
    color: var(--md-on-surface-variant, #80868b);
}

.gallery-dropzone__selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}

.gallery-selected-chip {
    background: #f1f3f4;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--md-on-surface, #1f1f1f);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-progress {
    width: 100%;
    height: 8px;
    margin: 8px 0;
}

.gallery-upload__status {
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 8px;
}

.gallery-upload__status.is-error {
    color: #d93025;
}

.gallery-upload__status.is-success {
    color: #1e8e3e;
}

/* ── Разделы ────────────────────────────────────────────────── */
.gallery-albums {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.gallery-album-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f3f4;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    color: var(--md-on-surface, #1f1f1f);
}

.gallery-album-chip__count {
    background: var(--md-surface, #fff);
    border-radius: 999px;
    padding: 0 6px;
    font-size: 12px;
    color: var(--md-on-surface-variant, #5f6368);
}

.gallery-album-chip__remove {
    border: none;
    background: transparent;
    color: var(--md-on-surface-variant, #5f6368);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.gallery-album-chip__remove:hover {
    color: #d93025;
}

/* ── Тулбар и фильтры ───────────────────────────────────────── */
.gallery-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gallery-filter {
    border: 1px solid var(--md-outline, #dadce0);
    background: var(--md-surface, #fff);
    color: var(--md-on-surface, #1f1f1f);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.gallery-filter:hover {
    border-color: var(--md-primary, #1a73e8);
}

.gallery-filter.is-active {
    background: var(--md-primary, #1a73e8);
    border-color: var(--md-primary, #1a73e8);
    color: #fff;
}

.gallery-toolbar__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
}

.gallery-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Подсказка в форме загрузки: водяной знак включён в настройках мероприятия */
.gallery-settings-hint {
    margin: 0;
    font-size: 12px;
}

a.gallery-item__author {
    text-decoration: none;
}

a.gallery-item__author:hover {
    text-decoration: underline;
}

/* ── Форма создания раздела ─────────────────────────────────── */
.gallery-album-form .form-row {
    align-items: end;
}

.gallery-album-form__action {
    justify-content: flex-end;
}

/* ── Сетка фотографий — masonry, как в старой системе ───────── */
/* Изображения сохраняют свои пропорции, поэтому портретные фото не обрезаются:
   плитка тянется по высоте картинки, а не по фиксированному 4:3. */
.gallery-grid {
    columns: 220px;
    column-gap: 12px;
}

.gallery-item {
    position: relative;
    margin: 0 0 12px;
    background: var(--md-surface, #fff);
    border: 1px solid var(--md-outline, #dadce0);
    border-radius: 12px;
    overflow: hidden;
    display: block;
    break-inside: avoid;
}

.gallery-item[draggable="true"] {
    cursor: grab;
}

.gallery-item.is-dragging {
    opacity: 0.4;
}

.gallery-item--draft {
    border-style: dashed;
}

.gallery-item__open {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: #f1f3f4;
    cursor: zoom-in;
}

.gallery-item__open img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s;
}

.gallery-item__open:hover img {
    opacity: 0.9;
}

.gallery-item__badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 6px;
}

.gallery-badge {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.gallery-badge--featured {
    background: #f9ab00;
}

.gallery-badge--draft {
    background: #5f6368;
}

.gallery-item__caption {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    flex: 1;
}

.gallery-item__title {
    color: var(--md-on-surface, #1f1f1f);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-item__author {
    color: var(--md-on-surface-variant, #5f6368);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-item__actions {
    display: flex;
    gap: 6px;
    padding: 0 10px 10px;
}

/* ── Пустое состояние ───────────────────────────────────────── */
.gallery-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--md-on-surface-variant, #5f6368);
    border: 1px dashed var(--md-outline, #dadce0);
    border-radius: 12px;
    margin-bottom: 16px;
}

.gallery-empty i {
    font-size: 48px;
    color: var(--md-outline, #dadce0);
}

/* ── Лайтбокс ───────────────────────────────────────────────── */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox__image {
    max-width: 92vw;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 4px;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.28);
}

.gallery-lightbox__close {
    top: 18px;
    right: 22px;
}

.gallery-lightbox__nav--prev {
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox__nav--next {
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox__info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 20px 18px;
    color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.gallery-lightbox__title {
    font-size: 16px;
    font-weight: 600;
}

.gallery-lightbox__meta {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 8px;
}

.gallery-lightbox__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.gallery-lightbox__author {
    color: #fff;
    font-size: 13px;
    text-decoration: underline;
}

@media (max-width: 640px) {
    .gallery-grid {
        columns: 150px;
        column-gap: 8px;
    }

    .gallery-item {
        margin-bottom: 8px;
    }

    .gallery-lightbox__image {
        max-width: 96vw;
        max-height: 68vh;
    }

    .gallery-lightbox__nav--prev {
        left: 6px;
    }

    .gallery-lightbox__nav--next {
        right: 6px;
    }

    .gallery-toolbar__filters {
        gap: 8px;
    }
}

/*
 * Скрытие элементов, у которых базовый класс задаёт display.
 *
 * Утилита `.is-hidden { display: none }` (components.css) имеет тот же вес, что и наши
 * базовые правила (`.gallery-lightbox { display: flex }`, `.btn { display: inline-flex }`),
 * а этот файл подключается позже — поэтому без составного селектора элемент остаётся
 * видимым. Именно так «залипал» лайтбокс галереи: чёрный оверлей z-index 1200 закрывал
 * всю страницу при открытии `/events/{id}/gallery`.
 */
.gallery-lightbox.is-hidden,
.event-gallery .btn.is-hidden,
.event-gallery .gallery-progress.is-hidden,
.gallery-lightbox__author.is-hidden {
    display: none;
}

/* ── Массовое выделение фотографий ─────────────────────────── */
.gallery-item__select {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
    cursor: pointer;
}

.gallery-item__select input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

/* Бейджи «Избранное» / «Черновик» не перекрываются чекбоксом. */
.gallery-item__select ~ .gallery-item__badges {
    left: 42px;
}

