:root {
  --card: rgba(20, 26, 32, 0.72);
  --card-solid: #161c22;
  --text: #f1f5f9;
  --muted: #9aa7b4;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --border: rgba(255, 255, 255, 0.1);
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  background:
    linear-gradient(rgba(8, 11, 14, 0.78), rgba(8, 11, 14, 0.92)),
    url("/bg.jpg") center top / cover fixed no-repeat,
    #0b0f12;
}

.container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 28px;
}

/* Header / footer */
.site-header {
  background: rgba(12, 16, 20, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.logo {
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.admin-link:hover { text-decoration: underline; }

.site-footer {
  margin-top: 48px;
  padding: 24px 0;
}

/* Двухколоночный макет: товары слева, инфо-блоки справа */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1200px) 360px;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin: 24px 0;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 86px;
}

/* Инфо-карточки (облачка) */
.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.45;
}
.info-card h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--accent);
}
.info-card p { margin: 0 0 8px; color: var(--text); }
.info-card p:last-child { margin-bottom: 0; }
.info-card ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--text);
}
.info-card li { margin: 3px 0; }
.info-card a { color: var(--accent-hover); text-decoration: none; word-break: break-word; }
.info-card a:hover { text-decoration: underline; }
.info-card ul.links { list-style: none; padding-left: 0; }

/* Сворачиваемые блоки (details/summary) */
details.info-card { padding-top: 0; padding-bottom: 0; }
details.info-card summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
details.info-card summary::-webkit-details-marker { display: none; }
details.info-card summary::after {
  content: "▸";
  font-size: 0.9rem;
  transition: transform 0.15s ease;
}
details.info-card[open] summary::after { transform: rotate(90deg); }
.details-body { padding-bottom: 14px; }
.details-body > :first-child { margin-top: 0; }

/* Подблок внутри сворачиваемого блока */
.subblock {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.subblock h3 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--accent);
}
.subblock ul { margin: 0; padding-left: 16px; }

/* мини-метки редкости в тексте */
.rar { font-weight: 700; }
.rar-rare { color: #60a5fa; }
.rar-epic { color: #a78bfa; }
.rar-leg { color: #fbbf24; }

.section-title { margin: 0 0 16px; }

/* Product grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.product {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: cardIn 0.4s ease backwards;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .product { animation: none; }
}
/* Подсветка по краям при наведении — в цвет редкости */
.product:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.product.r-rare:hover {
  border-color: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.55), 0 8px 24px rgba(0, 0, 0, 0.5);
}
.product.r-epic:hover {
  border-color: #a78bfa;
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.55), 0 8px 24px rgba(0, 0, 0, 0.5);
}
.product.r-leg:hover {
  border-color: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.6), 0 8px 24px rgba(0, 0, 0, 0.5);
}
.product-img {
  aspect-ratio: 4 / 3;
  background: rgba(255, 255, 255, 0.04);
}
.product-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-image {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem;
}
.product-body { padding: 11px 13px; }
.product-body h3 { margin: 0 0 5px; font-size: 0.95rem; line-height: 1.25; }
.prod-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0 0 6px;
  font-size: 0.74rem;
  color: var(--muted);
}
.prod-meta .rar { color: inherit; }
.prod-meta .rar.rar-leg { color: #fbbf24; }
.prod-meta .rar.rar-epic { color: #a78bfa; }
.prod-meta .rar.rar-rare { color: #60a5fa; }
.price { color: var(--accent); font-weight: 700; font-size: 0.98rem; }
.desc { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; white-space: pre-wrap; }


.empty { color: var(--muted); }

/* Фильтры */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}
.filters label {
  margin: 0;
  font-size: 0.85rem;
}
.filters select {
  display: block;
  margin-top: 6px;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--card-solid);
  color: var(--text);
}

/* Бейджи редкости / типа */
.product-img { position: relative; }
.badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: #475569;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge.type { background: #0f766e; }
.badge.kind { background: #1d4ed8; }
.badge.rarity-Rare { background: #2563eb; }
.badge.rarity-Epic { background: #7c3aed; }
.badge.rarity-Legendary {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #1c1f23;
}
/* В админ-списке бейджи в общем потоке */
.admin-item-body .badges { position: static; margin: 4px 0; }

select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  background: var(--card-solid);
  color: var(--text);
}

/* Скрытые товары в админке */
.info-card,
.product,
.panel {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.admin-item.is-hidden { opacity: 0.55; }
.private-line {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #fbbf24;
  word-break: break-all;
}
.hidden-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Panels / forms (admin) */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.panel.narrow { max-width: 360px; margin: 40px auto; }
.panel h2 { margin-top: 0; }

label {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 0.9rem;
}
input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button { color: #1a1205; }
button.secondary { background: rgba(255, 255, 255, 0.12); color: var(--text); }
button.secondary:hover { background: rgba(255, 255, 255, 0.2); }
button.danger { background: var(--danger); color: #fff; }
button.danger:hover { background: #dc2626; }

.form-actions { display: flex; gap: 10px; }

/* Форма товара: поля в два столбца + бокс загрузки справа */
.pf-grid {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 20px;
  align-items: start;
}
.pf-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  align-content: start;
}
.pf-fields label { margin: 0; }
.pf-fields .pf-full { grid-column: 1 / -1; }

.pf-photo { display: flex; flex-direction: column; gap: 8px; }
.pf-photo button { width: 100%; }
.pf-buttons { flex-direction: column; gap: 8px; margin-top: 4px; }
.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 210px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  padding: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(251, 191, 36, 0.08);
}
.dz-empty { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.dz-icon { font-size: 2rem; margin-bottom: 6px; }
#dz-preview {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  object-fit: contain;
}

@media (max-width: 720px) {
  .pf-grid { grid-template-columns: 1fr; }
  .pf-fields { grid-template-columns: 1fr; }
}
.toolbar { display: flex; justify-content: flex-end; margin-top: 16px; }

.hint { color: var(--muted); font-size: 0.8rem; margin: -6px 0 12px; }

/* Вкладки админки */
.tabs { display: flex; gap: 8px; margin: 4px 0 16px; }
.tab-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.tab-btn:hover { background: rgba(255, 255, 255, 0.16); }
.tab-btn.active { background: var(--accent); color: #1a1205; }

/* Строки «Чужое» */
.cons-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.cons-row label { margin: 0; }
.cons-row.cons-row--new { border-color: var(--accent); }
.cons-row.is-sold { opacity: 0.6; }
.cons-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }

/* Поле пароля с кнопкой показа */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px 6px;
  font-size: 1.05rem;
  cursor: pointer;
  opacity: 0.7;
}
.pw-toggle:hover { background: transparent; opacity: 1; }
.error { color: var(--danger); margin: 8px 0 0; }
.saved { color: #16a34a; margin-left: 10px; font-size: 0.9rem; }

/* Admin product list */
.admin-list { display: flex; flex-direction: column; gap: 12px; }
.admin-item {
  display: flex;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.admin-thumb {
  width: 70px; height: 70px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.7rem; text-align: center;
}
.admin-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-item-body { flex: 1; min-width: 0; }
.admin-item-body strong { display: block; }
.admin-item-body p { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.admin-item-actions { display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  /* блоки — наверх, над товарами */
  .sidebar { position: static; top: auto; order: -1; }
  /* фильтры — сеткой 2 в ряд, сортировка снизу на всю ширину */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
  }
  .filters label { margin: 0; }
  .filters select { width: 100%; min-width: 0; }
  .filters label:last-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .admin-item { flex-wrap: wrap; }
}
