/* ===== CSS Variables ===== */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.08);
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #3b82f6;
}

[data-theme="dark"] {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-hover: #1e293b;
  --border: #1e293b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --text-primary: #ffffff;
  --text-secondary: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px;
}

@media (min-width: 768px) {
  main { padding: 32px 24px; }
}

/* ===== Navbar ===== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-brand i { color: var(--accent); }

.navbar-links {
  display: none;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navbar-actions a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.navbar-actions a:hover { color: var(--text-primary); background: var(--surface-hover); }

/* Register/Login side by side */
.nav-guest {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-guest a[href$="login.html"] {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
}

.nav-guest a[href$="login.html"]:hover {
  background: var(--accent-hover);
  color: #fff;
}

.cart-link { position: relative; }

.cart-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.admin-badge {
  background: var(--success);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

/* User dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.user-dropdown-btn:hover { color: var(--text-primary); background: var(--surface-hover); }

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 4px;
  z-index: 200;
}

.user-dropdown-menu.show { display: block; }

.user-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.15s ease;
}

.user-dropdown-menu a:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.user-dropdown-menu .divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Games dropdown in navbar */
.nav-games-dropdown,
.nav-catalog-dropdown {
  position: relative;
}
.nav-games-toggle,
.nav-catalog-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-games-menu,
.nav-catalog-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 200;
  list-style: none;
  margin: 0;
}
.nav-games-dropdown:hover .nav-games-menu,
.nav-games-dropdown.open .nav-games-menu,
.nav-catalog-dropdown:hover .nav-catalog-menu,
.nav-catalog-dropdown.open .nav-catalog-menu {
  display: block;
}
.nav-games-menu li a,
.nav-catalog-menu li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
}
.nav-games-menu li a:hover,
.nav-catalog-menu li a:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Theme toggle button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* User credits display */
.nav-credits {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 6px;
  white-space: nowrap;
}

.nav-credits:empty { display: none; }

/* Hamburger menu */
.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
}

.hamburger:hover { background: var(--surface-hover); }

@media (min-width: 768px) {
  .navbar-links { display: flex; }
  .hamburger { display: none; }
}

/* Mobile slide-out drawer */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.mobile-drawer.open { display: block; }

.mobile-drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
}

.mobile-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.mobile-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  margin-left: auto;
  margin-bottom: 16px;
}

.mobile-drawer-content a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
}

.mobile-drawer-content a:hover { background: var(--surface-hover); color: var(--text-primary); }

.drawer-theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: all 0.15s ease;
}

.drawer-theme-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ===== Footer ===== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 16px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-brand {
  font-weight: 700;
  font-size: 16px;
}

.footer-tagline {
  color: var(--text-secondary);
  font-size: 14px;
}

.footer-copy {
  color: var(--text-secondary);
  font-size: 14px;
}

@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (min-width: 768px) {
  .page-header h1 { font-size: 28px; }
}

.page-header .header-actions {
  margin-left: auto;
}

/* ===== Section titles ===== */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Utility ===== */
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ===== Scrollbar (dark) ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
