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

:root {
  --bg-primary: #0a0a0f;
  --bg-card: rgba(20, 20, 35, 0.8);
  --bg-card-solid: #141423;
  --accent-primary: #6366f1;
  --accent-secondary: #22d3ee;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(99, 102, 241, 0.2);
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --font: 'Inter', sans-serif;
  --nav-height: 70px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + 20px);
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 12px;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

button {
  font-family: var(--font);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: opacity 0.2s, transform 0.1s;
  width: 100%;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

input, select, textarea {
  font-family: var(--font);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 16px;
  width: 100%;
  min-height: 44px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
}

/* Header */
header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-solid);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header button {
  width: auto;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
  transition: color 0.3s;
  padding: 8px;
  min-width: 64px;
}

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

.nav-item .icon {
  font-size: 24px;
  margin-bottom: 4px;
}

/* App Content */
#app-content {
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
}

/* Workout Page Specifics */
.live-hr {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-danger);
  margin-bottom: 20px;
}

.heart-icon {
  font-size: 40px;
  animation: pulse 1s infinite;
}

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

.exercise-card {
  transition: all 0.3s ease;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 15px;
}

.exercise-body {
  display: none;
}

.exercise-body.expanded {
  display: block;
  animation: slideDown 0.3s ease;
}

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

.set-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.set-row input {
  margin-bottom: 0;
  text-align: center;
}

/* Emoji Rating */
.rating-group {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.rating-btn {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  font-size: 24px;
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.rating-btn.selected {
  background: var(--accent-primary);
  border-color: var(--accent-secondary);
}

/* Utilities */
.fade-in {
  animation: fadeIn 0.4s ease;
}

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

/* Toasts */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: slideLeft 0.3s ease;
}

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

@keyframes slideLeft {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== WORKOUT PAGE ==================== */
.workout-page { }

.workout-header h2 { margin-bottom: 4px; }
.workout-date { color: var(--text-secondary); font-size: 14px; margin-bottom: 8px; }

.phase-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-primary), rgba(99,102,241,0.3));
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
}

.exercise-target { color: var(--text-secondary); font-size: 13px; }
.exercise-reps { color: var(--accent-secondary); font-size: 14px; font-weight: 500; white-space: nowrap; }
.expand-icon { color: var(--text-muted); font-size: 14px; transition: transform 0.3s; }
.exercise-card.collapsed .expand-icon { transform: rotate(-90deg); }
.exercise-card.collapsed .exercise-body { display: none; }
.exercise-card .exercise-body { display: block; animation: slideDown 0.3s ease; }
.exercise-card .exercise-header h3 { margin-bottom: 2px; font-size: 15px; }

/* ==================== COACH / TRAINER UI ==================== */
.plan-badge {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(34, 211, 238, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.coach-tip {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--accent-warning);
  margin-bottom: 8px;
  line-height: 1.4;
}

.breathing-tip {
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 0;
  margin-bottom: 10px;
}

.technique-toggle {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  min-height: 36px;
  margin-bottom: 4px;
  width: 100%;
  transition: color 0.2s, border-color 0.2s;
}

.technique-toggle:hover,
.technique-toggle:active {
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

.technique-panel {
  display: none;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: slideDown 0.3s ease;
}

.technique-panel.open {
  display: block;
}

.exercise-gif {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-sm);
  margin: 0 auto 12px;
  display: block;
}

.technique-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.technique-mistakes {
  color: var(--accent-danger);
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-danger);
}

/* Warmup / Cooldown */
.warmup-card { border-left: 3px solid #f97316; }
.cooldown-card { border-left: 3px solid #06b6d4; }
.warmup-card h3 { color: #f97316; }
.cooldown-card h3 { color: #06b6d4; }
.warmup-steps { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.warmup-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.warmup-step .step-num {
  min-width: 28px;
  height: 28px;
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.cooldown-card .step-num {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}
.warmup-step strong { font-size: 14px; color: var(--text-primary); }
.warmup-duration {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}
.warmup-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 4px;
}
.warmup-step-content { flex: 1; min-width: 0; }
.warmup-img-toggle {
  background: none;
  border: 1px dashed var(--text-muted);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s;
}
.warmup-img-toggle:hover { color: var(--accent-secondary); border-color: var(--accent-secondary); }
.warmup-img-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 0;
}
.warmup-img-panel.open {
  max-height: 400px;
  margin-top: 8px;
}
.warmup-img-panel img {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius-sm);
}

.exercise-card .exercise-header h3 { margin-bottom: 2px; font-size: 15px; }

.set-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.set-row.set-header {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.set-number {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.set-row input {
  margin-bottom: 0;
  text-align: center;
  padding: 10px 6px;
  font-size: 15px;
}

.btn-add-set {
  margin-top: 8px;
  font-size: 14px;
  min-height: 38px;
  padding: 8px 16px;
}

/* ==================== POLAR HR & TIMER ==================== */
.polar-timer-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border-left: 3px solid var(--accent-primary);
}

.btn-polar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-polar:hover { background: linear-gradient(135deg, #2563eb, #60a5fa); }

.heart-icon-static { font-size: 18px; }

.live-hr {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
}

.hr-value { font-size: 44px; font-weight: 700; color: var(--accent-danger); line-height: 1; }
.hr-unit { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }

.hr-stats {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.pulse { animation: pulse 1s infinite; }

.timer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.timer-display {
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-secondary);
}

.btn-timer-toggle {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-timer-toggle:hover { opacity: 0.9; }
.btn-timer-toggle.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* ==================== METRICS ==================== */
.metrics-card h3 { margin-bottom: 16px; }

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-field label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
}

.metric-field input, .metric-field textarea {
  margin-bottom: 0;
}

.rating-section {
  margin-top: 16px;
}

.rating-section label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}

.btn-submit {
  margin-top: 20px;
  font-size: 17px;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent-success), #059669);
}

.btn-submit.mini {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
}

/* ==================== LOADING SKELETON ==================== */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-card {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(99,102,241,0.1) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  height: 120px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==================== DASHBOARD ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  text-align: center;
  padding: 16px;
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.chart-card { padding: 16px; }
.chart-card h3 { margin-bottom: 12px; font-size: 15px; }

.chart-container {
  position: relative;
  height: 220px;
}

.glass-select {
  font-family: var(--font);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  margin-bottom: 12px;
  outline: none;
}

.glass-select:focus { border-color: var(--accent-primary); }

/* ==================== PROGRAM ==================== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.phase-timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.phase-block {
  text-align: center;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: all 0.3s;
}

.phase-block.current {
  border-color: var(--accent-primary);
  background: rgba(99,102,241,0.1);
}

.phase-name { font-weight: 600; font-size: 13px; }
.phase-weeks { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.phase-params { color: var(--text-secondary); font-size: 11px; margin-top: 2px; }

.exercises-list { display: flex; flex-direction: column; gap: 8px; }

.program-exercise {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ex-num { color: var(--text-muted); font-weight: 600; font-size: 13px; }
.ex-name { font-weight: 500; font-size: 14px; }
.ex-target { color: var(--text-secondary); font-size: 12px; }
.ex-rest { color: var(--accent-secondary); font-size: 12px; white-space: nowrap; }
.ex-reps { color: var(--accent-secondary); font-size: 12px; white-space: nowrap; }

/* ==================== HISTORY ==================== */
.history-card {
  cursor: pointer;
  transition: all 0.3s;
}

.history-card:hover { border-color: var(--accent-primary); }

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.history-header h4 { margin-bottom: 4px; font-size: 14px; }

.history-details {
  display: none;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.history-card.expanded .history-details {
  display: block;
  animation: slideDown 0.3s ease;
}

.history-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.history-sets { margin-top: 8px; }

.history-set-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-secondary);
}

.history-set-row span:first-child { font-weight: 500; color: var(--text-primary); }

.history-notes {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay.visible { opacity: 1; }

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.visible .modal { transform: translateY(0); }

.modal h2 { margin-bottom: 16px; }

.analysis-scores {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.score-item {
  text-align: center;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
}

.score-label { display: block; color: var(--text-muted); font-size: 12px; }
.score-value { display: block; font-weight: 600; font-size: 15px; margin-top: 4px; }

.recommendations { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.rec-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  font-size: 14px;
}

.rec-item p { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.rec-success { border-left: 3px solid var(--accent-success); }
.rec-warning { border-left: 3px solid var(--accent-warning); }
.rec-info { border-left: 3px solid var(--accent-secondary); }
.rec-danger { border-left: 3px solid var(--accent-danger); }

.btn-close-modal {
  margin-top: 20px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

/* ==================== ERROR ==================== */
.error-card { border-left: 3px solid var(--accent-danger); }
.error-card h3 { color: var(--accent-danger); }

/* ==================== APP CONTENT TRANSITION ==================== */
#app-content {
  transition: opacity 0.15s ease;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .metrics-grid { grid-template-columns: 1fr 1fr 1fr; }
  .modal { border-radius: var(--radius); margin-bottom: 20px; }
}
