/* ========================================
   DAS JONES // PROTOCOL — Phase 1
   Color System: Black / Blue / Red
   ======================================== */

:root {
  /* Core palette */
  --bg: #050510;
  --surface: #0a0a1a;
  --surface2: #10102a;
  --surface3: #161638;
  --border: #1a1a3a;

  /* Blue accents */
  --blue: #3b82f6;
  --blue-dim: #1e3a5f;
  --blue-glow: rgba(59, 130, 246, 0.15);
  --blue-bright: #60a5fa;

  /* Red accents (used sparingly) */
  --red: #ef4444;
  --red-dim: #5f1a1a;
  --red-glow: rgba(239, 68, 68, 0.12);

  /* Text */
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #475569;

  /* Status */
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;

  /* Typography */
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-body: 'DM Sans', sans-serif;

  /* Spacing */
  --gap: 12px;
  --radius: 10px;
  --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ========== HEADER ========== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--text);
}

.logo span { color: var(--blue); }

.header-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ========== NAV TABS ========== */
nav {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 -16px;
  padding: 0 16px;
}

nav::-webkit-scrollbar { display: none; }

.nav-tab {
  flex: none;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.nav-tab:hover { color: var(--text-dim); }

.nav-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ========== MAIN CONTENT ========== */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

.page { display: none; }
.page.active { display: block; }

/* ========== CARDS ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
}

.card-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ========== STAT GRID ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text);
  line-height: 1;
}

.stat-value.blue { color: var(--blue); }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }

.stat-unit {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ========== INPUTS ========== */
.input-group {
  margin-bottom: 14px;
}

.input-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

input[type="number"],
input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-glow);
}

textarea { resize: vertical; min-height: 60px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover { background: var(--blue-bright); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--text);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}

.btn-full { width: 100%; }



/* ========== EXERCISE BUTTONS ========== */
.exercise-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ex-btn {
  padding: 10px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ex-btn.active {
  border-color: var(--blue);
  background: var(--blue-glow);
  color: var(--blue);
}

/* ========== SLIDER ========== */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-wrap input[type="range"] {
  flex: 1;
  appearance: none;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.slider-val {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--blue);
  min-width: 28px;
  text-align: center;
}

/* ========== SUPPLEMENTS ========== */
.supp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.supp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.supp-check {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 12px;
}

.supp-item.active .supp-check {
  background: var(--blue);
  border-color: var(--blue);
}

.supp-info {
  flex: 1;
  min-width: 0;
}

.supp-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supp-dose {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

/* ========== GYM PAGE ========== */
.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.session-timer {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--blue);
}

.exercise-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}

.exercise-name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 4px;
}

.exercise-target {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 6px 0;
}

.set-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 28px;
  flex-shrink: 0;
}

.set-row input {
  width: 48px;
  padding: 6px 8px;
  font-size: 14px;
  text-align: center;
}

/* Weight input with +/- buttons */
.weight-input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.weight-input-wrap input[type="number"] {
  width: 48px;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  text-align: center;
  box-shadow: none;
}

.weight-input-wrap input[type="number"]:focus {
  box-shadow: none;
  border-color: transparent;
}

.weight-adj-btn {
  width: 26px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.1s;
  user-select: none;
}

.weight-adj-btn:active {
  background: var(--blue-glow);
  color: var(--blue);
}

.set-row .rir-btns {
  display: flex;
  gap: 3px;
}

.rir-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
}

.rir-btn.active {
  background: var(--blue-glow);
  border-color: var(--blue);
  color: var(--blue);
}

.set-logged {
  opacity: 0.5;
}

.set-logged input { color: var(--text-dim); }

.log-set-btn {
  padding: 6px 14px;
  font-size: 10px;
}

/* Nutrition quality toggle buttons (supps / processed foods) */
.nut-q-btn {
  flex: 1;
  padding: 9px 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.nut-q-btn:active {
  opacity: 0.7;
}

.nut-q-btn.active {
  background: var(--blue-glow);
  border-color: var(--blue);
  color: var(--blue);
}

/* Rest timer */
.rest-timer {
  display: none;
  text-align: center;
  padding: 20px;
  background: var(--surface2);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.rest-timer.active { display: block; }

.rest-time {
  font-family: var(--font-display);
  font-size: 52px;
  color: var(--blue);
  line-height: 1;
}

.rest-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

.rest-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

/* PR indicator */
.pr-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
}

/* e1RM display */
.e1rm-display {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.e1rm-display .val { color: var(--blue-bright); }

/* ========== SESSION HISTORY ========== */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.history-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.history-type {
  font-weight: 600;
  font-size: 13px;
}

.history-stats {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
}

/* ========== DASHBOARD ========== */
.big-stat {
  text-align: center;
  padding: 20px;
}

.big-stat-value {
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--blue);
  line-height: 1;
}

.big-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 4px;
}

/* ========== CHARTS ========== */
.chart-container {
  width: 100%;
  height: 160px;
  position: relative;
  margin-top: 8px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
  padding-bottom: 20px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  min-height: 2px;
  background: var(--blue);
  border-radius: 2px 2px 0 0;
  transition: height 0.3s;
  position: relative;
}

.bar:hover { opacity: 0.8; }

.bar-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-muted);
}

/* ========== ACTIVITY CALENDAR ========== */
.cal-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.cal-cells {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 2px;
}

.cal-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.cal-cell:hover { opacity: 0.65 !important; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.cal-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cal-stat { text-align: center; }

.cal-stat-num {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--blue);
  line-height: 1;
}

.cal-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}

.day-tooltip {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  z-index: 500;
  max-width: 280px;
  width: 90%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.day-tooltip.show { opacity: 1; }

/* ========== PR TABLE ========== */
.pr-table {
  width: 100%;
  border-collapse: collapse;
}

.pr-table th {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pr-table td {
  padding: 8px 6px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.pr-table .lift-name { color: var(--blue); font-weight: 600; }
.pr-table .pr-val { font-family: var(--font-display); font-size: 18px; }


/* ========== ZONE DISPLAY ========== */
.zone-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.zone-bar .z1 { background: #94a3b8; }
.zone-bar .z2 { background: var(--blue); }
.zone-bar .z3 { background: var(--green); }
.zone-bar .z4 { background: var(--orange); }
.zone-bar .z5 { background: var(--red); }

.zone-legend {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 20px;
  z-index: 999;
  transition: transform 0.3s;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .supp-grid { grid-template-columns: 1fr; }
  .exercise-row { grid-template-columns: repeat(2, 1fr); }
}
