/* SportsFun HK — Design System */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700;900&family=Inter:wght@400;500;600;700&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary: #01696f;
  --primary-dark: #015358;
  --primary-light: #02888f;
  --primary-glow: rgba(1,105,111,0.18);
  --accent: #f97316;
  --accent-light: #fde68a;
  --gold: #f59e0b;
  --silver: #94a3b8;
  --bronze: #cd7c40;

  --bg: #f8fafb;
  --surface: #ffffff;
  --surface-2: #f1f5f7;
  --border: #e2e8f0;
  --border-light: #f0f4f7;

  --text-1: #0f1923;
  --text-2: #374151;
  --text-3: #6b7280;
  --text-4: #9ca3af;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.06);
  --shadow-primary: 0 4px 20px rgba(1,105,111,.25);

  --nav-h: 64px;
  --bottom-nav-h: 70px;
  --sidebar-w: 240px;

  --transition: 0.2s cubic-bezier(.4,0,.2,1);
  --transition-slow: 0.35s cubic-bezier(.4,0,.2,1);

  --font-sans: 'Noto Sans TC', 'Inter', system-ui, sans-serif;
  --font-num: 'Inter', sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1e2530;
  --border: #2d3748;
  --border-light: #252d3a;
  --text-1: #f0f6fc;
  --text-2: #c9d1d9;
  --text-3: #8b949e;
  --text-4: #58647a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  --primary-glow: rgba(1,155,163,0.2);
}

/* ─── Reset ──────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font-family: inherit; }

/* ─── Typography ─────────────────────────────────────────────── */
h1 { font-size: clamp(1.5rem,4vw,2.25rem); font-weight: 900; line-height: 1.2; }
h2 { font-size: clamp(1.2rem,3vw,1.75rem); font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
.font-num { font-family: var(--font-num); }

/* ─── Layout ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100dvh; }
.main-content { flex: 1; overflow-x: hidden; }
.page { padding: 24px 16px; max-width: 900px; margin: 0 auto; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 1.5rem; font-weight: 800; color: var(--text-1); }
.page-subtitle { color: var(--text-3); margin-top: 4px; font-size: .9rem; }

/* Desktop layout */
@media (min-width: 768px) {
  .main-content { margin-left: var(--sidebar-w); padding-top: var(--nav-h); }
  .page { padding: 32px 28px; }
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-weight: 700; font-size: .95rem; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; min-height: 44px; padding: 10px 20px;
  border-radius: var(--radius); font-weight: 600; font-size: .9rem;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0); transition: background var(--transition);
}
.btn:hover::after { background: rgba(255,255,255,.1); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { color: var(--primary); }
.btn-ghost:hover { background: var(--primary-glow); }
.btn-danger { background: var(--error); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius); }

/* ─── Form Controls ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text-1);
  font-size: .95rem; transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .78rem; color: var(--text-3); }
.form-error { font-size: .78rem; color: var(--error); }
.range-input { width: 100%; accent-color: var(--primary); }

/* ─── Badges / Tags ──────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: .75rem; font-weight: 600;
}
.tag-primary { background: var(--primary-glow); color: var(--primary); }
.tag-gold { background: #fef3c7; color: #92400e; }
.tag-silver { background: #f1f5f9; color: #475569; }
.tag-bronze { background: #fef3e2; color: #92400e; }
.tag-success { background: var(--success-bg); color: #065f46; }
.tag-warning { background: var(--warning-bg); color: #92400e; }
.tag-error { background: var(--error-bg); color: #991b1b; }
.tag-info { background: var(--info-bg); color: #1e40af; }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  height: 10px; background: var(--surface-2);
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* XP bar variant */
.xp-bar { height: 8px; }
.xp-fill { background: linear-gradient(90deg, var(--accent), #fbbf24); }

/* ─── Skeleton Loading ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-light) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skel 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-icon { font-size: 3rem; opacity: .6; }
.empty-title { font-weight: 700; font-size: 1.1rem; color: var(--text-2); }
.empty-desc { color: var(--text-3); font-size: .9rem; max-width: 280px; }

/* ─── Avatar ──────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1.25rem;
  background: var(--primary-glow); border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar-sm { width: 36px; height: 36px; font-size: 1rem; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 72px; height: 72px; font-size: 2rem; }

/* ─── Stats Card ──────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 900; font-family: var(--font-num); color: var(--primary); }
.stat-label { font-size: .78rem; color: var(--text-3); font-weight: 500; margin-top: 4px; }

/* ─── Badge Display ───────────────────────────────────────────── */
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 12px 8px; border-radius: var(--radius);
  border: 1.5px solid var(--border); background: var(--surface);
  transition: all var(--transition);
}
.badge-item.earned { border-color: var(--gold); background: #fffbeb; }
[data-theme="dark"] .badge-item.earned { background: rgba(245,158,11,.08); }
.badge-item.locked { opacity: .45; filter: grayscale(1); }
.badge-emoji { font-size: 1.8rem; }
.badge-name { font-size: .7rem; font-weight: 600; text-align: center; color: var(--text-2); }

/* ─── Leaderboard ─────────────────────────────────────────────── */
.leaderboard-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  transition: background var(--transition);
}
.leaderboard-item:hover { background: var(--surface-2); }
.leaderboard-item.current-user { background: var(--primary-glow); }
.rank-badge {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem; flex-shrink: 0;
}
.rank-1 { background: var(--gold); color: #fff; font-size: 1rem; }
.rank-2 { background: var(--silver); color: #fff; }
.rank-3 { background: var(--bronze); color: #fff; }
.rank-other { background: var(--surface-2); color: var(--text-3); }

/* ─── Calendar ────────────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  aspect-ratio: 1; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text-3);
  transition: transform var(--transition);
  position: relative;
}
.cal-day:hover { transform: scale(1.1); z-index: 1; }
.cal-day.has-data { color: var(--text-1); }
.cal-day.level-0 { background: var(--surface-2); }
.cal-day.level-1 { background: #fecaca; color: #991b1b; }  /* <30m */
.cal-day.level-2 { background: #fde68a; color: #92400e; }  /* 30-59m */
.cal-day.level-3 { background: #bbf7d0; color: #065f46; }  /* ≥60m */
.cal-day.today { outline: 2px solid var(--primary); }

/* ─── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-lg);
  font-weight: 600; font-size: .9rem;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg); min-width: 250px; max-width: 360px;
  animation: toast-in .3s ease-out;
  pointer-events: auto;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--error); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }
.toast-badge { background: linear-gradient(135deg, var(--gold), var(--accent)); color: #fff; }
@keyframes toast-in { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateX(110%); opacity: 0; } }

/* ─── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 28px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s cubic-bezier(.4,0,.2,1);
  max-height: 90dvh; overflow-y: auto;
}
.modal-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { transform: scale(.94) translateY(8px); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ─── Table ───────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
  text-align: left; padding: 10px 14px; font-size: .75rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); border-bottom: 2px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); color: var(--text-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

/* ─── Chip / Filter ───────────────────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: .82rem; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--text-2);
  background: var(--surface); cursor: pointer; transition: all var(--transition);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

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

/* ─── Grid Utils ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ─── Flex Utils ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ─── Spacing ─────────────────────────────────────────────────── */
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* ─── Text Utils ──────────────────────────────────────────────── */
.text-sm { font-size: .85rem; } .text-xs { font-size: .75rem; }
.text-muted { color: var(--text-3); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; }

/* ─── Chart Bar ───────────────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 100px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px;
  transition: height 0.5s cubic-bezier(.4,0,.2,1); }
.bar-label { font-size: .68rem; color: var(--text-3); font-weight: 600; }
.bar-value { font-size: .65rem; color: var(--text-3); }
.bar-0 { background: var(--surface-2); }
.bar-1 { background: #fca5a5; }
.bar-2 { background: #fde68a; }
.bar-3 { background: linear-gradient(180deg, var(--primary-light), var(--primary)); }

/* ─── Streak Display ──────────────────────────────────────────── */
.streak-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #ff6b35, #f97316);
  color: #fff; padding: 6px 14px; border-radius: var(--radius-full);
  font-weight: 800; font-size: 1rem;
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ─── Print ───────────────────────────────────────────────────── */
@media print { .no-print { display: none !important; } }
