/* ============================================
   SharqMovie Design System v2.0
   Dark Mode UI Tokens — brand refresh
   ============================================ */

:root {
  /* ===== Color Tokens ===== */
  --color-primary-main: #FFD700;
  --color-primary-hover: #E6C200;
  --color-primary-active: #CCAD00;
  --color-accent-red: #E50914;
  --color-accent-green: #10B981;

  --color-bg-app: #0C0E12;
  --color-bg-surface-primary: #14171F;
  --color-bg-surface-secondary: #1E222D;
  --color-bg-overlay: rgba(12, 14, 18, 0.8);

  --color-text-primary: #FFFFFF;
  --color-text-secondary: #9CA3AF;
  --color-text-muted: #6B7280;
  --color-text-inverse: #0C0E12;

  /* Backward-compatible aliases */
  --color-primary: var(--color-primary-main);
  --color-primary-soft: rgba(255, 215, 0, 0.08);
  --color-primary-dim: rgba(255, 215, 0, 0.15);
  --color-primary-glow: rgba(255, 215, 0, 0.3);

  --color-bg: var(--color-bg-app);
  --color-bg-2: var(--color-bg-surface-primary);
  --color-surface: var(--color-bg-surface-primary);
  --color-surface-2: var(--color-bg-surface-secondary);
  --color-surface-3: #2A2E3A;

  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.15);

  --color-text: var(--color-text-primary);
  --color-text-2: var(--color-text-secondary);
  --color-text-dim: #50506a;

  --color-success: var(--color-accent-green);
  --color-success-dim: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-warning-dim: rgba(245, 158, 11, 0.12);
  --color-error: #ef4444;
  --color-error-dim: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;
  --color-info-dim: rgba(59, 130, 246, 0.12);
  --color-gold: var(--color-primary-main);

  /* ===== Typography Tokens ===== */
  --font-family-base: "Inter", "Roboto", sans-serif;
  --font-family: var(--font-family-base);

  --font-heading-xl: 32px;
  --font-heading-xl-lh: 40px;
  --font-heading-xl-fw: 700;

  --font-heading-lg: 24px;
  --font-heading-lg-lh: 32px;
  --font-heading-lg-fw: 600;

  --font-heading-md: 18px;
  --font-heading-md-lh: 24px;
  --font-heading-md-fw: 600;

  --font-body-md: 15px;
  --font-body-md-lh: 22px;
  --font-body-md-fw: 400;

  --font-body-sm: 13px;
  --font-body-sm-lh: 18px;
  --font-body-sm-fw: 400;

  --font-caption: 11px;
  --font-caption-lh: 14px;
  --font-caption-fw: 500;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;
  --weight-black: 900;

  --leading-tight: 1.15;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* ===== Spacing & Layout Tokens ===== */
  --spacing-2xs: 4px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Backward-compatible aliases */
  --space-1: var(--spacing-2xs);
  --space-2: var(--spacing-xs);
  --space-3: var(--spacing-sm);
  --space-4: var(--spacing-md);
  --space-5: 20px;
  --space-6: var(--spacing-lg);
  --space-8: var(--spacing-xl);
  --space-12: var(--spacing-2xl);
  --space-16: 64px;
  --space-20: 80px;

  --pad-container: clamp(16px, 4vw, 32px);
  --pad-section: clamp(60px, 10vw, 120px);

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

  /* ===== Shadows & Effects ===== */
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-glow-yellow: 0 0 16px rgba(255, 215, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-primary: 0 4px 20px rgba(255, 215, 0, 0.3);
  --shadow-glow-primary-strong: 0 8px 32px rgba(255, 215, 0, 0.45);

  --blur-backdrop: blur(12px);

  /* ===== Z-Index ===== */
  --z-base: 1;
  --z-dropdown: 50;
  --z-header: 100;
  --z-tab-bar: 100;
  --z-modal: 200;
  --z-toast: 300;
  --z-loader: 999;

  /* ===== Animation ===== */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.18, 0.89, 0.32, 1.28);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: var(--leading-normal);
}

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

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

button {
  cursor: pointer;
  font-family: var(--font-family);
}

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

:focus:not(:focus-visible) {
  outline: none;
}

/* ===== Skip Link (add to each page) ===== */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: white;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: 10000;
  font-weight: var(--weight-bold);
  font-size: 0.9rem;
  transition: top 0.2s;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
  outline: none;
  box-shadow: var(--shadow-glow-primary);
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

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

/* ===== Component Standards ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-primary-strong);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-hover);
  transform: translateY(-1px);
}

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

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}

.btn-danger:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}

.btn-success:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-sm {
  min-height: 36px;
  padding: 0.5rem 0.875rem;
  font-size: var(--text-sm);
}

.btn-lg {
  min-height: 52px;
  padding: 0.875rem 1.75rem;
  font-size: var(--text-lg);
}

.btn-icon {
  padding: 0.5rem;
  aspect-ratio: 1;
  min-height: auto;
}

.btn-full {
  width: 100%;
}

.input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  line-height: var(--leading-normal);
}

.input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}

.input--error,
select.input--error,
textarea.input--error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px var(--color-error-dim);
}

.input--success,
select.input--success,
textarea.input--success {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-dim);
}

.helper-text,
.input-error {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.input-error {
  color: var(--color-error);
  display: none;
}

.input-error.is-visible {
  display: block;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card--elevated {
  box-shadow: var(--shadow-md);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
}

.modal {
  position: fixed;
  inset: auto 0 0 0;
  z-index: calc(var(--z-modal) + 1);
  background: var(--color-surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  max-height: min(90vh, 56rem);
  overflow: auto;
}

@media (min-width: 768px) {
  .modal {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 2rem));
    border-radius: var(--radius-xl);
  }
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.table th,
.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.table th {
  color: var(--color-text-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
