/* ===== AYGCT Health Platform — Design System ===== */
/* Style: Accessible & Ethical | WCAG AAA */
/* Typography: Figtree / Noto Sans */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  /* Colors */
  --color-primary: #0891B2;
  --color-primary-dark: #0E7490;
  --color-primary-light: #22D3EE;
  --color-primary-subtle: #ECFEFF;
  --color-cta: #059669;
  --color-cta-dark: #047857;
  --color-cta-light: #D1FAE5;
  --color-danger: #DC2626;
  --color-danger-light: #FEE2E2;
  --color-warning: #D97706;
  --color-warning-light: #FEF3C7;
  --color-text: #164E63;
  --color-text-secondary: #475569;
  --color-text-muted: #64748B;
  --color-bg: #F0FDFA;
  --color-bg-white: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;

  /* Typography */
  --font-heading: 'Figtree', 'Noto Sans TC', system-ui, sans-serif;
  --font-body: 'Noto Sans TC', 'Figtree', system-ui, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;

  /* Spacing */
  --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;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

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

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

/* ===== Focus States (Accessibility) ===== */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== Buttons ===== */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  line-height: 1.4;
}

.ds-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.ds-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ds-btn-primary {
  background: var(--color-primary);
  color: white;
}
.ds-btn-primary:hover {
  background: var(--color-primary-dark);
}

.ds-btn-cta {
  background: var(--color-cta);
  color: white;
}
.ds-btn-cta:hover {
  background: var(--color-cta-dark);
}

.ds-btn-secondary {
  background: white;
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.ds-btn-secondary:hover {
  background: var(--color-border-light);
  border-color: var(--color-text-muted);
}

.ds-btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.ds-btn-ghost:hover {
  background: var(--color-border-light);
}

.ds-btn-danger {
  background: var(--color-danger);
  color: white;
}
.ds-btn-danger:hover {
  background: #B91C1C;
}

.ds-btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  min-height: 36px;
}

.ds-btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--fs-base);
}

/* ===== Cards ===== */
.ds-card {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
  transition: all var(--transition-base);
}

.ds-card-hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--color-border);
}

/* ===== Inputs ===== */
.ds-input {
  width: 100%;
  padding: var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--color-text);
  background: white;
  transition: border-color var(--transition-fast);
  min-height: 44px;
}

.ds-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

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

.ds-label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.ds-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ===== Badges ===== */
.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-heading);
}

.ds-badge-success {
  background: var(--color-cta-light);
  color: #065F46;
}

.ds-badge-warning {
  background: var(--color-warning-light);
  color: #92400E;
}

.ds-badge-danger {
  background: var(--color-danger-light);
  color: #991B1B;
}

.ds-badge-info {
  background: var(--color-primary-subtle);
  color: var(--color-primary-dark);
}

/* ===== Navbar ===== */
.ds-navbar {
  background: var(--color-bg-white);
  padding: var(--space-4) var(--space-8);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.ds-navbar-brand {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
}

.ds-navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ===== Container ===== */
.ds-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

@media (min-width: 768px) {
  .ds-container {
    padding: var(--space-8) var(--space-6);
  }
}

/* ===== Grid ===== */
.ds-grid {
  display: grid;
  gap: var(--space-6);
}

.ds-grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.ds-grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ===== Modal ===== */
.ds-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.ds-modal-overlay.active { display: flex; }

.ds-modal {
  background: var(--color-bg-white);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.ds-modal h2 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-6);
}

/* ===== Form Group ===== */
.ds-form-group {
  margin-bottom: var(--space-5);
}

.ds-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 480px) {
  .ds-form-row { grid-template-columns: 1fr; }
}

.ds-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ===== Error / Success Messages ===== */
.ds-alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  border-left: 4px solid;
}

.ds-alert-error {
  background: var(--color-danger-light);
  color: #991B1B;
  border-color: var(--color-danger);
}

.ds-alert-success {
  background: var(--color-cta-light);
  color: #065F46;
  border-color: var(--color-cta);
}

.ds-alert-info {
  background: var(--color-primary-subtle);
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
}

/* ===== Sport Tags ===== */
.ds-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-primary-subtle);
  color: var(--color-primary-dark);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.ds-tag button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: var(--fs-base);
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.ds-tag button:hover { opacity: 1; }

/* ===== Stat Card ===== */
.ds-stat {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  text-align: center;
}

.ds-stat-value {
  font-family: var(--font-heading);
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.ds-stat-label {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ===== Empty State ===== */
.ds-empty {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--color-text-muted);
}

.ds-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.ds-empty h3 {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

/* ===== Utility ===== */
.ds-text-center { text-align: center; }
.ds-text-sm { font-size: var(--fs-sm); }
.ds-text-muted { color: var(--color-text-muted); }
.ds-mt-4 { margin-top: var(--space-4); }
.ds-mt-6 { margin-top: var(--space-6); }
.ds-mb-4 { margin-bottom: var(--space-4); }
.ds-mb-6 { margin-bottom: var(--space-6); }
.ds-flex { display: flex; }
.ds-flex-between { display: flex; justify-content: space-between; align-items: center; }
.ds-gap-2 { gap: var(--space-2); }
.ds-gap-3 { gap: var(--space-3); }
.ds-gap-4 { gap: var(--space-4); }

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