/* Файл: /public/css/style.css */
/* Основные стили проекта  */

:root {
  --primary-color: #000000;
  --primary-hover: #333333;
  --secondary-color: #666666;
  --success-color: #000000;
  --success-hover: #333333;
  --danger-color: #dc3545;
  --danger-hover: #c82333;
  --info-color: #17a2b8;
  --warning-color: #ffc107;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --border-color: #dee2e6;
  --background-color: #ffffff;
  --body-bg-color: #f0f2f5;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --border-radius: 0.5rem;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

html { 
  font-size: 16px; 
  scroll-behavior: smooth; 
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  background-color: var(--body-bg-color);
  color: var(--dark-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.container {
  width: 100%;
  max-width: 960px;
  background-color: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.main-header { 
  padding: 8px 0px 3px 0px;
  background-color: var(--primary-color); 
  color: white;
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  flex-wrap: wrap; 
  gap: 1rem; 
}

.main-header h1 { 
  font-size: clamp(1.2rem, 3vw, 1.5rem); 
}

.main-header h1 a { 
  color: white; 
  text-decoration: none; 
}

.main-content { 
  padding: 1.5rem; 
  flex-grow: 1; 
}

.main-footer { 
  text-align: center; 
  padding: 1rem;
  background-color: var(--light-color); 
  border-top: 1px solid var(--border-color); 
  font-size: 0.9rem;
  color: var(--secondary-color); 
  flex-shrink: 0; 
}

.content-section { 
  margin-bottom: 2rem; 
  padding: 1.5rem;
  border: 1px solid var(--border-color); 
  border-radius: var(--border-radius); 
  background-color: #fff; 
}

.content-section > h3 { 
  margin-top: 0; 
  margin-bottom: 1.5rem; 
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem; 
}

details.content-section > summary { 
  cursor: pointer;
  font-weight: bold; 
  font-size: 1.2rem; 
}

.event-title { 
  text-align: center; 
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
  font-weight: 500; 
}

#hidden-login-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

#hidden-login-container a { 
  color: var(--primary-color);
  background-color: white; 
  padding: 5px 10px; 
  border-radius: var(--border-radius); 
  text-decoration: none; 
  font-size: 0.9rem; 
  box-shadow: var(--shadow-sm); 
}

/* --- FORMS --- */
.pincode-form, .upload-form, .login-form, .styled-form { 
  display: flex;
  flex-direction: column; 
  gap: 1.25rem; 
  max-width: 550px; 
  margin: 0 auto; 
}

.pincode-form { 
  gap: 1.5rem; 
}

.pincode-form button { 
  margin-top: 0.5rem; 
}

.form-group { 
  display: flex; 
  flex-direction: column; 
  gap: 0.5rem; 
}

.form-group-inline { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  flex-wrap: wrap; 
}

.form-row { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 1rem; 
  align-items: flex-end; 
}

.form-row .form-group { 
  flex: 1 1 auto; 
}

label { 
  font-weight: 500; 
  color: #495057; 
}

.sr-only { 
  position: absolute;
  width: 1px; 
  height: 1px; 
  padding: 0; 
  margin: -1px; 
  overflow: hidden;
  clip: rect(0, 0, 0, 0); 
  white-space: nowrap; 
  border-width: 0; 
}

input[type="text"], 
input[type="search"], 
input[type="password"], 
input[type="email"], 
input[type="datetime-local"], 
input[type="date"], 
select, 
textarea { 
  padding: 0.75rem;
  border: 1px solid var(--border-color); 
  border-radius: var(--border-radius); 
  font-size: 1rem;
  width: 100%; 
  font-family: inherit; 
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus { 
  outline: none; 
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

textarea { 
  resize: vertical; 
  min-height: 100px; 
}

/* --- BUTTONS --- */
button, .btn { 
  padding: 0.8rem 1.5rem; 
  border: none; 
  border-radius: var(--border-radius);
  background-color: var(--primary-color); 
  color: white; 
  font-size: 1rem; 
  font-weight: 500; 
  cursor: pointer;
  transition: background-color 0.2s; 
  text-align: center; 
  display: inline-flex; 
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1.5;
  min-height: 44px; 
  text-decoration: none; 
}

button:hover, .btn:hover { 
  background-color: var(--primary-hover); 
}

button:disabled, .btn:disabled { 
  background-color: var(--secondary-color); 
  cursor: not-allowed; 
  opacity: 0.7; 
}

.btn.danger, button.danger { 
  background-color: var(--danger-color); 
}

.btn.danger:hover, button.danger:hover { 
  background-color: var(--danger-hover); 
}

.btn.success, button.success { 
  background-color: var(--success-color); 
}

.btn.success:hover, button.success:hover { 
  background-color: var(--success-hover); 
}

.btn.secondary, button.secondary { 
  background-color: var(--secondary-color); 
}

.btn.secondary:hover, button.secondary:hover { 
  background-color: #5a6268; 
}

.btn-sm { 
  padding: 0.4rem 0.8rem; 
  font-size: 0.85rem;
  min-height: 32px;
}

/* --- MESSAGES & NOTIFICATIONS --- */
.message { 
  padding: 1rem; 
  border-radius: var(--border-radius); 
  margin: 1rem 0;
  border: 1px solid transparent; 
  animation: fadeIn 0.3s ease-out;
}

.message.success { 
  background-color: #d4edda; 
  color: #155724; 
  border-color: #c3e6cb; 
}

.message.error { 
  background-color: #f8d7da;
  color: #721c24; 
  border-color: #f5c6cb; 
}

.message.info { 
  background-color: #d1ecf1;
  color: #0c5460; 
  border-color: #bee5eb; 
}

/* --- QR CODE & COUNTDOWN --- */
.pincode-qrcode-wrapper {
    text-align: center;
    margin-bottom: -0.5rem;
}

.pincode-qrcode-wrapper .qr-code-link {
    display: inline-block;
    padding: 8px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.pincode-qrcode-wrapper .qr-code-link:hover {
    box-shadow: var(--shadow);
}

.pincode-qrcode-wrapper .qr-code-link img {
    display: block;
    width: 150px;
    height: 150px;
}

.countdown-container, .event-ended-container { 
  text-align: center; 
  padding: 2rem 1rem; 
}

.countdown-timer { 
  display: flex; 
  justify-content: center; 
  gap: 1rem;
  margin-top: 1.5rem; 
}

.timer-segment { 
  background: var(--light-color); 
  padding: 1rem; 
  border-radius: var(--border-radius); 
  min-width: 80px; 
}

.timer-segment span { 
  font-size: 2.5rem; 
  font-weight: bold;
  color: var(--primary-color); 
  display: block; 
}

.timer-segment small { 
  font-size: 0.9rem; 
  color: var(--secondary-color); 
}

/* --- LIGHTBOX --- */
.lightbox { 
  position: fixed; 
  top: 0;
  left: 0; 
  width: 100%; 
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85); 
  display: grid; 
  grid-template-rows: auto 1fr auto; 
  grid-template-columns: auto 1fr auto; 
  gap: 1rem;
  z-index: 2000;
  padding: 1rem; 
  opacity: 0; 
  visibility: hidden; 
  transition: opacity 0.3s ease, visibility 0.3s ease; 
}

.lightbox.show { 
  opacity: 1; 
  visibility: visible; 
}

/* НОВАЯ ЗОНА ДЛЯ ЖЕСТОВ - обеспечивает разделение жестов и кликов по кнопкам */
.lightbox-gesture-zone {
    grid-row: 2; 
    grid-column: 2; 
    position: relative; 
    display: flex !important; 
    justify-content: center; 
    align-items: center; 
    overflow: hidden;
    pointer-events: none;
    z-index: 2001;
}

/* Контент внутри зоны жестов должен быть интерактивным */
.lightbox-gesture-zone .lightbox-content,
.lightbox-gesture-zone img {
    pointer-events: auto;
}

.lightbox-content { 
    position: relative; 
    display: flex !important; 
    justify-content: center; 
    align-items: center; 
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* УЛУЧШЕННЫЕ СТИЛИ ДЛЯ ИЗОБРАЖЕНИЙ - кроссбраузерная оптимизация */
.lightbox img { 
  max-width: 100%;
  max-height: 100%; 
  display: block; 
  transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              opacity 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  margin: auto;
  cursor: grab;
  user-select: none;
  touch-action: pan-y pinch-zoom;
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000;
  will-change: transform, opacity;
}

.lightbox img:active {
  cursor: grabbing;
}

/* Класс для активного свайпа */
.lightbox img.swiping {
  transition: none;
  cursor: grabbing;
}

/* УЛУЧШЕННЫЕ АНИМАЦИИ ДЛЯ ВСЕХ БРАУЗЕРОВ */
.lightbox img.slide-out-left { 
  transform: translateX(-100%) scale(0.9); 
  opacity: 0; 
}
.lightbox img.slide-out-right { 
  transform: translateX(100%) scale(0.9); 
  opacity: 0; 
}
.lightbox img.slide-in-left { 
  transform: translateX(-100%) scale(0.9); 
  opacity: 0; 
}
.lightbox img.slide-in-right { 
  transform: translateX(100%) scale(0.9); 
  opacity: 0; 
}

/* Оптимизация для iOS */
@supports (-webkit-touch-callout: none) {
  .lightbox img {
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    -webkit-transform-style: preserve-3d;
  }
}

/* --- LIGHTBOX BUTTONS FIX --- */

/* Базовые стили для ВСЕХ кнопок lightbox */
.lightbox-close,
.lightbox-nav,
.lightbox-download-btn {
    background-color: transparent !important;
    border: none !important;
    padding: 0.5rem !important;
    margin: 0 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    min-width: auto !important;
    min-height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 3.5rem !important;
    height: 3.5rem !important;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    z-index: 2010;
    outline: none !important;
}

/* Убираем стандартные стили браузера для активного состояния lightbox кнопок */
.lightbox-close:active,
.lightbox-nav:active,
.lightbox-download-btn:active,
.lightbox-close:focus,
.lightbox-nav:focus,
.lightbox-download-btn:focus {
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Стили для иконок внутри кнопок */
.lightbox-close img,
.lightbox-nav img,
.lightbox-download-btn img {
    width: 3.5rem;
    height: 3.5rem;
    display: block;
    filter: none !important;
    transition: transform 0.2s ease;
    pointer-events: none;
}

/* Ховер-эффекты ТОЛЬКО для иконок - без фона */
.lightbox-close:hover,
.lightbox-nav:hover,
.lightbox-download-btn:hover {
    background-color: transparent !important;
    transform: scale(1.05);
}

.lightbox-close:hover img,
.lightbox-nav:hover img,
.lightbox-download-btn:hover img {
    transform: scale(1.1);
    filter: brightness(1.2) !important;
}

/* Активное состояние - тоже без фона */
.lightbox-close:active,
.lightbox-nav:active,
.lightbox-download-btn:active {
    background-color: transparent !important;
    transform: scale(1.02);
}

.lightbox-close:active img,
.lightbox-nav:active img,
.lightbox-download-btn:active img {
    transform: scale(1.05);
}

/* Фокус состояние для lightbox кнопок */
.lightbox-close:focus,
.lightbox-nav:focus,
.lightbox-download-btn:focus {
    background-color: transparent !important;
    outline: 2px solid transparent !important;
    outline-offset: 2px !important;
}

/* Позиционирование конкретных кнопок */
.lightbox-close { 
    grid-row: 1; 
    grid-column: 3; 
    justify-self: end; 
}

.lightbox-prev { 
    grid-row: 2; 
    grid-column: 1; 
    align-self: center;
    justify-self: start; 
}

.lightbox-next { 
    grid-row: 2; 
    grid-column: 3; 
    align-self: center;
    justify-self: end; 
}

.lightbox-controls { 
    grid-row: 1; 
    grid-column: 2; 
    justify-self: center; 
    display: flex; 
    gap: 1rem; 
    z-index: 2010;
    pointer-events: auto;
}

/* Убираем стандартные стили ссылки для кнопки скачивания */
.lightbox-download-btn {
    text-decoration: none !important;
    color: inherit !important;
}

.lightbox-loading { 
  background: rgba(0, 0, 0, 0.7);
  color: white; 
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.1rem;
  position: absolute; 
}

/* Блокировка скролла при открытом lightbox */
body.lightbox-open {
    overflow: hidden;
}

/* --- GALLERY --- */
.gallery-preview-container { 
  text-align: center; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 1.5rem;
}

.gallery, .gallery-preview { 
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); 
  gap: 1rem; 
  width: 100%; 
}

.gallery-preview { 
  justify-content: center; 
}

.gallery .thumbnail, .gallery-preview .thumbnail { 
  width: 100%; 
  border-radius: var(--border-radius); 
  box-shadow: var(--shadow-sm); 
  transition: transform 0.3s, box-shadow 0.3s; 
  aspect-ratio: 1 / 1;
  object-fit: cover; 
  cursor: pointer; 
}

.gallery .thumbnail:hover, .gallery-preview .thumbnail:hover { 
  transform: scale(1.05); 
  box-shadow: var(--shadow); 
}

.full-gallery-page .full-gallery-header { 
  display: flow;
  justify-content: space-between;
  align-items: center; 
  flex-wrap: wrap; 
  gap: 1rem; 
  margin-bottom: 0.5rem;
  padding-bottom: 1rem; 
  border-bottom: 1px solid var(--border-color); 
}

/* --- GALLERY TOOLBAR STYLES - IMPROVED --- */
.gallery-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
    position: relative;
    padding: 0.5rem 0;
}

/* Базовые стили для всех элементов toolbar */
.gallery-toolbar > * {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ЛЕВЫЙ БЛОК - всегда прижат к левому краю */
.gallery-toolbar > *:first-child {
    margin-right: auto;
    justify-content: flex-start;
}

/* ЦЕНТРАЛЬНЫЙ БЛОК - всегда по центру */
.gallery-toolbar > *:nth-child(2) {
    margin: 0 auto;
    justify-content: center;
    flex-shrink: 1;
}

/* ПРАВЫЙ БЛОК - всегда прижат к правому краю */
.gallery-toolbar > *:last-child {
    margin-left: auto;
    justify-content: flex-end;
}

/* Стили для кнопок в gallery-toolbar */
.gallery-back-btn,
.gallery-toolbar .qr-code-link {
    background-color: transparent !important;
    border: none !important;
    padding: 0.5rem !important;
    margin: 0 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    min-width: auto !important;
    min-height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 3.5rem !important;
    height: 3.5rem !important;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    text-decoration: none !important;
    color: inherit !important;
    outline: none !important;
}

/* Убираем стандартные стили браузера для активного состояния */
.gallery-back-btn:active,
.gallery-toolbar .qr-code-link:active,
.gallery-back-btn:focus,
.gallery-toolbar .qr-code-link:focus {
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Стили для иконок внутри кнопок gallery-toolbar */
.gallery-back-btn img,
.gallery-toolbar .qr-code-link img {
    width: 3.5rem;
    height: 3.5rem;
    display: block;
    filter: none !important;
    pointer-events: none;
}

/* Ховер-эффекты для кнопок gallery-toolbar */
.gallery-back-btn:hover,
.gallery-toolbar .qr-code-link:hover {
    background-color: transparent !important;
}

.gallery-back-btn:hover img,
.gallery-toolbar .qr-code-link:hover img {
    filter: none !important;
}

/* Активное состояние для кнопок gallery-toolbar - БЕЗ ФОНА */
.gallery-back-btn:active,
.gallery-toolbar .qr-code-link:active {
    background-color: transparent !important;
}

.gallery-back-btn:active img,
.gallery-toolbar .qr-code-link:active img {
}

/* Фокус состояние - убираем стандартное выделение */
.gallery-back-btn:focus,
.gallery-toolbar .qr-code-link:focus {
    background-color: transparent !important;
    outline: 2px solid transparent !important;
    outline-offset: 2px !important;
}

/* Плейсхолдеры для балансировки */
.gallery-toolbar-placeholder {
    width: 3.5rem;
    height: 3.5rem;
    visibility: hidden;
    flex-shrink: 0;
}

.full-gallery-page .gallery-title-text { 
  order: 2;
  width: 100%; 
  text-align: center; 
  margin-top: 0.5rem; 
}

.full-gallery-page .gallery-content-wrapper { 
  margin-bottom: 2rem; 
}

.download-public-container { 
  margin-top: 2rem; 
}

/* --- UPLOAD & CAMERA --- */
#file-input { display: none; }

.upload-section { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 1rem; 
}

.upload-section #upload-form { 
  width: 100%; 
}

.upload-section #upload-button { 
  max-width: 350px;
  margin: 0 auto; 
  display: block; 
}

.progress-container { 
  width: 100%; 
  background-color: #e9ecef; 
  border-radius: var(--border-radius); 
  overflow: hidden; 
  margin: 1rem 0; 
}

.progress-bar { 
  height: 20px;
  width: 0; 
  background-color: var(--success-color); 
  transition: width 0.3s ease; 
  border-radius: var(--border-radius); 
  text-align: center; 
  color: white; 
  font-size: 0.8rem;
  line-height: 20px; 
}

.camera-container { 
  display: flex;
  flex-direction: column; 
  align-items: center; 
  gap: 1rem; 
  width: 100%; 
  max-width: 640px;
  margin: 0 auto; 
}

.camera-wrapper { 
  position: relative; 
  width: 100%;
  background-color: #000; 
  overflow: hidden; 
  border-radius: var(--border-radius); 
  box-shadow: var(--shadow-sm);
  aspect-ratio: 4 / 3; 
}

.camera-layer { 
  position: absolute; 
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%; 
  pointer-events: none; 
}

#camera-preview { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  object-fit: cover;
  z-index: 1; 
}

.camera-background { z-index: 0; }
.camera-overlay { z-index: 2; }
.camera-background img, .camera-overlay img { width: 100%; height: 100%; }
.camera-fit-cover img { object-fit: cover; }
.camera-fit-contain img { object-fit: contain; }
.camera-fit-none img { object-fit: none; }

#camera-controls { 
  display: flex;
  justify-content: space-around; 
  align-items: center; 
  width: 100%;
  padding: 0.75rem; 
  background: var(--light-color); 
  border: 1px solid var(--border-color); 
  border-radius: var(--border-radius); 
}

#snap-photo { 
  flex-grow: 1;
  margin: 0 1rem; 
}

.camera-select-wrapper { 
  display: flex; 
  gap: 0.5rem; 
  align-items: center; 
}

.camera-select { 
  background: #fff; 
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius); 
  padding: 0.4rem; 
}

/* --- DASHBOARDS --- */
.dashboard-nav { 
  margin-bottom: 2rem; 
}

.dashboard-nav ul { 
  list-style: none; 
  display: flex;
  flex-wrap: wrap; 
  gap: 0.5rem 1rem; 
  padding: 1rem; 
  background-color: #e9ecef; 
  border-radius: var(--border-radius);
}

.dashboard-nav a { 
  text-decoration: none; 
  color: var(--primary-color); 
  font-weight: 500;
  padding: 0.5rem; 
  border-radius: calc(var(--border-radius) / 2); 
  transition: background-color 0.2s, color 0.2s;
  position: relative; 
  display: inline-block;
}

.dashboard-nav a:hover { 
  background-color: var(--primary-color); 
  color: white; 
}

.dashboard-nav .badge { 
  position: absolute; 
  top: -5px; 
  right: -10px; 
  background-color: var(--danger-color);
  color: white; 
  font-size: 0.7rem; 
  padding: 2px 6px; 
  border-radius: 50%; 
}

.data-table-wrapper { 
  overflow-x: auto; 
}

.data-table { 
  width: 100%; 
  border-collapse: collapse;
  margin-top: 1rem; 
  font-size: 0.9rem; 
}

.data-table th, .data-table td { 
  padding: 0.75rem; 
  text-align: left; 
  border-bottom: 1px solid var(--border-color); 
  vertical-align: middle;
}

.data-table th { 
  background-color: var(--light-color);
  font-weight: 600; 
  text-align: center; 
}

.data-table td:first-child { 
  text-align: left; 
}

.data-table .actions { 
  display: flex;
  flex-wrap: wrap; 
  gap: 0.5rem; 
  justify-content: center; 
}

.data-table .actions form { 
  margin: 0; 
}

.data-table .event-status-completed { color: var(--success-color); font-weight: bold; }
.data-table .event-status-active { color: var(--primary-color); font-weight: bold; }
.data-table .event-status-scheduled { color: var(--warning-color); }
tr.user-blocked { opacity: 0.6; background-color: #fef2f2; }
.pincodes-cell { padding: 1rem 1rem 1rem 2rem; border-bottom: 2px solid #ccc; background-color: #fcfcfc; }
.pincode-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.pincode-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; border-bottom: 1px solid var(--border-color); }
.pincode-item:last-child { border-bottom: none; }

/* --- MODALS --- */
.modal { 
  position: fixed; 
  top: 0; 
  left: 0; 
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6); 
  z-index: 1000; 
  display: none; 
  align-items: center; 
  justify-content: center; 
  padding: 1rem; 
}

.modal.is-active { 
  display: flex;
  animation: fadeIn 0.3s ease; 
}

.modal-content { 
  background: white; 
  padding: 2rem; 
  border-radius: var(--border-radius); 
  width: 100%; 
  max-width: 550px; 
  box-shadow: var(--shadow); 
  transform: scale(0.95);
  transition: transform 0.3s ease; 
}

.modal.is-active .modal-content { 
  transform: scale(1); 
}

.modal-buttons { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 1rem; 
  margin-top: 1.5rem;
  justify-content: flex-end; 
}

.modal-body-content { 
  margin-top: 1rem; 
  padding-top: 1rem; 
  border-top: 1px solid var(--border-color); 
  white-space: pre-wrap; 
  max-height: 50vh; 
  overflow-y: auto;
}

/* --- PAGINATION & SCROLL-TOP --- */
.pagination { 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  flex-wrap: wrap;
  list-style: none; 
  padding: 0; 
  margin: 2rem 0 1rem; 
  gap: 0.5rem; 
}

.pagination ul { 
  padding: 0; 
  margin: 0; 
  display: contents; 
}

.pagination li { 
  display: inline-block; 
}

.pagination a { 
  display: block; 
  padding: 0.5rem 1rem; 
  text-decoration: none; 
  color: var(--primary-color);
  border: 1px solid var(--border-color); 
  border-radius: var(--border-radius); 
  transition: background-color 0.2s, color 0.2s; 
}

.pagination a:hover { 
  background-color: #e9ecef; 
}

.pagination a.current { 
  background-color: var(--primary-color); 
  color: white; 
  border-color: var(--primary-color); 
  cursor: default; 
}

.pagination a.disabled { 
  color: var(--secondary-color); 
  pointer-events: none; 
  opacity: 0.6; 
}

.scroll-top-btn {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.3s, background-color 0.3s;
    text-decoration: none;
}

.scroll-top-btn:hover { 
  opacity: 1; 
  background-color: var(--primary-hover); 
}

/* --- MATERIALS --- */
.materials-gallery { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
  gap: 1.5rem; 
}
.material-card { 
  border: 1px solid var(--border-color); 
  border-radius: var(--border-radius);
  overflow: hidden; 
  display: flex; 
  flex-direction: column; 
  box-shadow: var(--shadow-sm); 
  transition: box-shadow 0.2s; 
}
.material-card:hover { 
  box-shadow: var(--shadow); 
}
.material-card-preview { 
  aspect-ratio: 16 / 10; 
  background-color: #eee; 
  display: block;
}
.material-card-preview img { 
  width: 100%; 
  height: 100%;
  object-fit: cover; 
}
.material-card-info { 
  padding: 1rem; 
  display: flex; 
  flex-direction: column; 
  gap: 0.75rem; 
  align-items: center; 
  text-align: center;
  flex-grow: 1;
}
.material-card-info p { margin: 0; font-weight: 500; width: 100%; }
.material-type-badge { font-size: 0.75rem; font-weight: bold; padding: 0.2rem 0.6rem; border-radius: 1rem; color: white; }
.material-type-badge.background { background-color: var(--info-color); }
.material-type-badge.overlay { background-color: var(--primary-color); }
.material-card-info small { color: var(--secondary-color); font-size: 0.8rem; }
.material-card-info form { width: 100%; margin-top: auto; }
.material-card-info .btn { width: 100%; }

/* --- ANIMATIONS --- */
@keyframes fadeIn { 
  from { opacity: 0; } 
  to { opacity: 1; } 
}

/* Индикатор загрузки для очень медленных соединений */
.loading-dots:after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* --- АДАПТИВНЫЕ СТИЛИ ДЛЯ GALLERY TOOLBAR --- */

/* Планшеты и маленькие десктопы */
@media (max-width: 1024px) {
    .gallery-toolbar {
        gap: 0.75rem;
        padding: 0.4rem 0;
    }
    
    .gallery-back-btn,
    .gallery-toolbar .qr-code-link {
        width: 3.2rem !important;
        height: 3.2rem !important;
    }
    
    .gallery-back-btn img,
    .gallery-toolbar .qr-code-link img {
        width: 3.2rem;
        height: 3.2rem;
    }
    
    .gallery-toolbar-placeholder {
        width: 3.2rem;
        height: 3.2rem;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .gallery-toolbar {
        gap: 0.5rem;
        padding: 0.3rem 0;
    }
    
    .gallery-back-btn,
    .gallery-toolbar .qr-code-link {
        width: 3rem !important;
        height: 3rem !important;
        padding: 0.4rem !important;
    }
    
    .gallery-back-btn img,
    .gallery-toolbar .qr-code-link img {
        width: 3rem;
        height: 3rem;
    }
    
    .gallery-toolbar-placeholder {
        width: 3rem;
        height: 3rem;
    }
}

/* Очень маленькие мобильные устройства */
@media (max-width: 480px) {
    .gallery-toolbar {
        gap: 0.25rem;
        padding: 0.2rem 0;
    }
    
    .gallery-back-btn,
    .gallery-toolbar .qr-code-link {
        width: 2.8rem !important;
        height: 2.8rem !important;
        padding: 0.3rem !important;
    }
    
    .gallery-back-btn img,
    .gallery-toolbar .qr-code-link img {
        width: 2.8rem;
        height: 2.8rem;
    }
    
    .gallery-toolbar-placeholder {
        width: 2.8rem;
        height: 2.8rem;
    }
    
    /* Убираем выделение при тапе на мобильных */
    .gallery-back-btn:active,
    .gallery-toolbar .qr-code-link:active {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Сверхмаленькие экраны */
@media (max-width: 360px) {
    .gallery-toolbar {
        gap: 0.15rem;
    }
    
    .gallery-back-btn,
    .gallery-toolbar .qr-code-link {
        width: 2.5rem !important;
        height: 2.5rem !important;
        padding: 0.25rem !important;
    }
    
    .gallery-back-btn img,
    .gallery-toolbar .qr-code-link img {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .gallery-toolbar-placeholder {
        width: 2.5rem;
        height: 2.5rem;
    }
}

/* Гарантия, что структура сохраняется при любых условиях */
.gallery-toolbar > *:first-child {
    order: 1;
    margin-right: auto !important;
}

.gallery-toolbar > *:nth-child(2) {
    order: 2;
    margin-left: auto !important;
    margin-right: auto !important;
}

.gallery-toolbar > *:last-child {
    order: 3;
    margin-left: auto !important;
}

/* --- FIX: QR Code Lightbox Styling --- */
.lightbox-btn svg {
    width: 24px;
    height: 24px;
    display: block;
}

.lightbox-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
}

.lightbox.qr-lightbox {
  display: flex !important;
  justify-content: center;
  align-items: center;
  padding: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 2000;
}

.lightbox.qr-lightbox .lightbox-content {
  width: 100%;
  height: 100%;
  display: flex !important;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  position: relative;
}

.lightbox.qr-lightbox img {
  background: white;
  padding: 1rem;
  max-width: 90vmin;
  max-height: 90vmin;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* --- FIX: QR Lightbox Close Button - Matching Main Lightbox --- */
.lightbox.qr-lightbox .lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background-color: transparent !important;
  border: none !important;
  padding: 0.5rem !important;
  margin: 0 !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  min-width: auto !important;
  min-height: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 3.5rem !important;
  height: 3.5rem !important;
  cursor: pointer;
  transition: all 0.2s ease;
  pointer-events: auto;
  z-index: 2010;
  outline: none !important;
  font-size: 0 !important;
  color: transparent !important;
}

/* Убираем стандартный текст "×" */
.lightbox.qr-lightbox .lightbox-close::before {
  content: none !important;
}

/* Добавляем SVG иконку закрытия */
.lightbox.qr-lightbox .lightbox-close::after {
  content: '';
  display: block;
  width: 3.5rem;
  height: 3.5rem;
  background-image: url('/images/Close.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: none !important;
  transition: transform 0.2s ease;
}

/* Ховер-эффекты для кнопки закрытия QR lightbox */
.lightbox.qr-lightbox .lightbox-close:hover {
  background-color: transparent !important;
  transform: scale(1.05);
}

.lightbox.qr-lightbox .lightbox-close:hover::after {
  transform: scale(1.1);
  filter: brightness(1.2) !important;
}

/* Активное состояние для кнопки закрытия QR lightbox */
.lightbox.qr-lightbox .lightbox-close:active {
  background-color: transparent !important;
  transform: scale(1.02);
}

.lightbox.qr-lightbox .lightbox-close:active::after {
  transform: scale(1.05);
}

/* Фокус состояние для кнопки закрытия QR lightbox */
.lightbox.qr-lightbox .lightbox-close:focus {
  background-color: transparent !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
}

/* Убираем стандартные стили браузера для активного состояния */
.lightbox.qr-lightbox .lightbox-close:active,
.lightbox.qr-lightbox .lightbox-close:focus {
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Адаптация для мобильных устройств */
@media (max-width: 480px) {
  .lightbox.qr-lightbox .lightbox-close {
    width: 4.5rem !important;
    height: 4.5rem !important;
    top: 0.5rem;
    right: 0.5rem;
  }
  
  .lightbox.qr-lightbox .lightbox-close::after {
    width: 4.5rem;
    height: 4.5rem;
  }
}

/* Сверхмаленькие экраны */
@media (max-width: 360px) {
  .lightbox.qr-lightbox .lightbox-close {
    width: 4rem !important;
    height: 4rem !important;
  }
  
  .lightbox.qr-lightbox .lightbox-close::after {
    width: 4rem;
    height: 4rem;
  }
}

/* --- RESPONSIVE ADAPTATIONS --- */
@media (max-width: 768px) {
  .main-header { 
    flex-direction: column; 
    text-align: center; 
  }
  .main-content { 
    padding: 1.5rem 1rem; 
  }
  .gallery, .gallery-preview { 
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); 
    gap: 0.75rem; 
  }
  .timer-segment { 
    min-width: 60px; 
    padding: 0.5rem; 
  }
  .timer-segment span { 
    font-size: 1.5rem; 
  }
  .btn-icon-mobile {
    font-size: 1.2rem;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    line-height: 1;
  }
  .btn-icon-mobile .btn-text {
    display: none;
  }

  /* Адаптация для gallery-toolbar на мобильных */
  .gallery-toolbar {
    padding: 0.5rem;
    gap: 0.75rem;
  }
  
  .gallery-back-btn,
  .gallery-toolbar .qr-code-link {
    width: 3rem !important;
    height: 3rem !important;
  }
  
  .gallery-back-btn img,
  .gallery-toolbar .qr-code-link img {
    width: 3rem;
    height: 3rem;
  }
  
  .gallery-toolbar-placeholder {
    width: 3rem;
    height: 3rem;
  }
  
  /* Сохраняем правильное расположение на мобильных */
  .gallery-toolbar > *:first-child {
    margin-right: auto;
  }
  
  .gallery-toolbar > *:nth-child(2) {
    margin-left: auto;
    margin-right: auto;
  }
  
  .gallery-toolbar > *:last-child {
    margin-left: auto;
  }
}

@media (max-width: 480px) {
  body { 
    padding: 0.5rem; 
  }
  .container { 
    border-radius: 0; 
    box-shadow: none; 
  }
  .main-content { 
    padding: 1rem; 
  }
  .gallery, .gallery-preview { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 0.5rem; 
  }
  .form-row { 
    flex-direction: column; 
    align-items: stretch; 
  }
  .countdown-timer { 
    gap: 0.5rem; 
  }
  
  /* ИСПРАВЛЕННАЯ мобильная версия lightbox */
  .lightbox {
    display: grid !important;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr auto 1fr;
    padding: 0.5rem;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* padding-bottom: env(safe-area-inset-bottom, 0px); Туточки*/
    padding-bottom: 4rem;;
  }
  
  .lightbox-gesture-zone {
    grid-row: 2;
    grid-column: 1 / span 3;
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 0.0rem; 
    box-sizing: border-box;
  }
  
  .lightbox-content {
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 0;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
  }
  
  .lightbox-content img {
    max-width: calc(100vw - 1.6rem - 1.5rem) !important;
    max-height: calc(100dvh - 10rem - 1rem) !important;
    object-fit: contain !important;
    margin: auto;
    width: auto !important;
    height: auto !important;
    object-position: center center !important;
    display: block !important;
    transform: none !important;
  }
  
  /* Кнопка закрытия - в правом верхнем углу */
  .lightbox-close {
    grid-row: 1;
    grid-column: 3;
    justify-self: end;
    align-self: start;
    margin: 0 !important;
    margin-top: 0.5rem !important;
  }
  
  /* Кнопки навигации - по бокам от изображения */
  .lightbox-prev {
    grid-row: 2;
    grid-column: 1;
    justify-self: start;
    align-self: center;
    margin-left: 0.5rem;
  }
  
  .lightbox-next {
    grid-row: 2;
    grid-column: 3;
    justify-self: end;
    align-self: center;
    margin-right: 0.5rem;
  }
  
  /* Кнопка скачивания - внизу по центру */
  .lightbox-controls {
    grid-row: 3;
    grid-column: 2;
    justify-self: center;
    align-self: end;
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    padding: 1rem 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    margin-bottom: 1rem !important;
  }
  
  /* ФИКСИРОВАННЫЕ РАЗМЕРЫ КНОПОК - одинаковые для всех состояний */
  .lightbox-close,
  .lightbox-nav,
  .lightbox-download-btn {
    width: 4.5rem !important;
    height: 4.5rem !important;
    transform: scale(1) !important;
    transition: none !important;
  }

  .lightbox-close img,
  .lightbox-nav img,
  .lightbox-download-btn img {
    width: 4.5rem;
    height: 4.5rem;
    transform: scale(1) !important;
    transition: none !important;
  }

  /* Убираем все эффекты наведения и нажатия */
  .lightbox-close:hover,
  .lightbox-nav:hover,
  .lightbox-download-btn:hover,
  .lightbox-close:active,
  .lightbox-nav:active,
  .lightbox-download-btn:active {
    transform: scale(1) !important;
    background-color: transparent !important;
  }

  .lightbox-close:hover img,
  .lightbox-nav:hover img,
  .lightbox-download-btn:hover img,
  .lightbox-close:active img,
  .lightbox-nav:active img,
  .lightbox-download-btn:active img {
    transform: scale(1) !important;
    filter: none !important;
  }

  /* Убираем выделение при тапе на кнопках lightbox */
  .lightbox-close:active,
  .lightbox-nav:active,
  .lightbox-download-btn:active {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    background-color: transparent !important;
  }

  /* Убираем стандартное выделение в мобильных браузерах */
  .lightbox-close,
  .lightbox-nav,
  .lightbox-download-btn {
    -webkit-tap-highlight-color: transparent;
    outline: none !important;
  }

  /* Адаптация для gallery-toolbar на очень маленьких экранах */
  .gallery-toolbar {
    gap: 0.5rem;
    padding: 0.25rem;
  }
  
  .gallery-back-btn,
  .gallery-toolbar .qr-code-link {
    width: 2.8rem !important;
    height: 2.8rem !important;
    padding: 0.4rem !important;
  }
  
  .gallery-back-btn img,
  .gallery-toolbar .qr-code-link img {
    width: 2.8rem;
    height: 2.8rem;
  }
  
  .gallery-toolbar-placeholder {
    width: 2.8rem;
    height: 2.8rem;
  }
  
  /* Сохраняем правильное расположение на очень маленьких экранах */
  .gallery-toolbar > *:first-child {
    margin-right: auto;
  }
  
  .gallery-toolbar > *:nth-child(2) {
    margin-left: auto;
    margin-right: auto;
  }
  
  .gallery-toolbar > *:last-child {
    margin-left: auto;
  }
}

/* Дополнительная адаптация для очень маленьких экранов */
@media (max-width: 360px) {
  .lightbox-close,
  .lightbox-nav,
  .lightbox-download-btn {
    width: 4rem !important;
    height: 4rem !important;
  }
  
  .lightbox-close img,
  .lightbox-nav img,
  .lightbox-download-btn img {
    width: 4rem;
    height: 4rem;
  }
  
  .lightbox-prev {
    margin-left: 0.25rem;
  }
  
  .lightbox-next {
    margin-right: 0.25rem;
  }

  .lightbox-content img {
    max-width: calc(100vw - 1.6rem - 1.5rem) !important;
    max-height: calc(100dvh - 10rem - 1.5rem) !important;
  }

  /* Адаптация для gallery-toolbar на очень маленьких экранах */
  .gallery-back-btn,
  .gallery-toolbar .qr-code-link {
    width: 2.5rem !important;
    height: 2.5rem !important;
    padding: 0.3rem !important;
  }
  
  .gallery-back-btn img,
  .gallery-toolbar .qr-code-link img {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  .gallery-toolbar-placeholder {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  /* Сохраняем правильное расположение */
  .gallery-toolbar > *:first-child {
    margin-right: auto;
  }
  
  .gallery-toolbar > *:nth-child(2) {
    margin-left: auto;
    margin-right: auto;
  }
  
  .gallery-toolbar > *:last-child {
    margin-left: auto;
  }
}

/* Скрытие кнопки "Поделиться галереей" */
#share-gallery-btn {
  display: none !important;
}

/* --- ОПТИМИЗАЦИИ ДЛЯ ПЛАВНОСТИ --- */

/* Оптимизация анимаций для плавности */
.lightbox img {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000;
  will-change: transform, opacity;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Улучшенные анимации с GPU-ускорением */
.lightbox img.slide-out-left,
.lightbox img.slide-out-right,
.lightbox img.slide-in-left,
.lightbox img.slide-in-right {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, opacity;
}

/* Оптимизация для быстрого переключения */
.lightbox img.instant-transition {
  transition: none !important;
}

/* Улучшение производительности на мобильных */
@media (max-width: 480px) {
  .lightbox img {
    -webkit-backface-visibility: hidden;
    -webkit-transform-style: preserve-3d;
  }
}

/* Индикатор загрузки для оптимизированной версии */
.lightbox-loading.optimized {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

/* Плавное появление/исчезновение для прелоадера */
.lightbox-loading {
  transition: opacity 0.3s ease;
}

.lightbox-loading.fade-out {
  opacity: 0;
}
