/* =============================================================
   Custom styles — loaded alongside TailwindCSS
   ============================================================= */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg-base:      #0d0d1a;
  --bg-surface:   #16162a;
  --bg-hover:     #1e1e38;
  --accent:       #7c3aed;
  --accent-light: #9d5cf6;
  --accent-2:     #06b6d4;
  --border:       rgba(255,255,255,0.07);
  --text-primary: #e2e8f0;
  --text-muted:   #94a3b8;
  --radius:       0.75rem;
  --sidebar-w:    220px;
  --topbar-h:     60px;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ─────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(13,13,26,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  padding: 0 1.25rem;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar-logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 500px;
  margin: 0 auto;
}

.topbar-search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.45rem 1rem 0.45rem 2.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.topbar-search-input:focus {
  border-color: var(--accent);
}

.topbar-search-input::placeholder { color: var(--text-muted); }

.topbar-actions { margin-left: auto; flex-shrink: 0; }

.btn-login {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-login:hover { background: var(--accent-light); }

/* Mobile sidebar toggle button */
.sidebar-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.25rem;
}

/* ── Page Shell ─────────────────────────────────────────────── */
.page-shell {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform 0.25s ease;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-nav { padding: 0.75rem 0.5rem 2rem; }

.sidebar-section { display: flex; flex-direction: column; gap: 2px; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0.5rem;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.75rem 0.4rem;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(124, 58, 237, 0.2);
  color: #a78bfa;
  font-weight: 600;
}

.sidebar-icon { font-size: 1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.5rem 3rem;
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 49;
}

/* ── Hero Banner ────────────────────────────────────────────── */
.hero-banner {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/6;
  max-height: 300px;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #1a0533 0%, #0d1a33 100%);
  border: 1px solid var(--border);
}

.hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.hero-banner-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem 2rem;
  background: linear-gradient(to top, rgba(13,13,26,0.9) 0%, transparent 60%);
}

.hero-banner-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
}

.hero-banner-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.hero-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: white;
  padding: 0.55rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.15s;
  align-self: flex-start;
}

.hero-banner-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* ── Tag Pills ──────────────────────────────────────────────── */
.tag-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.tag-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(124,58,237,0.5);
}

/* ── Sections ───────────────────────────────────────────────── */
.section-row { margin-bottom: 2rem; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.section-more {
  font-size: 0.8rem;
  color: var(--accent-light);
  transition: color 0.15s;
}
.section-more:hover { color: var(--accent-2); }

/* ── Games Grid ─────────────────────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.875rem;
}

/* ── Game Card ──────────────────────────────────────────────── */
.game-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(124,58,237,0.25);
  border-color: rgba(124,58,237,0.5);
}

.game-card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #0d0d20;
}

.game-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.game-card:hover .game-card-thumb img {
  transform: scale(1.05);
}

.game-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.game-card:hover .game-card-overlay { opacity: 1; }

.game-card-info {
  padding: 0.5rem 0.625rem 0.625rem;
}

.game-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.stars { color: #f59e0b; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  line-height: 1.4;
}

.badge-original { background: #7c3aed; color: white; }
.badge-new      { background: #059669; color: white; }
.badge-hot      { background: #dc2626; color: white; }

/* ── Game Play Page ─────────────────────────────────────────── */
.game-player-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16/9;
  max-height: 520px;
}

.game-player-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.game-player-wrap .placeholder-play {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a0533, #0d1a33);
  gap: 1rem;
  cursor: pointer;
}

.game-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.game-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.game-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.fullscreen-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.fullscreen-btn:hover { background: var(--accent-light); }

/* ── Category Header ────────────────────────────────────────── */
.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.category-icon { font-size: 2rem; }

.category-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
}

.category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}

/* ── Search Results ─────────────────────────────────────────── */
.search-header {
  margin-bottom: 1.5rem;
}

.search-query {
  font-size: 1.25rem;
  font-weight: 700;
}

.search-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.15s;
}

.page-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    width: 220px;
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-overlay { display: block; }

  .main-content {
    margin-left: 0;
    padding: 1rem 0.875rem 3rem;
  }

  .sidebar-toggle-btn { display: flex; }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .hero-banner { aspect-ratio: 16/7; max-height: 200px; }
  .hero-banner-title { font-size: 1.2rem; }
  .topbar-logo-text { display: none; }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }
}
