/* ============================================================
   FAMILLY DART — Global CSS
   Design System: tokens, reset, typography, utilities
   ============================================================ */

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

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Colors */
  --bg-primary:     #090909;
  --bg-secondary:   #141414;
  --bg-card:        #1a1a1a;
  --bg-elevated:    #202020;
  --accent:         #FF3131;
  --accent-hover:   #FF4545;
  --accent-dim:     rgba(255, 49, 49, 0.15);
  --accent-glow:    rgba(255, 49, 49, 0.3);
  --text-primary:   #FFFFFF;
  --text-secondary: #B5B5B5;
  --text-muted:     #6B6B6B;
  --border:         #2A2A2A;
  --border-light:   #333333;
  --success:        #22C55E;
  --success-dim:    rgba(34, 197, 94, 0.15);
  --danger:         #EF4444;
  --danger-dim:     rgba(239, 68, 68, 0.15);
  --warning:        #F59E0B;
  --warning-dim:    rgba(245, 158, 11, 0.15);
  --gold:           #FFD700;
  --silver:         #C0C0C0;
  --bronze:         #CD7F32;

  /* Glassmorphism */
  --glass-bg:       rgba(255, 255, 255, 0.04);
  --glass-border:   rgba(255, 255, 255, 0.08);
  --glass-blur:     12px;

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

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

  /* Typography */
  --font:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs:    12px;
  --text-sm:    14px;
  --text-base:  16px;
  --text-lg:    18px;
  --text-xl:    20px;
  --text-2xl:   24px;
  --text-3xl:   32px;
  --text-4xl:   40px;
  --text-5xl:   56px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 20px var(--accent-glow);

  /* Transitions */
  --transition: 200ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --nav-height: 72px;
  --header-height: 64px;
  --max-width: 480px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  position: relative;
}

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

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}

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

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

img, svg {
  display: block;
}

ul, ol {
  list-style: none;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: var(--text-3xl); font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; }
h2 { font-size: var(--text-2xl); font-weight: 700; line-height: 1.2; }
h3 { font-size: var(--text-xl);  font-weight: 600; line-height: 1.3; }
h4 { font-size: var(--text-lg);  font-weight: 600; }
h5 { font-size: var(--text-base); font-weight: 600; }

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }

.font-light   { font-weight: 300; }
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semi    { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extra   { font-weight: 800; }
.font-black   { font-weight: 900; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

/* ── Layout Utilities ─────────────────────────────────────── */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
}

.page-with-nav {
  padding-bottom: calc(var(--nav-height) + 16px);
}

.page-content {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-start { display: flex; align-items: center; justify-content: flex-start; }
.gap-xs     { gap: var(--space-xs); }
.gap-sm     { gap: var(--space-sm); }
.gap-md     { gap: var(--space-md); }
.gap-lg     { gap: var(--space-lg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-sm); }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: var(--space-sm); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.flex-1  { flex: 1; }

.mt-xs  { margin-top: var(--space-xs); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
}

.card-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.card-accent {
  background: var(--accent-dim);
  border: 1px solid rgba(255, 49, 49, 0.3);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 16px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  min-height: 56px;
  user-select: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:active::after {
  opacity: 0.08;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 28px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

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

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 10px 16px;
  font-size: var(--text-sm);
  min-height: 40px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 20px 32px;
  font-size: var(--text-lg);
  min-height: 64px;
  border-radius: var(--radius-lg);
  font-weight: 700;
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius);
  min-height: unset;
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-accent  { background: var(--accent-dim); color: var(--accent); }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim); color: var(--danger); }
.badge-muted   { background: var(--bg-elevated); color: var(--text-secondary); }
.badge-gold    { background: rgba(255, 215, 0, 0.15); color: var(--gold); }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-lg);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.avatar-sm { width: 36px; height: 36px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-2xl); border-radius: var(--radius-lg); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-3xl); border-radius: var(--radius-xl); }

/* ── Section Header ───────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.section-action {
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header-title {
  font-size: var(--text-xl);
  font-weight: 700;
  flex: 1;
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
}

/* ── Bottom Navigation ────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding: 0 var(--space-sm);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  flex: 1;
  text-decoration: none;
  min-height: 56px;
  justify-content: center;
}

.nav-item:hover {
  color: var(--text-secondary);
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active .nav-icon svg path,
.nav-item.active .nav-icon svg rect,
.nav-item.active .nav-icon svg circle {
  fill: var(--accent);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── FAB ──────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--accent-glow);
  z-index: 150;
  transition: all var(--transition);
  font-size: 28px;
  line-height: 1;
}

.fab:hover {
  background: var(--accent-hover);
  transform: scale(1.08);
  box-shadow: 0 6px 32px var(--accent-glow);
}

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

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-lg);
  width: 100%;
  max-width: var(--max-width);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--transition-slow) cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
}

.modal-backdrop.open .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-lg);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  text-align: center;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px var(--space-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  pointer-events: auto;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}

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

.empty-state-icon {
  font-size: 64px;
  line-height: 1;
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 240px;
}

/* ── Pill Tabs ────────────────────────────────────────────── */
.pill-tabs {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.pill-tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  border: none;
  background: none;
}

.pill-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Toggle ───────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.toggle-info {
  flex: 1;
}

.toggle-label {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
  margin-left: var(--space-md);
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(24px) translateY(-50%);
  background: var(--accent);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

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

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

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

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.04); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

@keyframes bust {
  0%   { background: var(--bg-card); }
  25%  { background: var(--danger-dim); }
  100% { background: var(--bg-card); }
}

@keyframes confettiFloat {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

.animate-fade-in       { animation: fadeIn 0.4s ease forwards; }
.animate-fade-in-up    { animation: fadeInUp 0.4s ease forwards; }
.animate-fade-in-down  { animation: fadeInDown 0.4s ease forwards; }
.animate-scale-in      { animation: scaleIn 0.3s ease forwards; }
.animate-slide-right   { animation: slideInRight 0.3s ease forwards; }

/* Staggered children animations */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; }
.stagger > *:nth-child(8) { animation-delay: 420ms; }

/* ── Gradient Backgrounds ─────────────────────────────────── */
.gradient-accent {
  background: linear-gradient(135deg, #FF3131 0%, #FF6B6B 100%);
}

.gradient-dark {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 480px) {
  .page { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .bottom-nav { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ── Selection color ──────────────────────────────────────── */
::selection {
  background: var(--accent-dim);
  color: var(--accent);
}
