/* styles.css
   Background stays dark/black in every color scheme - only the accent
   (highlights, lines, key text) changes based on the user's selection
   in Settings. --accent-rest is intentionally fixed across all schemes:
   it's the ring/cue color during REST phases, kept visually distinct
   from whichever accent color is chosen for HOLD phases. */

/* Rajdhani font bundled locally (via @fontsource) so it works fully
   offline from first install - no external CDN dependency. */
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/rajdhani-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/rajdhani-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 600;
  src: url('../fonts/rajdhani-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/rajdhani-latin-700-normal.woff2') format('woff2');
}

:root {
  --bg: #0B0F0E;
  --bg-card: #14201D;
  --bg-card-alt: #1A2A26;
  --text-primary: #F2F5F4;
  --danger: #C97A7A;
  --accent-rest: #5B8DEF; /* fixed cool blue - distinct from any accent color */
  --accent-rest-dark: #0A1830;
}

/* --- Color schemes: each only redefines accent, border, and secondary text --- */
body[data-theme="teal"] {
  --accent: #1D9E75; --accent-dark: #04342C;
  --text-secondary: #7FBFA8; --text-muted: #5C8C7C; --border: #1E4A3E;
}
body[data-theme="purple"] {
  --accent: #8B5CF6; --accent-dark: #1E1033;
  --text-secondary: #C4B5FD; --text-muted: #8B7CB8; --border: #3B2E5C;
}
body[data-theme="green"] {
  --accent: #22C55E; --accent-dark: #0B2818;
  --text-secondary: #86EFAC; --text-muted: #5FAE7A; --border: #1E4A2E;
}
body[data-theme="blue"] {
  --accent: #3B82F6; --accent-dark: #0B1E33;
  --text-secondary: #93C5FD; --text-muted: #6B8CB8; --border: #1E3A5C;
}
body[data-theme="orange"] {
  --accent: #F59E0B; --accent-dark: #332005;
  --text-secondary: #FCD34D; --text-muted: #B8945F; --border: #4A3A1E;
}
body[data-theme="red"] {
  --accent: #EF4444; --accent-dark: #330A0A;
  --text-secondary: #FCA5A5; --text-muted: #B87A7A; --border: #4A1E1E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px;
  padding-bottom: 84px; /* leaves room for the fixed nav bar */
  max-width: 420px;
  margin: 0 auto;
}
.screen.active { display: flex; }

#screen-workout { position: relative; }
.get-ready-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}
.get-ready-overlay.active { display: flex; }
.get-ready-text {
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 40px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.get-ready-text.visible { opacity: 1; }

h1 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
p.subtitle { font-size: 13px; color: var(--text-secondary); margin: 0 0 20px; }

label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 6px; }
input, select {
  width: 100%;
  height: 40px;
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

button {
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.btn-primary {
  height: 44px;
  background: var(--accent);
  color: var(--accent-dark);
  border-radius: 8px;
  width: 100%;
}
.btn-secondary {
  height: 44px;
  background: transparent;
  color: var(--text-primary);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  width: 100%;
}
.btn-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--bg-card-alt);
  border: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}

.spacer { flex: 1; }

/* Workout screen */
.workout-top-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 12px; color: var(--text-secondary);
}
.toggle-row { display: flex; align-items: center; gap: 6px; }
.toggle {
  width: 32px; height: 18px; border-radius: 9px; position: relative; cursor: pointer;
  background: var(--border); transition: background 0.15s;
}
.toggle.on { background: var(--accent); }
.toggle .knob {
  width: 14px; height: 14px; border-radius: 50%; background: var(--text-primary);
  position: absolute; top: 2px; left: 2px; transition: left 0.15s;
}
.toggle.on .knob { left: 16px; }

.progress-bar {
  height: 4px; background: rgba(255,255,255,0.12); border-radius: 2px;
  margin-bottom: 24px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; }

.timer-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.timer-ring-container {
  width: 320px; height: 320px; position: relative;
  margin-bottom: 18px;
}
.timer-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: none;
}
.timer-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.timer-ring-inner {
  position: absolute; top: 26px; left: 26px; right: 26px; bottom: 26px;
  border-radius: 50%; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: background 0.4s;
}
/* During an active HOLD (or a pulse's hold beat), the inner circle
   fills with the user's selected accent color, blended with the dark
   background so text stays readable - this is now where the MOST
   color shows, since hold is the active/working phase. REST goes back
   to the plain neutral background (no tint at all) - the opposite of
   how this used to work, when rest got the color and hold stayed
   plain. */
.timer-ring-inner.hold-tint {
  background: color-mix(in srgb, var(--accent) 45%, var(--bg));
}
.timer-number { font-size: 72px; font-weight: 500; }
.timer-phase-label { font-size: 14px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.15em; }
.timer-cue { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }

/* Tracked-out uppercase labels, matching the reference's technical/fitness look */
.tracked-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--text-muted); text-align: center; margin: 0;
}

.session-remaining-block { text-align: center; margin-bottom: 18px; }
.remaining-value { font-size: 26px; font-weight: 600; color: var(--text-primary); margin: 2px 0 6px; letter-spacing: 0.05em; }
.interval-sublabel { font-size: 10px; color: var(--text-muted); }

.cancel-session-link {
  text-align: center; font-size: 12px; color: var(--text-muted);
  margin-top: 12px; cursor: pointer; letter-spacing: 0.08em;
}

.pause-row { display: flex; justify-content: center; margin-top: 6px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg-card); border-radius: 10px; padding: 12px; }
.stat-label { font-size: 10px; color: var(--text-secondary); margin: 0 0 6px; }
.stat-value { font-size: 20px; font-weight: 500; margin: 0; }

.goal-pips { display: flex; gap: 6px; margin-bottom: 6px; }
.goal-pip { flex: 1; height: 8px; border-radius: 4px; background: var(--border); }
.goal-pip.done { background: var(--accent); }

.session-card {
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 10px; padding: 14px; margin-bottom: 10px; font-size: 14px;
}
.session-card-left { display: flex; align-items: center; gap: 10px; }
.session-card-icon { font-size: 16px; width: 18px; text-align: center; }
.session-card.complete { background: var(--bg-card-alt); color: var(--text-primary); }
.session-card.complete .session-card-icon { color: var(--accent); }
.session-card.current { background: var(--bg-card); border: 0.5px solid var(--accent); cursor: pointer; }
.session-card.current .session-card-icon { color: var(--accent); }
.session-card.upcoming { background: var(--bg); border: 0.5px solid var(--border); opacity: 0.6; }
.session-card.upcoming .session-card-icon { color: var(--text-muted); }

/* Used on the workout screen's pause/cancel cards - same card shape as
   Home's session list, but icon+label centered instead of left-aligned
   since there's no second element to balance against on the right. */
.session-card.centered { justify-content: center; gap: 10px; }
.session-card.subtle { background: var(--bg); border: 0.5px solid var(--border); color: var(--text-muted); cursor: pointer; }
.session-card.subtle .session-card-icon { color: var(--text-muted); font-size: 13px; }

.week-chart { display: flex; align-items: flex-end; gap: 6px; height: 70px; margin-bottom: 14px; }
.week-bar { flex: 1; background: rgba(255,255,255,0.12); border-radius: 3px; }
.week-bar.done { background: var(--accent); }

/* Calendar view (replaces the old weekly bar chart) */
.calendar-weekday-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}
.calendar-weekday-row span {
  text-align: center; font-size: 10px; color: var(--text-muted);
}
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
}
.calendar-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
}
.calendar-day-ring {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.calendar-day-ring-inner {
  width: 24px; height: 24px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}
.calendar-day.empty { visibility: hidden; }
.calendar-day.future .calendar-day-ring-inner { color: var(--text-muted); }
.calendar-day.today .calendar-day-ring-inner { font-weight: 700; text-decoration: underline; }

/* Settings rows */
.settings-section-label {
  font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); margin: 18px 0 8px;
}
.settings-section-label:first-of-type { margin-top: 0; }
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.settings-row .value { color: var(--text-secondary); font-size: 12px; }
.settings-row.danger { color: var(--danger); border-bottom: none; }

.color-swatch-row { display: flex; gap: 10px; padding: 10px 0; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
}
.color-swatch.selected { border-color: var(--text-primary); }

.voice-select-row { display: flex; gap: 8px; margin-bottom: 4px; }
.voice-option {
  flex: 1; padding: 10px; text-align: center; border-radius: 8px; font-size: 12px;
  border: 0.5px solid var(--border); cursor: pointer; color: var(--text-secondary);
}
.voice-option.selected { border: 2px solid var(--accent); color: var(--text-primary); background: var(--bg-card); }

/* Three items (fitness level) need a touch less padding/font than the
   two-item voice row to comfortably fit "Intermediate" on one line. */
#signup-level-row.voice-select-row .voice-option { padding: 10px 4px; font-size: 11px; }

/* Fixed bottom nav - present on every screen */
.nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around; padding: 12px 0;
  background: var(--bg); border-top: 0.5px solid var(--border);
  max-width: 420px; margin: 0 auto;
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--text-muted); cursor: pointer; }
.nav-item.active { color: var(--accent); }
.nav-icon { width: 22px; height: 22px; }

.icon-badge {
  width: 52px; height: 52px; border-radius: 14px; background: var(--bg-card-alt);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
  font-size: 24px;
}

/* Random Workout picker - a centered popup card over a dimmed backdrop.
   Uses the same --bg-card/--border/--accent theme variables as the rest
   of the app, so it automatically matches whichever accent color is
   currently selected rather than having its own fixed palette. */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 16px;
  padding: 24px 20px; width: 100%; max-width: 380px;
}
.modal-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; color: var(--text-primary); }

/* --- Planner (Home tab) --- */
.planner-card {
  background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 14px;
  padding: 16px;
}
.planner-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 0.5px solid var(--border); }
.planner-tab {
  flex: 1; text-align: center; padding: 10px 0; font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.planner-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.planner-tab-panel { display: none; }
.planner-tab-panel.active { display: block; }
.planner-placeholder-blocks { display: flex; flex-direction: row; gap: 8px; margin-top: 14px; }
.planner-placeholder-blocks .session-card { flex: 1; padding: 10px 6px; font-size: 12px; text-align: center; }

/* Today's upcoming reminders (1, 2, or 3 of them) - whatever count is
   actually there stretches to fill the row evenly, rather than staying
   a fixed small width and leaving empty space on either side. */
#planner-upcoming-list { display: flex; flex-direction: row; gap: 8px; }
#planner-upcoming-list > * { flex: 1; }
#planner-upcoming-list .session-card { padding: 10px 6px; font-size: 12px; text-align: center; }

.planner-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.planner-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.planner-note { font-size: 11px; color: var(--text-muted); margin: 0 0 16px; line-height: 1.4; }
.planner-label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 8px; }

.day-row { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 18px; }
.day-pill {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; border: 1.5px solid var(--border); color: var(--text-muted); cursor: pointer;
}
/* A day with at least one workout scheduled (workoutCount > 0) gets a
   filled accent pill - an unfilled pill means that day is set to None,
   with no reminders at all. This makes which days actually have
   reminders visible at a glance without tapping through each one. */
.day-pill.has-workouts { background: var(--accent); border-color: var(--accent); color: var(--accent-dark); }
.day-pill.editing { border-color: var(--text-primary); }
/* Used only inside the Apply-to-other-days picker, where a filled pill
   means "selected to receive the copy" - a separate meaning from
   .has-workouts above, but the same visual treatment reads fine since
   the two never appear in the same day-row at once. */
.day-pill.selected-for-apply { background: var(--accent); border-color: var(--accent); color: var(--accent-dark); }

/* Hidden until there's an actual unsaved change on the currently-edited
   day (or the notifications toggle) - see renderPlannerCard()'s dirty
   check in app.js. */
.planner-save-row { display: none; gap: 10px; margin-top: 18px; }
.planner-save-row.visible { display: flex; }
.planner-save-row button { flex: 1; width: auto; font-size: 13px; }

.stepper { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.stepper-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 0.5px solid var(--border); background: var(--bg);
  color: var(--text-primary); font-size: 16px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.stepper-value { font-size: 20px; font-weight: 600; min-width: 24px; text-align: center; }
.stepper-cap { font-size: 11px; color: var(--text-muted); }

.time-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip {
  padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 500;
  background: var(--bg); border: 0.5px solid var(--accent); color: var(--text-primary); cursor: pointer;
}

/* --- Time-edit popup: scrollable wheel picker --- */
.wheel-row { display: flex; justify-content: center; gap: 4px; margin-bottom: 22px; position: relative; }
.wheel-col { position: relative; width: 74px; height: 132px; overflow: hidden; }
.wheel-scroll {
  height: 132px; overflow-y: scroll; scroll-snap-type: y mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
}
.wheel-scroll::-webkit-scrollbar { display: none; }
.wheel-pad { height: 44px; }
.wheel-item {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; scroll-snap-align: center;
  color: var(--text-primary); opacity: 0.3; transition: opacity 0.15s, font-size 0.15s;
}
/* Selected (centered) item is full size and full opacity in the accent
   color; the item above and below shrink down rather than just fading,
   so the faded neighbors take up less visual space and the wheel reads
   as tidier at rest. */
.wheel-item.selected { opacity: 1; font-size: 22px; color: var(--accent); }
.wheel-highlight-band {
  position: absolute; top: 44px; left: 0; right: 0; height: 44px;
  border-top: 0.5px solid var(--border); border-bottom: 0.5px solid var(--border);
  pointer-events: none;
}
.wheel-fade-top, .wheel-fade-bottom {
  position: absolute; left: 0; right: 0; height: 44px; pointer-events: none;
}
.wheel-fade-top { top: 0; background: linear-gradient(to bottom, var(--bg-card), transparent); }
.wheel-fade-bottom { bottom: 0; background: linear-gradient(to top, var(--bg-card), transparent); }
.wheel-colon { display: flex; align-items: center; justify-content: center; width: 12px; font-size: 22px; font-weight: 600; color: var(--text-muted); }
.modal-btn-row { display: flex; gap: 10px; }
.modal-btn-row button {
  flex: 1; padding: 11px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none;
  font-family: 'Rajdhani', sans-serif; cursor: pointer;
}
.modal-btn-cancel { background: var(--bg); border: 0.5px solid var(--border) !important; color: var(--text-secondary); }
.modal-btn-save { background: var(--accent); color: var(--accent-dark); }

.feature-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.feature-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.feature-check { color: var(--accent); }

.price-card {
  border: 0.5px solid var(--border); border-radius: 10px; padding: 12px;
  margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.price-card.selected { border: 2px solid var(--accent); background: var(--bg-card); position: relative; }
.price-badge {
  position: absolute; top: -9px; left: 10px; background: var(--accent); color: var(--accent-dark);
  font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 500;
}
.price-name { font-size: 13px; margin: 0 0 2px; }
.price-sub { font-size: 11px; color: var(--text-muted); margin: 0; }
.price-amount { font-size: 14px; font-weight: 500; }

.legal-row { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }
.legal-row span { font-size: 10px; color: var(--text-muted); }

.error-banner {
  background: var(--bg-card); border: 0.5px solid var(--danger); border-radius: 8px;
  padding: 10px; font-size: 12px; color: var(--danger); margin-bottom: 16px; display: none;
}
