/* CSS Variables */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #10b981;
  --secondary-light: #34d399;
  --accent: #f59e0b;
  --danger: #ef4444;
  
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-tertiary: #1a1a24;
  --bg-card: #16161f;
  --bg-elevated: #1e1e2a;
  
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --border-color: #27272a;
  --border-light: #3f3f46;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --nav-height: 70px;
  --header-height: 60px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

/* Light mode */
.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-light: #cbd5e1;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

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

.nav-icon {
  width: 24px;
  height: 24px;
}

/* Screens Container */
.screens-container {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);
}

.screen.active {
  display: block;
  animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Screen Header */
.screen-header {
  position: sticky;
  top: 0;
  padding: calc(var(--safe-area-top) + 16px) 20px 16px;
  background: var(--bg-primary);
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content {
  flex: 1;
}

.greeting {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Screen Content */
.screen-content {
  padding: 0 20px 20px;
}

/* Sections */
.section {
  margin-top: 28px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:active {
  transform: scale(0.98);
}

.card-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Progress Bar */
.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  margin-top: 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* Session Card */
.session-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  margin-top: 16px;
}

.session-header {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.session-icon {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.session-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.session-info {
  flex: 1;
  min-width: 0;
}

.session-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.session-details {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Quick Start Grid */
.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.quick-start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.quick-start-card:active {
  transform: scale(0.95);
  background: var(--bg-elevated);
}

.quick-start-card span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.quick-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-icon svg {
  width: 22px;
  height: 22px;
}

.quick-icon.run {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.quick-icon.trail {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.quick-icon.weights {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.quick-icon.stretch {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Programs List */
.programs-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.program-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.program-card-item:active {
  transform: scale(0.98);
}

.program-card-item.active-program {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.program-card-header {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.program-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.program-icon svg {
  width: 24px;
  height: 24px;
}

.program-icon.running {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.program-icon.trail {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.program-icon.weights {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.program-icon.mobility {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.program-card-info {
  flex: 1;
  min-width: 0;
}

.program-card-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.program-card-meta {
  display: flex;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.program-card-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 12px 18px;
  margin-bottom: 16px;
}

.search-bar svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

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

/* Filter Chips */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Exercises Grid */
.exercises-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.exercise-card:active {
  transform: scale(0.98);
}

.exercise-card-image {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.exercise-card-image svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.exercise-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exercise-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.exercise-card-muscle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Streak Card */
.streak-card {
  background: linear-gradient(135deg, var(--accent) 0%, #ea580c 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  color: white;
}

.streak-flame {
  font-size: 3rem;
}

.streak-count {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.streak-label {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Charts */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  height: 200px;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.history-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-icon svg {
  width: 22px;
  height: 22px;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.history-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Responsive */
@media (min-width: 480px) {
  .quick-start-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 400px;
  }
  
  .exercises-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .screen-content {
    max-width: 600px;
    margin: 0 auto;
  }
  
  .exercises-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
