/* ═══════════════════════════════════════════════════════════════
   GroupsMix — Shared Design System
   Constitution v3.1 §29-33
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── CSS Custom Properties ─────────────────────────────────── */
:root {
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1200px;

  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16161f;
  --bg-card-hover: #1e1e2d;
  --bg-input: #1a1a28;
  --bg-modal: #16161f;
  --border-primary: #2a2a3e;
  --border-secondary: #3a3a4e;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-tertiary: #6a6a82;
  --text-muted: #505068;
  --accent-primary: #6c5ce7;
  --accent-primary-hover: #5a4bd6;
  --accent-primary-light: rgba(108, 92, 231, 0.15);
  --accent-secondary: #00cec9;
  --accent-gold: #ffd700;
  --accent-diamond: #b9f2ff;
  --success: #00b894;
  --success-light: rgba(0, 184, 148, 0.15);
  --warning: #fdcb6e;
  --warning-light: rgba(253, 203, 110, 0.15);
  --error: #e17055;
  --error-light: rgba(225, 112, 85, 0.15);
  --info: #74b9ff;
  --info-light: rgba(116, 185, 255, 0.15);
  --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: 0 0 20px rgba(108, 92, 231, 0.3);
}

[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f6;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f6fa;
  --bg-input: #f0f1f6;
  --bg-modal: #ffffff;
  --border-primary: #e0e2ea;
  --border-secondary: #d0d2da;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a62;
  --text-tertiary: #7a7a92;
  --text-muted: #9a9ab2;
  --accent-primary: #6c5ce7;
  --accent-primary-hover: #5a4bd6;
  --accent-primary-light: rgba(108, 92, 231, 0.1);
  --accent-secondary: #00b5ad;
  --accent-gold: #f0c800;
  --accent-diamond: #7ee8fa;
  --success: #00a884;
  --success-light: rgba(0, 168, 132, 0.1);
  --warning: #e8b500;
  --warning-light: rgba(232, 181, 0, 0.1);
  --error: #d63031;
  --error-light: rgba(214, 48, 49, 0.1);
  --info: #0984e3;
  --info-light: rgba(9, 132, 227, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.15);
}

/* ─── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 10001;
  padding: var(--space-2) var(--space-4);
  background: var(--accent-primary);
  color: #fff;
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: var(--space-4);
}

/* ─── Layout ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 20px;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-primary-hover); }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-secondary); background: var(--bg-card-hover); }
.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--accent-primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--text-sm); }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: var(--text-lg); }
.btn-icon { width: 44px; min-height: 44px; padding: 0; }
.btn-full { width: 100%; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card:hover { background: var(--bg-card-hover); box-shadow: var(--shadow-md); border-color: var(--border-secondary); }
.card--clickable { cursor: pointer; }
.card--clickable:hover { transform: translateY(-2px); }
.card__header { padding: var(--space-4); border-bottom: 1px solid var(--border-primary); }
.card__body { padding: var(--space-4); }
.card__footer { padding: var(--space-4); border-top: 1px solid var(--border-primary); }

.group-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); }
.group-card__platform { font-size: var(--text-sm); color: var(--text-secondary); }
.group-card__name { font-size: var(--text-lg); font-weight: var(--font-semibold); margin: 0 0 var(--space-2); line-height: 1.3; }
.group-card__description { font-size: var(--text-sm); color: var(--text-secondary); margin: 0 0 var(--space-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.group-card__meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-bottom: var(--space-2); }
.group-card__stats { display: flex; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-3); }
.group-card__footer { display: flex; gap: var(--space-2); align-items: center; }
.vip-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--font-semibold); }
.vip-badge--verified { background: var(--success-light); color: var(--success); }
.vip-badge--niche { background: var(--info-light); color: var(--info); }
.vip-badge--global { background: var(--warning-light); color: var(--accent-gold); }
.vip-badge--diamond { background: rgba(185, 242, 255, 0.2); color: var(--accent-diamond); }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  color: var(--text-primary);
}
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}
.form-input--error { border-color: var(--error); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-error-text { color: var(--error); font-size: var(--text-sm); margin-top: var(--space-1); }
.form-help { color: var(--text-tertiary); font-size: var(--text-sm); margin-top: var(--space-1); }
.form-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* ─── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 420px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--info);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--error); }
.toast--warning { border-left-color: var(--warning); }
.toast--info { border-left-color: var(--info); }
.toast__content { flex: 1; }
.toast__title { font-weight: var(--font-semibold); font-size: var(--text-sm); }
.toast__message { font-size: var(--text-sm); color: var(--text-secondary); }

/* ─── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); background: rgba(0,0,0,0.6); animation: fadeIn 0.2s ease;
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg-modal); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
}
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border-primary); }
.modal__title { font-size: var(--text-xl); font-weight: var(--font-bold); margin: 0; }
.modal__body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-primary); }
.auth-modal-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.auth-tab.is-active { background: var(--accent-primary-light); color: var(--accent-primary); }
.auth-pane.is-hidden { display: none !important; }

/* ─── Skeleton ───────────────────────────────────────────────── */
.skeleton {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.5s infinite;
}
.skeleton-text { height: 16px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-title { height: 24px; width: 60%; border-radius: 4px; }
.skeleton-card { height: 280px; border-radius: var(--radius-lg); }
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ─── Empty & Error states ───────────────────────────────────── */
.empty-state,
.error-state {
  text-align: center;
  padding: var(--space-16) var(--space-4);
}
.empty-state__icon,
.error-state__icon { font-size: var(--text-4xl); margin-bottom: var(--space-4); }
.empty-state__title,
.error-state__title { font-size: var(--text-xl); font-weight: var(--font-semibold); margin-bottom: var(--space-2); }
.empty-state__text,
.error-state__text { color: var(--text-secondary); margin-bottom: var(--space-6); max-width: 400px; margin-left: auto; margin-right: auto; }

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
}
.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--text-primary);
  text-decoration: none;
}
.site-header__link {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: color 0.2s ease, background 0.2s ease;
}
.site-header__link:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.site-header__nav { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.site-header__user { display: inline-flex; align-items: center; gap: var(--space-2); position: relative; }
.site-header__gxp { font-size: var(--text-xs); color: var(--text-tertiary); }
.site-header__level { font-size: var(--text-xs); color: var(--accent-primary); font-weight: var(--font-semibold); }
.site-header__dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 4px; min-width: 180px; padding: var(--space-2);
  background: var(--bg-card); border: 1px solid var(--border-primary); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px; z-index: 1001;
}
.site-header__dropdown a, .site-header__dropdown button {
  padding: var(--space-2) var(--space-3); text-align: left; border: none; background: none; color: var(--text-primary);
  font-size: var(--text-sm); cursor: pointer; border-radius: var(--radius-sm); font-family: inherit;
}
.site-header__dropdown a:hover, .site-header__dropdown button:hover { background: var(--bg-tertiary); }

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  padding: var(--space-12) 0 var(--space-6);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-primary);
}
.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}
.site-footer__title { font-size: var(--text-sm); font-weight: var(--font-semibold); margin-bottom: var(--space-3); }
.site-footer__links { display: flex; flex-direction: column; gap: var(--space-2); }
.site-footer__link { color: var(--text-secondary); text-decoration: none; font-size: var(--text-sm); }
.site-footer__link:hover { color: var(--text-primary); }
.site-footer__copy { font-size: var(--text-sm); color: var(--text-tertiary); text-align: center; }

/* ─── Dashboard layout ───────────────────────────────────────── */
.dashboard {
  display: flex;
  min-height: calc(100vh - 60px);
}
.dashboard__sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  padding: var(--space-4) 0;
}
.dashboard__nav { display: flex; flex-direction: column; gap: 2px; }
.dashboard__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-left: 3px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.dashboard__nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.dashboard__nav-item--active { background: var(--accent-primary-light); color: var(--accent-primary); border-left-color: var(--accent-primary); }
.dashboard__main { flex: 1; padding: var(--space-6); overflow-x: hidden; }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 767px) {
  .site-header { min-height: 56px; }
  .site-footer__grid { grid-template-columns: 1fr; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
}

@media (max-width: 639px) {
  .dashboard__sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-primary); }
  .dashboard { flex-direction: column; }
}
