:root,
[data-theme="light"] {
  --bg: #FFF9F4;
  --bg-elev: #FFFFFF;
  --ink: #1A0F0C;
  --muted: #7A5C52;
  --accent: #FF8C00;
  --accent-strong: #D31D44;
  --accent-pop: #0047AB;
  --ok: #00B359;
  --line: rgba(211, 29, 68, 0.14);
  --header-bg: rgba(255, 249, 244, 0.94);
  --shadow: 0 1px 2px rgba(26, 15, 12, 0.04), 0 10px 28px rgba(211, 29, 68, 0.08);
  --input-bg: #FFFFFF;
  --thumb-bg: #FFE8D6;
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0A0A0A;
  --bg-elev: #161012;
  --ink: #FFF9F4;
  --muted: #C4A59A;
  --accent: #FF8C00;
  --accent-strong: #FF4D6D;
  --accent-pop: #4C8DFF;
  --ok: #2EE08A;
  --line: rgba(255, 140, 0, 0.18);
  --header-bg: rgba(10, 10, 10, 0.92);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(211, 29, 68, 0.18);
  --input-bg: #1C1416;
  --thumb-bg: #2A1A1C;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(211, 29, 68, 0.12), transparent 55%),
    radial-gradient(760px 380px at 100% 0%, rgba(255, 140, 0, 0.16), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(211, 29, 68, 0.22), transparent 55%),
    radial-gradient(760px 380px at 100% 0%, rgba(255, 140, 0, 0.14), transparent 50%),
    var(--bg);
}

h1, h2, h3, .navbar-brand {
  font-family: "Space Grotesk", sans-serif;
}

.admin-header {
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink) !important;
  font-weight: 700;
}

.brand-logo {
  height: 96px;
  width: auto;
  display: block;
  background: transparent;
}

@media (max-width: 767.98px) {
  .brand-logo { height: 76px; }
}

.auth-panel {
  max-width: 440px;
  margin: 0 auto;
}

.auth-lead {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.nav-link { color: var(--muted) !important; font-weight: 500; }
.nav-link:hover { color: var(--ink) !important; }
.navbar-toggler { border-color: var(--line); }
[data-theme="light"] .navbar-toggler-icon { filter: none; }
[data-theme="dark"] .navbar-toggler-icon { filter: invert(1); }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: 999px;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  line-height: 0;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.theme-icon { display: none; line-height: 0; }
[data-theme="light"] .theme-icon--moon { display: inline-flex; }
[data-theme="dark"] .theme-icon--sun { display: inline-flex; }

.lang-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

.lang-dropdown-toggle::after {
  margin-left: 0.15rem;
}

.lang-dropdown-toggle:hover,
.lang-dropdown-toggle:focus,
.lang-dropdown-toggle.show {
  border-color: var(--accent);
  color: var(--ink);
}

.lang-dropdown-label {
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-dropdown-menu {
  --bs-dropdown-bg: var(--bg-elev);
  --bs-dropdown-color: var(--ink);
  --bs-dropdown-border-color: var(--line);
  --bs-dropdown-link-color: var(--ink);
  --bs-dropdown-link-hover-bg: rgba(255, 140, 0, 0.12);
  --bs-dropdown-link-hover-color: var(--ink);
  --bs-dropdown-link-active-bg: var(--accent);
  --bs-dropdown-link-active-color: #1A0F0C;
  min-width: 12rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
}

.lang-dropdown-menu .dropdown-item {
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.stat-card .label { color: var(--muted); font-size: 0.85rem; }
.stat-card .value {
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  font-weight: 700;
  color: var(--accent-strong);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  margin: 0;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.filters-bar .form-control {
  flex: 1 1 220px;
  min-width: 0;
}

.table-panel, .form-panel, .detail-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
}

.stack-form {
  display: grid;
  gap: 0.85rem;
  max-width: 640px;
  margin: 1rem 0;
}

.stack-form .form-row {
  display: grid;
  gap: 0.35rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.admin-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.barcode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.barcode-row .form-control {
  flex: 1 1 180px;
}

.barcode-reader {
  margin-top: 0.75rem;
  max-width: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.form-control, .form-select {
  background: var(--input-bg);
  color: var(--ink);
  border-color: var(--line);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1A0F0C;
  font-weight: 600;
}

.btn-primary:hover {
  background: #FFB347;
  border-color: #FFB347;
  color: #1A0F0C;
}

.btn-outline-light {
  border-color: var(--line);
  color: var(--ink);
  background: var(--bg-elev);
}

.btn-outline-light:hover {
  background: rgba(255, 140, 0, 0.12);
  border-color: var(--accent);
  color: var(--ink);
}

.btn-outline-danger {
  border-color: color-mix(in srgb, var(--accent-strong) 45%, transparent);
  color: var(--accent-strong);
}

.btn-danger {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.form-panel { max-width: 840px; width: 100%; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

.game-thumb {
  width: 48px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--thumb-bg);
  display: block;
}

.game-thumb-empty { border: 1px dashed var(--line); }

.cover-block {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  align-items: start;
}

.cover-preview-wrap {
  width: 140px;
  aspect-ratio: 400 / 520;
  border-radius: 10px;
  overflow: hidden;
  background: var(--thumb-bg);
  border: 1px solid var(--line);
}

.cover-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-preview.is-empty { opacity: 0.35; }

.image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-height: 2rem;
}

.image-gallery-item {
  position: relative;
  width: 110px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.image-gallery-item:active { cursor: grabbing; }

.image-gallery-item img {
  width: 100%;
  aspect-ratio: 400 / 520;
  object-fit: cover;
  display: block;
  background: var(--thumb-bg);
  pointer-events: none;
}

.image-gallery-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--accent);
  color: #1A0F0C;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
}

.image-gallery-item:not(:first-child) .image-gallery-badge {
  display: none;
}

.image-gallery-actions {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.3rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.cropper-modal-content {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
}

.cropper-stage {
  max-height: min(60vh, 520px);
  background: #111;
  overflow: hidden;
}

.cropper-stage img {
  max-width: 100%;
  display: block;
}

.cropper-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.game-cards { display: grid; gap: 0.85rem; }

.game-card-admin {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.85rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
}

.game-card-admin img {
  width: 72px;
  height: 94px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--thumb-bg);
}

.game-card-admin h2 {
  font-size: 1.05rem;
  margin: 0 0 0.25rem;
}

.game-card-admin .meta,
.game-card-admin .price {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-card-admin .price { color: var(--accent-strong); font-weight: 600; }
.empty-state { color: var(--muted); }

.alert-success {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  color: var(--ink);
}

.alert-danger {
  background: color-mix(in srgb, var(--accent-strong) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent-strong) 40%, transparent);
  color: var(--ink);
}

@media (max-width: 767.98px) {
  .container { padding-left: 1rem; padding-right: 1rem; }
  .cover-block { grid-template-columns: 1fr; }
  .cover-preview-wrap { width: min(160px, 45vw); margin: 0 auto; }
  .page-head .btn { width: 100%; }
  .form-actions .btn { flex: 1 1 auto; }
  .lang-dropdown-toggle { width: 100%; justify-content: space-between; }
  .lang-dropdown-label { max-width: none; }
}
