/* ==========================================================================
   WORKOUT APPLICATION STYLESHEET
   Clean, distraction-free, high-performance dark theme
   ========================================================================== */

:root {
  /* Surface & Backgrounds */
  --bg-primary: #0a0b0d;
  --bg-card: #131417;
  --bg-card-hover: #191b20;
  --bg-input: #0f1013;
  --bg-nav: #0c0d10;
  --border-color: #22242a;
  --border-focus: #3b82f6;

  /* Typography */
  --text-primary: #ededf0;
  --text-secondary: #8e929e;
  --text-muted: #5e626e;
  --text-dim: #41444d;

  /* Accents - Functional, Solid, No Neon Gradients */
  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-blue: #3b82f6;
  --accent-blue-bg: rgba(59, 130, 246, 0.1);
  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.1);
  --accent-orange: #f59e0b;

  /* Geometry - Crisp, Rectangular, No Pill Shapes */
  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;

  /* Layout */
  --nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --max-width: 520px;
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 15px;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* App Shell */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 24px);
  overflow-y: auto;
}

.page--active {
  display: flex;
}

/* Sticky Rest Timer Bar */
.rest-timer-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background-color: #121418;
  border-bottom: 2px solid var(--accent-green);
}

.rest-timer-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rest-timer-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rest-timer-clock {
  font-size: 20px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--accent-green);
}

.rest-timer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

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

.card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.card__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Buttons - Flat, Crisp, Rectangular (No Pill Radii) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.btn:active {
  opacity: 0.85;
}

.btn--primary {
  background-color: var(--accent-green);
  color: #061e12;
  border-color: var(--accent-green);
}

.btn--outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn--outline:hover, .btn--outline:active {
  background-color: var(--bg-card-hover);
  border-color: var(--text-secondary);
}

.btn--danger {
  background-color: var(--accent-red-bg);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

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

.btn--ghost:hover, .btn--ghost:active {
  color: var(--text-primary);
  background-color: var(--bg-card-hover);
}

.btn--block {
  width: 100%;
}

.btn--lg {
  padding: 14px 20px;
  font-size: 15px;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn--xs {
  padding: 4px 8px;
  font-size: 12px;
}

/* Segmented Control / Tab Switcher (Rectangular) */
.segmented-control {
  display: flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 3px;
  gap: 4px;
  margin-bottom: 14px;
}

.segmented-control__item {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented-control__item--active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  border: 1px solid var(--border-color);
}

/* Day selector multi-day responsiveness */
#day-selector {
  overflow-x: auto;
  scrollbar-width: none;
}

#day-selector::-webkit-scrollbar {
  display: none;
}

#day-selector .segmented-control__item {
  min-width: 48px;
  padding: 6px 4px;
  font-size: 12px;
  white-space: nowrap;
}

/* Inputs */
.input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus {
  border-color: var(--border-focus);
}

.input--num {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
}

/* Badges (Flat Rectangular, No Pill Shapes) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.badge--green {
  background-color: var(--accent-green-bg);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.badge--blue {
  background-color: var(--accent-blue-bg);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
}

/* Workout Checklist Container */
.workout-checklist {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exercise-block {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
}

.exercise-block__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.exercise-block__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.exercise-block__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.exercise-block__note {
  font-size: 12px;
  color: var(--text-muted);
  background-color: var(--bg-input);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 2px solid var(--text-muted);
}

/* Set Table */
.set-table {
  width: 100%;
  border-collapse: collapse;
}

.set-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
}

.set-table td {
  padding: 8px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.set-table tr:last-child td {
  border-bottom: none;
}

.set-table tr.set-row--done td {
  opacity: 0.55;
}

.set-table tr.set-row--done .set-checkbox {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
  color: #061e12;
}

/* Set Checkbox - Large, Accessible, Rectangular */
.set-checkbox {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 2px solid var(--border-color);
  background-color: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  color: transparent;
  transition: all 0.15s ease;
  user-select: none;
}

.set-checkbox:active {
  transform: scale(0.95);
}

.set-checkbox--checked {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
  color: #061e12;
}

.set-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Bottom Navigation */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background-color: var(--bg-nav);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: var(--safe-area-bottom);
  z-index: 90;
}

.nav-bottom__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
}

.nav-bottom__item--active {
  color: var(--accent-green);
}

.nav-icon {
  width: 20px;
  height: 20px;
  margin-bottom: 3px;
}

.nav-bottom__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}

/* Utility Helpers */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 20px; }
.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 14px; }
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 18px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-secondary); }
.text-green { color: var(--accent-green); }
.text-blue { color: var(--accent-blue); }
.text-red { color: var(--accent-red); }
.border-b { border-bottom: 1px solid var(--border-color); }
.pb-xs { padding-bottom: 4px; }
.pb-sm { padding-bottom: 8px; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
}

.stat-box__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-box__value {
  font-size: 20px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-primary);
  margin-top: 4px;
}
