/* Theme V2: visual-only overrides. No logic, ids, or structure changed. */

/* ===== 1. БАЗОВАЯ ТЕМА И КОНТЕЙНЕР ===== */
.theme-v2 {
  background: radial-gradient(ellipse at 50% -20%, #0d0f12 0%, #050608 70%, #040507 100%);
  min-height: 100vh;
}

/* ===== 2. ВЕРХНИЙ БАР (STICKY, ПРАВИЛЬНЫЙ СЛОЙ) ===== */
.theme-v2 header {
  position: static; /* двигается вместе со страницей */
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.05));
  backdrop-filter: blur(6px);
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.theme-v2 .main-title {
  text-shadow: 0 0 16px rgba(184,255,90,.4);
  letter-spacing: 1.5px;
  margin: 0 0 8px 0;
  font-size: 24px;
}

.theme-v2 .main-subtitle {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

/* ===== 3. ОТСТУПЫ ПОД ВЕРХНИЙ БАР ===== */
.theme-v2 .screen {
  padding-top: 16px; /* компактный верхний отступ */
}

.theme-v2 #screen-upload {
  padding-top: 16px;
}

.theme-v2 #screen-revise {
  padding-top: 16px; /* отступ для экрана ревизии */
}

/* ===== 4. КАРТОЧКИ ===== */
.theme-v2 .card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)), #12161c;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 8px 28px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.03);
  margin: 12px;
  padding: 16px;
}

/* ===== 5. СТАРТОВАЯ СТРАНИЦА - АТМОСФЕРНАЯ ФРАЗА ===== */
.theme-v2 .barman-quote {
  text-align: center;
  margin: 24px auto;
  padding: 0 24px;
  max-width: 480px;
}

.theme-v2 .barman-quote p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(184,255,90,.7);
  font-style: italic;
  margin: 0;
}

/* ===== 6. КНОПКА "НАЧАТЬ РЕВИЗИЮ" - ПОКАЗЫВАТЬ УСЛОВНО ===== */
/* Логика показа/скрытия остаётся в JS, здесь только стили */
.theme-v2 #btn-start {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-v2 #btn-start:not([style*="display: none"]) {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 7. ПОИСК И ВЫПАДАЮЩИЙ СПИСОК (ПРАВИЛЬНЫЕ СЛОИ) ===== */
.theme-v2 .search {
  position: relative !important; /* чтобы дропдаун позиционировался от поля */
  z-index: 2;
}

.theme-v2 .search-wrap { position: relative; }

.theme-v2 #suggestions {
  position: absolute !important;
  top: calc(100% + 6px) !important; /* прямо под инпутом */
  left: 0 !important;
  right: 0 !important;
  z-index: 95 !important;
  margin-top: 0 !important;
  max-height: 320px;
  overflow-y: auto;
}

/* ===== 8. БЛОК "ВЫБРАНО: ..." (ПОД ПОИСКОМ, НАД КЛАВИАТУРАМИ) ===== */
.theme-v2 #composer {
  margin-top: 12px;
}

.theme-v2 .composer-item {
  margin-bottom: 12px;
}

/* ===== 9. КЛАВИАТУРЫ (ФИКСИРОВАННАЯ СЕТКА) ===== */
.theme-v2 .keypad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 480px) {
  .theme-v2 .keypad {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===== 10. НИЖНЯЯ ПАНЕЛЬ ДЕЙСТВИЙ (ЕДИНООБРАЗНЫЕ КНОПКИ) ===== */
.theme-v2 .footer {
  position: sticky;
  bottom: 0;
  z-index: 90;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* Кнопки в нижней панели - одинаковые, без эмодзи */
.theme-v2 .actions-top {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.theme-v2 .actions-top .btn {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  background: #2a2f38;
  color: #e8edf2;
  border: 1px solid rgba(255,255,255,.08);
}

.theme-v2 .actions-top .btn.primary {
  background: #3a4150;
  color: #b8ff5a;
  border: 1px solid rgba(184,255,90,.2);
}

.theme-v2 .actions-top .btn:hover {
  background: #323844;
  border-color: rgba(255,255,255,.12);
}

.theme-v2 .actions-top .btn.primary:hover {
  background: #424b5e;
  border-color: rgba(184,255,90,.3);
}

/* ===== 11. СКРЫТЬ КНОПКУ МЕНЮ НА МОБИЛЕ ===== */
@media (max-width: 480px) {
  .theme-v2 #btn-menu,
  .theme-v2 .actions-bottom {
    display: none !important;
  }
}

/* ===== 12. БЕЗОПАСНАЯ ОБЛАСТЬ ПОД КЛАВИАТУРУ ===== */
@supports (padding: max(0px)) {
  .theme-v2 .footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ===== 13. ЭКРАН ЗАВЕРШЕНИЯ (УЛУЧШЕННЫЙ ДИЗАЙН) ===== */
.theme-v2 #screen-finished {
  min-height: calc(100vh - 80px);
  /* display управляется базовыми стилями .screen/.active */
  align-items: center;
  justify-content: flex-start; /* карточка чуть выше по экрану */
  padding: 32px 24px 24px;
}

.theme-v2 #screen-finished.active {
  display: flex;
}

.theme-v2 .screen-finished {
  width: 100%;
  max-width: 560px;
  margin: 12px auto 0; /* немного выше */
  text-align: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)), #12161c;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}

.theme-v2 .screen-finished h2 {
  font-size: 32px;
  margin-bottom: 16px;
  color: #b8ff5a;
  text-shadow: 0 0 20px rgba(184,255,90,.4);
}

.theme-v2 .screen-finished p {
  font-size: 16px;
  color: rgba(255,255,255,.7);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* Крупная и аккуратная кнопка "Открыть файл" */
.theme-v2 #btn-open-file,
.theme-v2 #btn-open-file-finished,
.theme-v2 .btn-open-file,
.theme-v2 #download-link,
.theme-v2 #download-save-link {
  width: 100%;
  max-width: 100%;
  height: 56px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  background: linear-gradient(180deg, #2a2f38, #222731);
  color: #e8edf2;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 6px 22px rgba(0,0,0,.45);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.theme-v2 .file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 12px 14px;
  color: #e8edf2;
}

.theme-v2 .file-chip__icon { font-size: 20px; }
.theme-v2 .file-chip__name { font-weight: 600; flex: 1; }
.theme-v2 .file-chip__size { opacity: .7; font-size: 12px; }

.theme-v2 .file-chip:hover {
  border-color: rgba(255,255,255,.16);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
}

.theme-v2 #btn-open-file:hover,
.theme-v2 #btn-open-file-finished:hover,
.theme-v2 .btn-open-file:hover,
.theme-v2 #download-link:hover,
.theme-v2 #download-save-link:hover {
  background: linear-gradient(180deg, #323844, #29303a);
  border-color: rgba(255,255,255,.18);
}

.theme-v2 #btn-new-session-finished {
  width: 100%;
  max-width: 100%;
  height: 56px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  background: linear-gradient(135deg, #b8ff5a, #a0e050);
  color: #0a0f12;
  border: none;
  box-shadow: 0 8px 24px rgba(184,255,90,.3);
  transition: all .3s ease;
}

.theme-v2 #btn-new-session-finished:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(184,255,90,.4);
}

@media (min-width: 481px) {
  .theme-v2 #btn-new-session-finished {
    max-width: 360px;
  }
}

/* ===== 14. ТИПОГРАФИКА ===== */
.theme-v2 h1 { 
  font-size: 24px;
  font-weight: 700;
}

.theme-v2 h2 { 
  font-size: 20px;
  font-weight: 600;
}

.theme-v2 h3 { 
  font-size: 18px;
  font-weight: 600;
}

@media (min-width: 481px) {
  .theme-v2 h1 { font-size: 28px; }
  .theme-v2 h2 { font-size: 24px; }
  .theme-v2 h3 { font-size: 20px; }
}

/* ===== 15. ЕДИНЫЙ СТИЛЬ КНОПОК ===== */
.theme-v2 .btn {
  height: 44px;
  border-radius: 12px;
  font-weight: 600;
  transition: all .2s ease;
  border: 1px solid rgba(255,255,255,.08);
}

.theme-v2 .btn.primary {
  background: linear-gradient(135deg, #b8ff5a, #a0e050);
  color: #0a0f12;
  border: none;
  box-shadow: 0 4px 16px rgba(184,255,90,.25);
}

.theme-v2 .btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(184,255,90,.35);
}

/* Неактивные кнопки */
.theme-v2 .btn.disabled,
.theme-v2 .btn:disabled {
  background: rgba(255,255,255,.02);
  border-color: rgba(255,255,255,.04);
  color: rgba(255,255,255,.3);
  cursor: not-allowed;
  opacity: 0.5;
}

.theme-v2 .btn.disabled:hover,
.theme-v2 .btn:disabled:hover {
  transform: none;
  background: rgba(255,255,255,.02);
  border-color: rgba(255,255,255,.04);
}

/* ===== 16. АНИМАЦИИ ===== */
.theme-v2 .btn,
.theme-v2 .button {
  opacity: 0;
  transform: translateY(6px);
  animation: fadeInUp .45s ease forwards;
}

.theme-v2 .btn:nth-child(2),
.theme-v2 .button:nth-child(2) { animation-delay: .05s; }

.theme-v2 .btn:nth-child(3),
.theme-v2 .button:nth-child(3) { animation-delay: .1s; }

@keyframes fadeInUp { 
  to { 
    opacity: 1; 
    transform: translateY(0); 
  } 
}

/* ===== 17. ХОВЕРЫ И АКТИВНЫЕ СОСТОЯНИЯ ===== */
.theme-v2 .btn:hover,
.theme-v2 .button:hover {
  box-shadow: 0 0 18px rgba(184,255,90,.25);
}

.theme-v2 .segmented .active,
.theme-v2 .segmented button.active {
  outline: 1px solid rgba(255,255,255,.08);
  background: var(--accent);
  color: #0a0f12;
}

/* ===== 18. TOAST ===== */
.theme-v2 .toast { 
  box-shadow: 0 10px 30px rgba(0,0,0,.55); 
}

/* ===== 19. МОБИЛЬНЫЕ ОПТИМИЗАЦИИ ===== */
@media (max-width: 480px) {
  /* Компактный текст кнопки добавления */
  .theme-v2 .add-item-text { 
    display: none; 
  }
  
  /* Отступы карточек */
  .theme-v2 .card {
    margin: 8px;
    padding: 14px;
  }
  
  /* Поля ввода на всю ширину */
  .theme-v2 input[type="text"],
  .theme-v2 input[type="number"] {
    width: 100%;
    font-size: 16px; /* предотвращает зум на iOS */
  }
  
  /* Заголовок меньше на мобиле */
  .theme-v2 .main-title {
    font-size: 20px;
  }
  
  .theme-v2 .main-subtitle {
    font-size: 13px;
  }
}

/* ===== 20. SEGMENTED КНОПКИ ===== */
.theme-v2 .segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-v2 .segmented .btn {
  background: rgba(255,255,255,.04);
  flex: 1;
  min-width: fit-content;
}

.theme-v2 .segmented .btn.active {
  background: var(--accent);
  color: #0a0f12;
}

/* ===== 21. Z-INDEX ИЕРАРХИЯ ===== */
/* 
  100 - header (topbar)
  95  - search dropdown (suggestions)
  90  - bottom actions (footer)
  auto - обычный контент
*/

/* ===== 22. МОДАЛКИ (ВЫСОКИЙ СЛОЙ) ===== */
.theme-v2 #unit-modal,
.theme-v2 #add-item-modal,
.theme-v2 #waiting-overlay {
  z-index: 1000;
}

/* ===== 23. АДАПТИВНОСТЬ COMPOSER ===== */
@media (max-width: 480px) {
  .theme-v2 .composer-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .theme-v2 .composer-actions .btn {
    width: 100%;
  }
}

/* ===== 24. ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ ===== */
/* Скролл для suggestions */
.theme-v2 #suggestions::-webkit-scrollbar {
  width: 6px;
}

.theme-v2 #suggestions::-webkit-scrollbar-track {
  background: rgba(0,0,0,.2);
  border-radius: 3px;
}

.theme-v2 #suggestions::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 3px;
}

.theme-v2 #suggestions::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.3);
}

/* Выровнять элементы в file-upload */
.theme-v2 .file-upload {
  margin-top: 0;
}

/* Spacing для session-info если показан */
.theme-v2 .session-info {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ===== 25. АТМОСФЕРНЫЕ ФИЧИ СТАРТОВОГО ЭКРАНА ===== */

/* Атмосферный фон с боке-эффектами */
.theme-v2 .rev-atmo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120px 80px at 20% 30%, rgba(255,180,80,.12), transparent 70%),
    radial-gradient(160px 110px at 75% 25%, rgba(184,255,90,.10), transparent 70%),
    radial-gradient(100px 80px at 70% 80%, rgba(255,220,140,.08), transparent 70%),
    radial-gradient(circle at 40% 50%, #0f1216, #080a0c 70%);
  animation: revAtmoPulse 8s ease-in-out infinite alternate;
  filter: saturate(1.05);
}

@keyframes revAtmoPulse {
  from { 
    opacity: .45; 
    transform: scale(1); 
  }
  to { 
    opacity: .75; 
    transform: scale(1.03); 
  }
}

/* Ритуал-интро */
.theme-v2 .rev-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0e1115 0%, #06080a 80%);
  backdrop-filter: blur(4px);
}

.theme-v2 .rev-intro__card {
  color: #e8edf2;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 0 20px rgba(184,255,90,.3);
}

.theme-v2 .rev-intro__line {
  opacity: 0;
  animation: introFade 1s ease forwards;
  margin: 8px 0;
}

.theme-v2 .rev-intro__line:nth-child(1) { animation-delay: .1s; }
.theme-v2 .rev-intro__line:nth-child(2) { animation-delay: 1.2s; }
.theme-v2 .rev-intro__line:nth-child(3) { animation-delay: 2.3s; }

@keyframes introFade {
  to { opacity: 1; }
}

.theme-v2 .rev-intro--hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

/* Доска славы */
.theme-v2 .hall.card {
  margin-top: 12px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border: 1px solid rgba(255,255,255,.04);
}

.theme-v2 .hall__title {
  font-weight: 800;
  margin-bottom: 8px;
  color: #e8edf2;
  font-size: 14px;
  text-shadow: 0 0 10px rgba(255,180,80,.2);
}

.theme-v2 .hall__list {
  margin: 0;
  padding-left: 18px;
  color: #cfd6dd;
  font-size: 13px;
  line-height: 1.4;
}

.theme-v2 .hall__list li {
  margin: 2px 0;
  opacity: 0.9;
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
  .theme-v2 .rev-atmo { 
    animation-duration: 10s; 
    opacity: .6; 
  }
  
  .theme-v2 .rev-intro__card { 
    font-size: 16px; 
  }
  
  .theme-v2 .hall.card { 
    margin-top: 8px; 
    padding: 10px; 
  }
  
  .theme-v2 .hall__title { 
    font-size: 13px; 
  }
  
  .theme-v2 .hall__list { 
    font-size: 12px; 
  }
}

/* Отключение анимаций для пользователей с prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .theme-v2 .rev-atmo {
    animation: none;
    opacity: .5;
  }
  
  .theme-v2 .rev-intro__line {
    animation: none;
    opacity: 1;
  }
}
