/*
 * Modern style for the at‑home workout webapp.
 * Defines a clean, mobile‑responsive layout with a dark theme and bright blue accent.
 */

/* Theme colours */
:root {
  --primary: #3fa9f5;
  --primary-dark: #2d7fc3;
  --secondary: #14171c;
  --card-bg: #1e2330;
  --card-border: #2a2f3d;
  --text-color: #e5e7eb;
  --muted-text: #9fa6b2;
  --highlight-bg: #24334a;
  --highlight-border: #3fa9f5;
  --progress-bg: #2a3245;
}

/* Base styles */
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  background-color: var(--secondary);
  line-height: 1.5;
  font-size: 18px;
}

/* Layout */
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}
.content {
  flex: 1;
  padding: 24px 40px;
  overflow-y: auto;
}
.music {
  display: none;
}

/* Page title centering on home */
.page-title {
  text-align: center;
  margin: 0 0 24px;
  font-size: 28px;
  font-weight: 700;
}

/* Dashboard grid for home page: two columns on larger screens */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 768px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    align-items: flex-start;
  }
}

/* Headings */
h1 {
  font-size: 28px;
  margin: 0 0 12px;
}
h2 {
  font-size: 22px;
  margin-top: 24px;
  margin-bottom: 12px;
}

/* Highlight box for next session */
.highlight-box {
  background-color: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 600;
}

/* Primary button */
.primary-btn {
  display: inline-block;
  padding: 12px 24px;
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 10px;
  font-size: 16px;
  transition: background-color 0.2s ease;
  text-align: center;
}
.primary-btn:hover {
  background-color: var(--primary-dark);
}
.play-all-btn {
  display: block;
  width: 100%;
  margin: 6px 0 18px;
}

/* Instrument summary line displayed at the top of each session. */
.instrument-summary {
  margin: 6px 0 18px;
  font-style: italic;
  color: var(--muted-text);
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.back-link:hover {
  text-decoration: underline;
}

/* Session list styles */
.session-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}
.session-list li {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, background-color 0.2s;
}
.session-list li:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.session-list li input[type="checkbox"] {
  margin-right: 12px;
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  transform: scale(1.2);
  cursor: pointer;
}
.session-list li .session-name {
  flex-grow: 1;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.session-list li .session-name:hover {
  text-decoration: underline;
}
.session-list li.completed {
  background-color: #24384a;
  border-color: #2f4a61;
}
.session-list li.completed .session-name {
  text-decoration: line-through;
  color: #7cae80;
}
.session-list li.next {
  border-color: var(--primary);
  background-color: var(--highlight-bg);
}
.session-list li .status {
  margin-left: 8px;
  font-size: 14px;
  color: var(--muted-text);
}

/* Progress indicator on session page */
.session-progress {
  font-size: 14px;
  margin: 8px 0 16px;
  color: var(--muted-text);
}
.progress-bar-container {
  width: 100%;
  background-color: var(--progress-bg);
  border-radius: 6px;
  height: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background-color: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* Exercise cards */
.exercise {
  border: 1px solid var(--card-border);
  background-color: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.exercise-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background-color: #25304b;
  border-bottom: 1px solid var(--card-border);
  cursor: pointer;
}
.exercise-header.open .toggle-icon {
  transform: rotate(90deg);
}
.exercise-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.toggle-icon {
  font-size: 18px;
  transition: transform 0.2s;
  color: var(--primary);
}
.exercise-details {
  padding: 18px;
  display: none;
  background-color: var(--card-bg);
}
.exercise-details.active {
  display: block;
}
.exercise-details p {
  margin: 10px 0;
  color: var(--text-color);
}
.exercise-details p strong {
  color: var(--primary);
}

/* Video layout */
.exercise-videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.exercise-video {
  width: 100%;
  border-radius: 6px;
  background-color: #0f172a;
}

.musclewiki-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--primary);
  font-weight: 500;
  font-size: 14px;
  text-decoration: underline;
}
.musclewiki-link:hover {
  color: var(--primary-dark);
}

/* When the MuscleWiki link is placed inside the muscle-info block, reduce its margin to align it with the image/text */
.muscle-info .musclewiki-link {
  margin-bottom: 4px;
  display: block;
}

/* Layout for exercise details: when expanded, videos and info are displayed side by side on larger screens */
.exercise-details.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.exercise-details.active .exercise-videos {
  margin-bottom: 12px;
}
.exercise-details.active .exercise-info {
  /* no extra rules by default */
}
@media (min-width: 768px) {
  .exercise-details.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    align-items: flex-start;
  }
  .exercise-details.active .exercise-videos {
    margin-bottom: 0;
  }
}

/* Timer bar styles */
.timer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--highlight-bg);
  /* Increase padding and font size for better tap targets on tablets.
     A larger bar helps avoid triggering the OS multitasking bar when tapped. */
  /* Reduce vertical padding to decrease the gap between timer controls and bar edges */
  padding: 12px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  font-size: 20px;
  z-index: 1000;
  border-top: 1px solid var(--card-border);
}
.timer-bar button {
  font-size: 18px;
  padding: 8px 14px;
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.timer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* Grouped timer controls */
.timer-left,
.timer-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
}
/* Make the time display prominent and centered */
#timer-display {
  /* Do not expand; center relative to available space */
  flex: 0 0 auto;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
}
.timer-bar button:hover {
  background-color: var(--primary-dark);
}

/* Set list */
.sets {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.set-item {
  display: flex;
  align-items: center;
  font-size: 16px;
}
.set-item input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  transform: scale(1.15);
  cursor: pointer;
}
.set-item.done label {
  text-decoration: line-through;
  color: var(--muted-text);
}

/* Stats container */
.stats-container {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 20px 0;
  font-size: 16px;
  line-height: 1.6;
}
.stats-container .stat-item {
  margin-bottom: 8px;
}
.stats-container .stat-item strong {
  color: var(--primary);
  font-weight: 600;
}

/* Dropdown button */
.dropdown-btn {
  display: inline-block;
  margin-top: 10px;
  margin-bottom: 10px;
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.dropdown-btn:hover {
  background-color: var(--primary-dark);
}

/* Muscle info section */
.muscle-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}
.muscle-info img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}
.muscle-info p {
  margin: 0;
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.4;
}
.muscle-info strong {
  color: var(--primary);
}

/* Reps count emphasised in set label */
.reps-count {
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
}

/* Checkbox di livello esercizio in header */
.exercise-header input.exercise-checkbox {
  margin-right: 12px;
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  transform: scale(1.2);
  cursor: pointer;
}

/* Badge for number of sets (unused) */
.exercise-header .sets-count-badge {
  margin-left: auto;
  margin-right: 12px;
  background-color: var(--primary-dark);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  .music {
    width: 100%;
    height: auto;
    position: relative;
    border-left: none;
    border-top: 1px solid var(--card-border);
  }
  .content {
    padding: 20px;
  }

  /* Reduce base font size on mobile/tablet to fit more content and provide a slight zoom-out effect */
  body {
    font-size: 16px;
  }

  /* Make the timer bar slightly smaller on mobile for space efficiency, while keeping touch targets large */
  .timer-bar {
    font-size: 18px;
    gap: 16px;
    /* Reduce vertical padding on small screens */
    padding: 10px 20px;
  }
  .timer-bar button {
    font-size: 16px;
    padding: 6px 12px;
  }

  /* Slightly reduce the size of the timer display on small screens to maintain balance */
  #timer-display {
    font-size: 28px;
  }

  /* Ensure emphasis labels (strong) inside exercise info are not larger than base text */
  .exercise-info p strong {
    font-size: 14px;
  }

  /* Riduci le dimensioni del testo per le descrizioni, attenzione e strumento nelle info degli esercizi */
  .exercise-info p {
    font-size: 14px;
    line-height: 1.4;
  }
}

/* Additional small‑screen tweaks for phone devices */
@media (max-width: 480px) {
  .content {
    padding: 16px;
  }
  h1 {
    font-size: 24px;
  }
  h2 {
    font-size: 20px;
  }
  h3 {
    font-size: 18px;
  }
  .exercise-video {
    max-width: 100%;
    height: auto;
  }
}