/* MTB Coach — main stylesheet
   Aesthetic: industrial/outdoor — dark greens, earth tones, strong type
   Font: Barlow Condensed (display) + DM Sans (body)
*/

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Design tokens ─────────────────────────────────────── */
:root {
  --col-bg:      #0f1710;
  --col-surface: #1a2318;
  --col-card:    #1f2a1d;
  --col-border:  #2e3d2b;
  --col-hover:   #263523;

  --col-primary: #6fba3a;
  --col-primary-dim: #4d8228;
  --col-accent:  #d4a027;
  --col-danger:  #c0392b;
  --col-danger-dim: #922b21;

  --col-text:     #e8eddf;
  --col-muted:    #8a9e80;
  --col-label:    #b0c4a6;

  --radius:  6px;
  --radius-lg: 10px;
  --shadow:  0 2px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 6px 28px rgba(0,0,0,.6);

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --nav-h: 56px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--col-bg);
  color: var(--col-text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--col-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.15;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-wrap {
  padding-top: calc(var(--nav-h) + 2rem);
  padding-bottom: 3rem;
}

/* ── Nav ───────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #111a10;
  border-bottom: 1px solid var(--col-border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.nav-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: .06em;
  color: var(--col-primary);
  text-transform: uppercase;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
}

.nav-logo svg { width: 26px; height: 26px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .15rem;
  margin-left: 1.5rem;
}

.nav-links a {
  color: var(--col-label);
  font-size: .9rem;
  font-weight: 500;
  padding: .35rem .75rem;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--col-text);
  background: var(--col-hover);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.nav-user {
  font-size: .85rem;
  color: var(--col-muted);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--col-text);
  cursor: pointer;
  padding: .4rem;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--col-card);
  border: 1px solid var(--col-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { filter: brightness(.92); }

.btn-primary { background: var(--col-primary); color: #0f1710; }
.btn-secondary { background: var(--col-surface); border: 1px solid var(--col-border); color: var(--col-label); }
.btn-accent { background: var(--col-accent); color: #0f1710; }
.btn-danger { background: var(--col-danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--col-border); color: var(--col-label); }
.btn-ghost:hover { background: var(--col-hover); color: var(--col-text); }

.btn-sm { font-size: .8rem; padding: .35rem .8rem; }
.btn-lg { font-size: 1rem; padding: .7rem 1.5rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--col-label);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: .4rem;
}

.form-control {
  width: 100%;
  background: var(--col-surface);
  border: 1px solid var(--col-border);
  border-radius: var(--radius);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: .95rem;
  padding: .55rem .85rem;
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--col-primary-dim);
  box-shadow: 0 0 0 3px rgba(111,186,58,.12);
}

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.form-hint {
  font-size: .78rem;
  color: var(--col-muted);
  margin-top: .3rem;
}

/* Checkboxes / radio groups */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.check-chip {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.check-chip input { display: none; }

.check-chip label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .75rem;
  border: 1px solid var(--col-border);
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--col-label);
  cursor: pointer;
  transition: all .15s;
  text-transform: none;
  letter-spacing: 0;
}

.check-chip input:checked + label {
  background: var(--col-primary);
  border-color: var(--col-primary);
  color: #0f1710;
}

/* ── Alerts ────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .9rem;
  margin-bottom: 1rem;
}

.alert-success { background: rgba(111,186,58,.12); border: 1px solid rgba(111,186,58,.3); color: #a8e670; }
.alert-error   { background: rgba(192,57,43,.12);  border: 1px solid rgba(192,57,43,.3); color: #e57c70; }
.alert-info    { background: rgba(212,160,39,.12);  border: 1px solid rgba(212,160,39,.3); color: #e8c46a; }

/* ── Badges / tags ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.badge-technique { background: rgba(111,186,58,.15); color: #a8e670; border: 1px solid rgba(111,186,58,.25); }
.badge-location  { background: rgba(212,160,39,.15); color: #e8c46a; border: 1px solid rgba(212,160,39,.25); }
.badge-intensity-easy   { background: rgba(52,152,219,.15); color: #85c4e8; border: 1px solid rgba(52,152,219,.25); }
.badge-intensity-medium { background: rgba(212,160,39,.15); color: #e8c46a; border: 1px solid rgba(212,160,39,.25); }
.badge-intensity-intense { background: rgba(192,57,43,.15); color: #e57c70; border: 1px solid rgba(192,57,43,.25); }
.badge-private { background: rgba(155,89,182,.15); color: #c39bd3; border: 1px solid rgba(155,89,182,.25); }

/* ── Exercise cards grid ───────────────────────────────── */
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.exercise-card {
  background: var(--col-card);
  border: 1px solid var(--col-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  display: flex;
  flex-direction: column;
}

.exercise-card:hover {
  border-color: var(--col-primary-dim);
  transform: translateY(-2px);
}

.exercise-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--col-surface);
}

.exercise-card-image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--col-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--col-muted);
  font-size: 2.5rem;
}

.exercise-card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.exercise-card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.exercise-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .2rem;
}

.exercise-card-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--col-border);
  display: flex;
  gap: .5rem;
  align-items: center;
}

.exercise-card-times {
  font-size: .8rem;
  color: var(--col-muted);
  display: flex;
  gap: .75rem;
}

/* ── Filter bar ────────────────────────────────────────── */
.filter-bar {
  background: var(--col-card);
  border: 1px solid var(--col-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}

.filter-bar select,
.filter-bar input {
  background: var(--col-surface);
  border: 1px solid var(--col-border);
  border-radius: var(--radius);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: .88rem;
  padding: .45rem .8rem;
}

.filter-bar select { cursor: pointer; }

/* ── Tables ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--col-muted);
  padding: .6rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--col-border);
}

.data-table td {
  padding: .65rem .85rem;
  border-bottom: 1px solid rgba(46,61,43,.5);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--col-hover); }

/* ── Session builder ───────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}

.builder-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}

.duration-bar {
  height: 12px;
  border-radius: 99px;
  background: var(--col-surface);
  overflow: hidden;
  margin: .5rem 0;
}

.duration-bar-fill {
  height: 100%;
  background: var(--col-primary);
  border-radius: 99px;
  transition: width .3s;
}

.duration-bar-fill.over-target {
  background: var(--col-danger);
}

.session-exercise-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 60px;
}

.session-exercise-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--col-surface);
  border: 1px solid var(--col-border);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  cursor: grab;
}

.session-exercise-item:active { cursor: grabbing; }
.session-exercise-item.drag-over { border-color: var(--col-primary); }

.drag-handle {
  color: var(--col-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
  cursor: grab;
}

/* ── Mobile execution view ─────────────────────────────── */
.exec-view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 540px;
  margin: 0 auto;
}

.exec-exercise-card {
  background: var(--col-card);
  border: 1px solid var(--col-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.exec-exercise-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.exec-exercise-body {
  padding: 1.25rem;
}

.exec-exercise-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: .5rem;
}

.exec-exercise-desc {
  color: var(--col-label);
  font-size: .95rem;
  margin-bottom: 1rem;
}

.timer-display {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 5rem);
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--col-primary);
  text-align: center;
  margin: 1rem 0;
  line-height: 1;
}

.timer-controls {
  display: flex;
  gap: .75rem;
  justify-content: center;
}

.exec-nav {
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

.exec-progress {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.exec-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--col-border);
  transition: background .2s;
}

.exec-progress-dot.done { background: var(--col-primary); }
.exec-progress-dot.active { background: var(--col-accent); }

/* ── Report view ───────────────────────────────────────── */
.report-chart-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
}

.report-chart-label { width: 160px; font-size: .85rem; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-bar-track { flex: 1; height: 20px; background: var(--col-surface); border-radius: 4px; overflow: hidden; position: relative; }
.report-bar-planned { height: 100%; background: var(--col-primary-dim); border-radius: 4px; }
.report-bar-actual { position: absolute; top: 3px; left: 0; height: 14px; background: var(--col-accent); border-radius: 3px; opacity: .85; }
.report-chart-val { width: 80px; font-size: .8rem; color: var(--col-muted); text-align: right; flex-shrink: 0; }

/* ── Page header ───────────────────────────────────────── */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { flex: 1; }

/* ── Auth pages ────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--col-primary);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

/* ── Utilities ─────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-muted { color: var(--col-muted); }
.text-small { font-size: .85rem; }
.text-right { text-align: right; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--col-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: .95rem; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-direction: column; position: fixed; top: var(--nav-h); left: 0; right: 0; background: #111a10; padding: 1rem; border-bottom: 1px solid var(--col-border); z-index: 99; }
  .nav-toggle { display: block; }

  .builder-layout { grid-template-columns: 1fr; }
  .builder-sidebar { position: static; }

  .exercise-grid { grid-template-columns: 1fr; }

  .filter-bar { flex-direction: column; }
  .filter-bar select,
  .filter-bar input { width: 100%; }

  .page-header { flex-direction: column; align-items: flex-start; gap: .5rem; }

  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: .5rem .6rem; }
}

/* ── Drag-and-drop drop zone ──────────────────────────── */
.drop-zone {
  border: 2px dashed var(--col-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--col-muted);
  font-size: .9rem;
  transition: border-color .2s, background .2s;
}

.drop-zone.drag-over {
  border-color: var(--col-primary);
  background: rgba(111,186,58,.05);
}
