/* ═══════════════════════════════════════════════════════════
   Review Distributor — assets/style.css
   Mobile-first responsive, dark/light mode via [data-theme]
════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────────── */
:root {
  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Card grid */
  --card-min: 300px;
  --card-max: 380px;

  /* Topbar height */
  --topbar-h: 60px;
  --filterbar-h: 56px;
}

/* ─── Light Theme ───────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f5f6fa;
  --bg-alt:      #ffffff;
  --bg-elevated: #ffffff;
  --border:      #e2e4ea;
  --text-primary:   #1a1c23;
  --text-secondary: #5c6278;
  --text-muted:     #9399b0;
  --accent:      #6366f1;
  --accent-hover:#4f52e0;
  --accent-light: rgba(99,102,241,.10);
  --success:     #22c55e;
  --success-bg:  rgba(34,197,94,.10);
  --warning:     #f59e0b;
  --warning-bg:  rgba(245,158,11,.10);
  --info:        #3b82f6;
  --info-bg:     rgba(59,130,246,.10);
  --danger:      #ef4444;
  --danger-bg:   rgba(239,68,68,.10);
  --skeleton-base:  #e8eaf0;
  --skeleton-shine: #f4f5f9;
  --topbar-bg:   rgba(255,255,255,.85);
  --topbar-border: rgba(226,228,234,.8);
  --filterbar-bg: rgba(245,246,250,.9);
}

/* ─── Dark Theme ────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0f1117;
  --bg-alt:      #181b25;
  --bg-elevated: #1e2130;
  --border:      #2a2e40;
  --text-primary:   #e8eaf0;
  --text-secondary: #9399b0;
  --text-muted:     #5c6278;
  --accent:      #7c7fff;
  --accent-hover:#9698ff;
  --accent-light: rgba(124,127,255,.12);
  --success:     #4ade80;
  --success-bg:  rgba(74,222,128,.10);
  --warning:     #fbbf24;
  --warning-bg:  rgba(251,191,36,.10);
  --info:        #60a5fa;
  --info-bg:     rgba(96,165,250,.10);
  --danger:      #f87171;
  --danger-bg:   rgba(248,113,113,.10);
  --skeleton-base:  #1e2130;
  --skeleton-shine: #262a3a;
  --topbar-bg:   rgba(15,17,23,.85);
  --topbar-border: rgba(42,46,64,.8);
  --filterbar-bg: rgba(15,17,23,.9);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-primary);
  transition: background var(--duration-base) var(--ease),
              color var(--duration-base) var(--ease);
  min-height: 100dvh;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* ─── Container ────────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
@media (min-width: 640px)  { .container { padding: 0 var(--space-6); } }
@media (min-width: 1024px) { .container { padding: 0 var(--space-8); } }

/* ─── Top Bar ───────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--topbar-border);
  transition: background var(--duration-base) var(--ease),
              border-color var(--duration-base) var(--ease);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--space-4);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.topbar__logo { font-size: 1.4rem; line-height: 1; }
.topbar__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
@media (max-width: 479px) { .topbar__title { display: none; } }

.topbar__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
}

/* ─── Counter Badge ─────────────────────────────────────── */
.counter-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--accent-light);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--duration-base) var(--ease);
}
.counter-badge__icon { font-size: .9rem; }
.counter-badge__label { display: none; }
@media (min-width: 640px) { .counter-badge__label { display: inline; } }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,.40);
}
.btn--primary:active { transform: translateY(0); }
.btn--outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--outline:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
}
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent);
}
.btn--sm { padding: 6px 12px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ─── Theme Toggle ──────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--duration-fast) var(--ease);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: rotate(15deg);
}

/* ─── Analytics Panel ───────────────────────────────────── */
.analytics-panel {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--duration-slow) var(--ease),
              opacity var(--duration-base) var(--ease),
              padding var(--duration-slow) var(--ease);
  padding: 0;
}
.analytics-panel.is-open {
  max-height: 200px;
  opacity: 1;
  padding: var(--space-5) 0;
}
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
@media (min-width: 640px) { .analytics-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  text-align: center;
  transition: transform var(--duration-fast) var(--ease);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card--success { border-color: var(--success); }
.stat-card--warning { border-color: var(--warning); }
.stat-card--info    { border-color: var(--info); }

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}
.stat-card--success .stat-card__value { color: var(--success); }
.stat-card--warning .stat-card__value { color: var(--warning); }
.stat-card--info    .stat-card__value { color: var(--info); }

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ─── Filter Bar ────────────────────────────────────────── */
.filter-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  background: var(--filterbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) 0;
  transition: background var(--duration-base) var(--ease);
}
.filter-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
  max-width: 360px;
}
.search-wrap__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Platform pills */
.platform-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}
.platform-filters::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease);
  flex-shrink: 0;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
  padding: var(--space-6) 0 var(--space-12);
  min-height: calc(100dvh - var(--topbar-h) - var(--filterbar-h));
}

/* ─── Cards Grid ────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: var(--space-5);
  padding-top: var(--space-5);
}
@media (max-width: 359px) {
  .cards-grid { grid-template-columns: 1fr; }
}

/* ─── Review Card ───────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease),
              opacity var(--duration-base) var(--ease),
              border-color var(--duration-fast) var(--ease);
  animation: cardIn var(--duration-slow) var(--ease) both;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--accent);
}
.card.is-used {
  opacity: 0;
  transform: scale(.93) translateY(-8px);
  pointer-events: none;
}

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

/* Card header */
.card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.card__avatar-wrap { position: relative; flex-shrink: 0; }
.card__avatar,
.card__avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
}
.card__avatar { display: none; } /* shown by JS when loaded */
.card__avatar-fallback {
  background: linear-gradient(135deg, var(--accent) 0%, var(--info) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: var(--text-base);
}

.card__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.card__name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__platform-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}

/* Card review text */
.card__review {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  flex: 1;
  border-left: 3px solid var(--accent-light);
  padding-left: var(--space-3);
  margin: 0;
  word-break: break-word;
  /* Clamp to 5 lines */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__review.is-expanded { -webkit-line-clamp: unset; }

/* Card photo thumbnail */
.card__photo-preview {
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 160px;
  position: relative;
}
.card__photo-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
  transition: transform var(--duration-base) var(--ease);
}
.card__photo-img:hover { transform: scale(1.03); }

/* Card footer */
.card__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
}
.card__use-btn { flex: 1; justify-content: center; }
.card__use-btn.is-loading {
  pointer-events: none;
  opacity: .7;
}

/* ─── Skeleton Loading ──────────────────────────────────── */
.card--skeleton {
  gap: var(--space-4);
  pointer-events: none;
  animation: none;
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
}
.skeleton--avatar  { width: 44px; height: 44px; border-radius: var(--radius-full); }
.skeleton--line    { height: 13px; }
.skeleton--line-lg { width: 65%; }
.skeleton--line-md { width: 85%; }
.skeleton--line-sm { width: 50%; }
.skeleton--btn     { height: 38px; border-radius: var(--radius-md); margin-top: var(--space-2); }

/* ─── Empty States ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  max-width: 480px;
  margin: 0 auto;
}
.empty-state__icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
  animation: bounce 2s ease infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.empty-state__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.empty-state__text {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  line-height: 1.7;
}

/* ─── Toast Notifications ───────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--space-6) + 70px); /* above undo bar */
  right: var(--space-4);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 320px;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn var(--duration-base) var(--ease) both;
  transition: opacity var(--duration-base) var(--ease),
              transform var(--duration-base) var(--ease);
}
.toast.is-out {
  opacity: 0;
  transform: translateX(20px);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast__icon { font-size: 1.2rem; flex-shrink: 0; }
.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger);  }
.toast--info    { border-left: 3px solid var(--info);    }

/* ─── Undo Bar ──────────────────────────────────────────── */
.undo-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  transform: translateY(100%);
  transition: transform var(--duration-base) var(--ease);
}
.undo-bar.is-visible { transform: translateY(0); }
.undo-bar__msg { font-size: var(--text-sm); color: var(--text-secondary); flex: 1; }
.undo-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
/* 10-second countdown progress ring (tiny bar) */
.undo-bar__progress {
  width: 60px;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.undo-bar__progress::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  animation: progressDrain 10s linear forwards;
}
@keyframes progressDrain {
  from { width: 100%; }
  to   { width: 0%; }
}
.undo-bar__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-1);
  line-height: 1;
  cursor: pointer;
}
.undo-bar__close:hover { color: var(--danger); }

/* ─── Refresh spin animation ────────────────────────────── */
.btn--refreshing svg {
  animation: spin .8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Scrollbar (cosmetic, WebKit only) ─────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Utility ───────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
