/* web/static/css/styles.css - MOBILE OPTIMIZED VERSION */
/* Monochrome Gallery - Responsive Design */

:root {
  --bg-dark: #0e0e0e;
  --bg-panel: #141414;
  --border: #252525;
  --accent: #00ff94;
  --accent-dim: rgba(0, 255, 148, 0.1);
  --text-main: #ececec;
  --text-muted: #777;
  --card-bg: #1a1a1a;
  --bottom-nav-height: 60px;
  --top-bar-height: 50px;
}

* {
  box-sizing: border-box;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height для мобильных */
  display: flex;
  overflow: hidden;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

/* === DESKTOP: SIDEBAR === */
.sidebar {
  width: 320px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.mode-badge.admin {
  background: var(--accent);
  color: #000;
}

.mode-badge.public {
  background: #333;
  color: #888;
}

.search-box {
  width: 100%;
  background: #000;
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.2s;
}

.search-box:focus {
  border-color: var(--accent);
}

.lists-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.list-col {
  flex: 1;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.list-col:last-child {
  border-right: none;
}

/* === LIST ITEMS === */
.list-item {
  padding: 12px 16px;
  font-size: 13px;
  cursor: pointer;
  color: #aaa;
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item:hover {
  background: #1f1f1f;
  color: #fff;
}

.list-item.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.list-item-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  transition: all 0.3s;
  flex-shrink: 0;
}

.list-item.status-complete .status-dot {
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
}

.list-item.status-partial .status-dot {
  background: #ffcc00;
  box-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
}

.preview-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #222;
  transition: opacity 0.3s;
}

.preview-thumb.loading {
  opacity: 0;
}

/* === MAIN CONTENT === */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-dark);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* === TOP BAR === */
.top-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  z-index: 10;
  min-height: var(--top-bar-height);
}

.breadcrumb {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.breadcrumb-collection {
  color: var(--text-main);
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-weight: 400;
}

.breadcrumb-model {
  color: var(--text-muted);
  font-weight: 400;
}

.breadcrumb-rarity {
  background: rgba(255, 148, 206, 0.2);
  color: #ff94ce;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 148, 206, 0.3);
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #aaa;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: 0.3s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #000;
}

/* === GRID === */
.grid-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.group-section {
  margin-bottom: 24px;
}

.group-header {
  font-size: 12px;
  font-weight: 600;
  color: #777;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #222;
  padding-bottom: 5px;
}

/* === CARDS === */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #444;
}

.card-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.8;
}

.lottie-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  height: 85%;
  z-index: 2;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

.lottie-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lottie-wrapper.loading {
  opacity: 0;
}

.lottie-wrapper.loaded {
  opacity: 1;
  transition: opacity 0.3s;
}

.card-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.card-name {
  font-size: 10px;
  font-weight: 500;
  color: #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.badge-real {
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: #aaa;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  margin-left: 4px;
}

.badge-real.is-real {
  background: rgba(0, 255, 148, 0.2);
  color: var(--accent);
  border-color: var(--accent);
}

.badge-real.is-extracted {
  background: rgba(255, 200, 0, 0.2);
  color: #ffcc00;
  border-color: #ffcc00;
}

.card.selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-dim);
}

.card.selected::after {
  content: "MONO";
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 10;
}

.card.dimmed {
  opacity: 0.3;
  filter: grayscale(0.9);
}

.card.dimmed:hover {
  opacity: 1;
  filter: grayscale(0);
}

.stats-container {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 5;
}

.stat-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: fit-content;
}

.stat-badge.price {
  color: #ffcc00;
  border-color: rgba(255, 204, 0, 0.3);
}

.stat-badge.supply {
  color: #00ccff;
  border-color: rgba(0, 204, 255, 0.3);
}

.stat-badge.rarity {
  color: #ff94ce;
  border-color: rgba(255, 148, 206, 0.3);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 26, 0.95);
  z-index: 4;
  transition: opacity 0.3s;
}

.card-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #333;
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, #1a1a1a 0%, #222 50%, #1a1a1a 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -100% 0;
  }
  100% {
    background-position: 100% 0;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.save-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  z-index: 100;
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Поднимаем save кнопку когда фильтры открыты */
.save-container.lifted {
  bottom: calc(var(--bottom-nav-height) + 100px);
}

.save-container.hidden {
  display: none;
}

.save-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 255, 148, 0.3);
}

.save-btn:disabled {
  background: #333;
  color: #555;
  cursor: not-allowed;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  font-size: 14px;
  color: #555;
  text-align: center;
  padding: 20px;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

/* === BOTTOM NAVIGATION (Mobile) === */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 0;
}

.bottom-nav-items {
  display: flex;
  height: 100%;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  color: #777;
  transition: color 0.2s;
  border: none;
  background: none;
  font-family: inherit;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Sidebar Overlay для мобильных */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Menu Toggle Button - УБРАНА */
.mobile-menu-toggle {
  display: none !important;
}

/* ============================================
   RESPONSIVE: MOBILE FIRST
   ============================================ */

@media (max-width: 768px) {
  /* Убираем padding-bottom, так как grid-wrapper сам справится */
  body {
    display: flex;
    flex-direction: column;
  }

  /* Показываем bottom nav */
  .bottom-nav {
    display: block;
  }

  /* Прячем sidebar по умолчанию */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: var(--bottom-nav-height);
    width: 90%;
    max-width: 400px;
    transform: translateX(-100%);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  /* Показываем только одну колонку в sidebar */
  .sidebar.show-collections .list-col#col-list {
    display: block;
    width: 100%;
  }

  .sidebar.show-collections .list-col#mod-list {
    display: none;
  }

  .sidebar.show-models .list-col#col-list {
    display: none;
  }

  .sidebar.show-models .list-col#mod-list {
    display: block;
    width: 100%;
  }

  /* По умолчанию показываем обе колонки */
  .sidebar:not(.show-collections):not(.show-models) .list-col {
    display: block;
    width: 50%;
  }

  /* Top bar упрощаем */
  .top-bar {
    padding: 8px 12px;
    min-height: auto;
  }

  .breadcrumb {
    font-size: 12px;
    gap: 4px;
    flex: 1;
  }

  .breadcrumb-rarity {
    font-size: 9px;
    padding: 2px 5px;
  }

  /* Фильтры - скрываем по умолчанию на мобильных */
  .controls {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 12px);
    right: 12px;
    left: 12px;
    background: var(--bg-panel);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    flex-direction: row;
    justify-content: space-around;
    gap: 8px;
    z-index: 100;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);

    /* Анимация появления */
    display: flex;
    transform: translateY(calc(100% + var(--bottom-nav-height) + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .controls.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .toggle-wrapper {
    gap: 6px;
    font-size: 10px;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .toggle-wrapper span {
    order: 2;
  }

  .switch {
    order: 1;
    width: 32px;
    height: 18px;
  }

  .slider:before {
    height: 12px;
    width: 12px;
  }

  input:checked + .slider:before {
    transform: translateX(14px);
  }

  /* Grid */
  .grid-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    padding: 12px;
    padding-bottom: calc(var(--bottom-nav-height) + 12px);
    min-height: 0; /* Важно для flex контейнера */
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card-name {
    font-size: 9px;
  }

  .badge-real {
    font-size: 7px;
    padding: 1px 3px;
  }

  .stat-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  .card.selected::after {
    font-size: 8px;
    top: 5px;
    right: 5px;
  }

  .save-container {
    bottom: calc(var(--bottom-nav-height) + 12px);
    right: 12px;
  }

  .save-container.lifted {
    bottom: calc(var(--bottom-nav-height) + 90px);
  }

  .save-btn {
    padding: 10px 20px;
    font-size: 12px;
    border-radius: 6px;
  }

  .group-header {
    font-size: 11px;
    margin-bottom: 8px;
  }

  /* Уменьшаем высоту списков в sidebar */
  .lists-wrapper {
    height: calc(100% - 80px);
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 90%;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .grid-wrapper {
    padding: 10px;
    padding-bottom: calc(var(--bottom-nav-height) + 10px);
  }

  .card-name {
    font-size: 8px;
  }

  .badge-real {
    font-size: 6px;
  }

  .stat-badge {
    font-size: 7px;
    max-width: 60px;
  }

  .bottom-nav {
    height: 56px;
  }

  :root {
    --bottom-nav-height: 56px;
  }

  .save-btn {
    padding: 8px 16px;
    font-size: 11px;
  }

  .save-container.lifted {
    bottom: calc(var(--bottom-nav-height) + 85px);
  }
}

@media (max-width: 360px) {
  .grid {
    gap: 6px;
  }

  .card-footer {
    padding: 6px;
  }

  .lottie-wrapper {
    width: 80%;
    height: 80%;
  }

  .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
  }

  .bottom-nav-icon {
    font-size: 18px;
  }

  .bottom-nav-label {
    font-size: 9px;
  }
}

/* Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .grid-wrapper {
    padding: 8px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }

  .save-container {
    bottom: 8px;
    right: 8px;
  }
}

/* Desktop: hide mobile elements */
@media (min-width: 769px) {
  .bottom-nav,
  .sidebar-overlay,
  .mobile-menu-toggle {
    display: none !important;
  }

  .sidebar {
    transform: none !important;
  }

  .save-container {
    bottom: 20px;
    right: 20px;
  }
}
