/**
 * GameHub - Global Styles
 * File CSS utama yang berisi reset, variabel, typography, dan utility classes.
 */

/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  /* Colors */
  --bg-primary: #0D0D0D;
  --bg-surface: #171717;
  --bg-card: #1E1E1E;
  --bg-card-hover: #252525;
  --bg-elevated: #2A2A2A;
  --bg-glass: rgba(30, 30, 30, 0.7);

  /* Brand Colors */
  --primary: #4F8CFF;
  --primary-hover: #6B9FFF;
  --primary-light: rgba(79, 140, 255, 0.15);
  --success: #37D67A;
  --success-light: rgba(55, 214, 122, 0.15);
  --danger: #FF4B55;
  --danger-light: rgba(255, 75, 85, 0.15);
  --warning: #FFB800;

  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #B8B8B8;
  --text-tertiary: #888888;
  --text-disabled: #555555;

  /* Border */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(79, 140, 255, 0.5);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(79, 140, 255, 0.15);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Z-index */
  --z-navbar: 100;
  --z-bottom-nav: 100;
  --z-modal: 200;
  --z-toast: 300;
  --z-overlay: 150;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-disabled);
}

/* ===== Selection ===== */
::selection {
  background: var(--primary-light);
  color: var(--text-primary);
}

/* ===== Focus Visible ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }
h4 { font-size: clamp(1rem, 1.5vw, 1.25rem); }

p {
  color: var(--text-secondary);
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page {
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.section {
  padding: var(--space-lg) 0;
}

.section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding: 0 var(--space-md);
}

.section__title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section__title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.section__link {
  font-size: 0.875rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.section__link svg {
  width: 16px;
  height: 16px;
}

/* ===== Grid ===== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
  padding: 0 var(--space-md);
}

.games-grid--horizontal {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 var(--space-md);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.games-grid--horizontal::-webkit-scrollbar {
  display: none;
}

.games-grid--horizontal .game-card {
  flex-shrink: 0;
  width: 160px;
  scroll-snap-align: start;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), #6B5CE7);
  color: #fff;
  box-shadow: 0 4px 15px rgba(79, 140, 255, 0.3);
}

.btn--primary:hover {
  box-shadow: 0 6px 20px rgba(79, 140, 255, 0.4);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn--secondary:hover {
  background: var(--bg-card-hover);
}

.btn--success {
  background: linear-gradient(135deg, var(--success), #2DBF6A);
  color: #fff;
  box-shadow: 0 4px 15px rgba(55, 214, 122, 0.3);
}

.btn--danger {
  background: linear-gradient(135deg, var(--danger), #E8434A);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn--icon {
  padding: 10px;
  border-radius: var(--radius-md);
}

.btn--large {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn--small {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Ripple Effect ===== */
.ripple-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: rippleEffect 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleEffect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== Glass Effect ===== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes fadeInScale {
  from { 
    opacity: 0; 
    transform: scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: scale(1); 
  }
}

@keyframes slideInLeft {
  from { 
    opacity: 0; 
    transform: translateX(-20px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

@keyframes slideInRight {
  from { 
    opacity: 0; 
    transform: translateX(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp var(--transition-base) forwards;
}

.animate-fade-in-scale {
  animation: fadeInScale var(--transition-base) forwards;
}

.animate-slide-left {
  animation: slideInLeft var(--transition-base) forwards;
}

.animate-slide-right {
  animation: slideInRight var(--transition-base) forwards;
}

/* Stagger animation delays */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
  margin-bottom: 0;
}

.skeleton-image {
  border-radius: var(--radius-md);
}

.skeleton-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-banner {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
}

/* ===== Star Rating ===== */
.star {
  width: 14px;
  height: 14px;
}

.star-full {
  color: #FFD700;
}

.star-half {
  color: #FFD700;
}

.star-empty {
  color: #4A4A4A;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-disabled);
  margin-bottom: var(--space-md);
}

.empty-state__title {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state__message {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* ===== Error State ===== */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
}

.error-state__icon {
  width: 64px;
  height: 64px;
  color: var(--text-disabled);
  margin-bottom: var(--space-md);
}

.error-state__title {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.error-state__submessage {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

.btn--retry {
  gap: var(--space-sm);
}

.btn--retry svg {
  width: 18px;
  height: 18px;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 13, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: 10;
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: inherit;
}

.loading-overlay.active {
  opacity: 1;
}

.loading-overlay__text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== Spinner ===== */
.spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spinner svg {
  width: 100%;
  height: 100%;
}

/* ===== Visually Hidden ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Print Styles ===== */
@media print {
  .bottom-nav,
  .header,
  .btn {
    display: none !important;
  }
}
