/* Color Variables for Light & Dark Mode */
:root {
  --bg-color: #f9fafb;
  --text-color: #333;
  --heading-color: #1f2937;
  --card-bg-color: white;
  --border-color-light: #e5e7eb;
  --border-color-medium: #d1d5db;
  --back-btn-hover-bg: #f3f4f6;
  --progress-badge-bg: #f3f4f6;
  --progress-badge-text: #374151;
  --days-card-bg: rgb(232, 232, 235);
  --days-btn-bg: rgb(221, 122, 142);
  --days-btn-text: #333;
  --days-btn-hover-bg: #eff6ff;
  --days-btn-hover-border: #3b82f6;
  --exercise-completed-bg: #f0fdf4;
  --exercise-completed-border: #16a34a;
  --exercise-badge-incomplete-bg: #f3f4f6;
  --exercise-badge-incomplete-text: #6b7280;
  --checklist-completed-bg: #f0fdf4;
  --checklist-completed-border: #bbf7d0;
  --checklist-completed-text: #166534;
  --checklist-incomplete-bg: #e5e7eb;
  --checklist-incomplete-icon: #9ca3af;
  --stat-remaining-color: #9ca3af;
  --icon-circle-blue-bg: #e0f2fe;
  --icon-circle-blue-text: #2563eb;
  --icon-circle-green-bg: #dcfce7;
  --icon-circle-green-text: #16a34a;
  --icon-circle-purple-bg: #ede9fe;
  --icon-circle-purple-text: #7c3aed;
  --tips-text-color: #4b5563;
}

body.dark-mode {
  --bg-color: #111827;
  --text-color: #d1d5db;
  --heading-color: #f9fafb;
  --card-bg-color: #1f2937;
  --border-color-light: #374151;
  --border-color-medium: #4b5563;
  --back-btn-hover-bg: #374151;
  --progress-badge-bg: #374151;
  --progress-badge-text: #d1d5db;
  --days-card-bg: #1f2937;
  --days-btn-bg: #9f2a48;
  --days-btn-text: #f9fafb;
  --days-btn-hover-bg: #374151;
  --days-btn-hover-border: #60a5fa;
  --exercise-completed-bg: #064e3b;
  --exercise-completed-border: #15803d;
  --exercise-badge-incomplete-bg: #374151;
  --exercise-badge-incomplete-text: #9ca3af;
  --checklist-completed-bg: #042f2e;
  --checklist-completed-border: #065f46;
  --checklist-completed-text: #6ee7b7;
  --checklist-incomplete-bg: #374151;
  --checklist-incomplete-icon: #6b7280;
  --stat-remaining-color: #6b7280;
  --icon-circle-blue-bg: #1e3a8a;
  --icon-circle-blue-text: #93c5fd;
  --icon-circle-green-bg: #064e3b;
  --icon-circle-green-text: #6ee7b7;
  --icon-circle-purple-bg: #4c1d95;
  --icon-circle-purple-text: #c4b5fd;
  --tips-text-color: #9ca3af;
}

/* Basic Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

#background-video {
  position: fixed;
  right: 0;
  bottom: 0;
  min-width: 100%; 
  min-height: 100%;
  z-index: -1;
  object-fit: cover;
}

/* Page Containers */
.page {
  display: none; /* Hidden by default */
  min-height: 100vh;
  padding: 20px;
}

.page.active {
  display: flex; /* Show active page */
  justify-content: center;
  align-items: center;
}

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Levels Page */
.level-card {
  background: var(--card-bg-color);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.level-card h1 {
  font-size: 2rem;
  margin-bottom: 30px;
  color: var(--heading-color);
}

.level-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.level-btn {
  padding: 16px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
}

.level-btn.beginner { background: #16a34a; }
.level-btn.beginner:hover { background: #15803d; }
.level-btn.intermediate { background: #2563eb; }
.level-btn.intermediate:hover { background: #1d4ed8; }
.level-btn.advanced { background: #dc2626; }
.level-btn.advanced:hover { background: #b91c1c; }

/* Days Page */
.page-title {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 30px;
  color: var(--heading-color);
  text-transform: capitalize;
}

.days-card {
  background: var(--days-card-bg);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 600px;
}

.days-card h3 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 30px;
  color: var(--heading-color);
}

.days-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.days-buttons button {
  padding: 20px 16px;
  background: var(--days-btn-bg);
  border: 2px solid var(--border-color-light);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--days-btn-text);
}

.days-buttons button:hover {
  border-color: var(--days-btn-hover-border);
  background: var(--days-btn-hover-bg);
}

/* Back Button */
.back-btn {
  background: var(--card-bg-color);
  border: 1px solid var(--border-color-medium);
  color: var(--text-color);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 20px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.back-btn:hover {
  background: var(--back-btn-hover-bg);
}

/* Workout Page */
.workout-header {
  text-align: center;
  margin-bottom: 30px;
}

.workout-header h2 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: var(--heading-color);
  text-transform: capitalize;
}

.progress-badge {
  display: inline-block;
  background: var(--progress-badge-bg);
  color: var(--progress-badge-text);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 500;
}

.workout-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* Main Workout Content */
.workout-card {
  background: var(--card-bg-color);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.workout-card h3 {
  font-size: 1.5rem;
  margin-bottom: 30px;
  color: var(--heading-color);
}

.exercise {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  padding: 20px;
  border: 2px solid var(--border-color-light);
  border-radius: 12px;
  background: var(--card-bg-color);
  transition: all 0.2s ease;
}

.exercise.completed {
  border-color: var(--exercise-completed-border);
  background: var(--exercise-completed-bg);
}

.exercise:hover {
  border-color: var(--border-color-medium);
}

.exercise img {
  width: 300px;
  height: 300px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.exercise img:hover {
  transform: scale(1.05);
}

.exercise-content {
  flex: 1;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.exercise-header h4 {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--heading-color);
}

.exercise-intensity-badge {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  color: white;
}

.exercise-intensity-badge.low { background: #16a34a; }
.exercise-intensity-badge.medium { background: #2563eb; }
.exercise-intensity-badge.high { background: #dc2626; }
.exercise-intensity-badge.very-low { background: #e5e7eb; color: #4b5563; }
.exercise-intensity-badge.very-high { background: #b91c1c; }
.exercise-intensity-badge.max { background: #000; }
.exercise-intensity-badge.rest,
.exercise-intensity-badge.na { background: #9ca3af; }

.exercise-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.exercise-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exercise-detail-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exercise-detail-icon-circle.blue { background: var(--icon-circle-blue-bg); color: var(--icon-circle-blue-text); }
.exercise-detail-icon-circle.green { background: var(--icon-circle-green-bg); color: var(--icon-circle-green-text); }
.exercise-detail-icon-circle.purple { background: var(--icon-circle-purple-bg); color: var(--icon-circle-purple-text); }

.exercise-detail-label {
  font-size: 0.75rem;
  color: var(--text-color);
}

.exercise-detail-value {
  font-weight: 600;
  color: var(--heading-color);
  font-size: 0.875rem;
}

.exercise-description-title, .exercise-tips-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--heading-color);
  margin-bottom: 8px;
}

.exercise-description-text {
  color: var(--tips-text-color);
  line-height: 1.625;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.exercise-tips {
  list-style: none;
  margin-bottom: 16px;
}

.exercise-tips li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--tips-text-color);
  font-size: 0.875rem;
}

.exercise-tips li::before {
  content: "•";
  color: var(--checklist-incomplete-icon);
  font-weight: bold;
  margin-top: 2px;
}

.exercise-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

.exercise-badge.completed { background: var(--exercise-completed-border); color: white; }
.exercise-badge.incomplete { background: var(--exercise-badge-incomplete-bg); color: var(--exercise-badge-incomplete-text); }

/* Progress Sidebar */
.progress-sidebar {
  position: sticky;
  top: 20px;
  height: fit-content;
}

.progress-card {
  background: var(--card-bg-color);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.progress-card h3 {
  font-size: 1.25rem;
  margin-bottom: 24px;
  color: var(--heading-color);
}

/* Overall Progress */
.overall-progress {
  margin-bottom: 32px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: var(--border-color-light);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar {
  height: 100%;
  background: var(--exercise-completed-border);
  border-radius: 6px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-color);
}

/* Exercise Checklist */
.exercise-checklist {
  margin-bottom: 24px;
}

.exercise-checklist h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 16px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-color-light);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checklist-item:hover {
  border-color: var(--border-color-medium);
}

.checklist-item.completed {
  border-color: var(--checklist-completed-border);
  background: var(--checklist-completed-bg);
}

.checklist-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.checklist-icon.completed { background: var(--exercise-completed-border); color: white; }
.checklist-icon.incomplete { background: var(--checklist-incomplete-bg); color: var(--checklist-incomplete-icon); }

.checklist-content {
  flex: 1;
  min-width: 0;
}

.checklist-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--heading-color);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checklist-item.completed .checklist-name {
  color: var(--checklist-completed-text);
}

.checklist-info {
  font-size: 0.75rem;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Completion Status */
.completion-status {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--checklist-completed-bg);
  border: 1px solid var(--checklist-completed-border);
  border-radius: 8px;
}

.completion-content { text-align: center; }
.completion-icon { font-size: 2rem; margin-bottom: 8px; }
.completion-title { font-size: 0.875rem; font-weight: 600; color: var(--checklist-completed-text); margin-bottom: 4px; }
.completion-subtitle { font-size: 0.75rem; color: var(--exercise-completed-border); }

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color-light);
}

.stat { text-align: center; }
.stat-number { font-size: 2rem; font-weight: bold; color: var(--exercise-completed-border); }
.stat:last-child .stat-number { color: var(--stat-remaining-color); }
.stat-label { font-size: 0.75rem; color: var(--text-color); }

/* Theme Toggle Button */
.theme-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-color-medium);
  background-color: var(--card-bg-color);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}
.theme-toggle-btn:hover {
  transform: scale(1.1);
}
.theme-toggle-btn #theme-toggle-dark-icon {
  display: none;
}
.dark-mode .theme-toggle-btn #theme-toggle-dark-icon {
  display: block;
}
.dark-mode .theme-toggle-btn #theme-toggle-light-icon {
  display: none;
}


/* Responsive Design */
@media (max-width: 1024px) {
  .workout-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .exercise { flex-direction: column; }
  .exercise img { width: 100%; height: 200px; }
  .days-buttons { grid-template-columns: repeat(2, 1fr); }
  .container-wide { padding: 16px; }
}