/* Workout Tracker - app.css
   Palette/tokens ported from the "beer" app's look and feel:
   near-neutral slate dark theme with a warm amber accent, plus a
   light theme toggle. Category colors (success/warn/flag/never) are
   reused here to color-code exercise/day types instead of overdue levels. */

:root {
  --bg:         #1a1c1e;
  --panel:      #23262a;
  --panel-2:    #2c3036;
  --border:     #363b42;
  --text:       #d8dde3;
  --text-dim:   #7a8390;
  --text-faint: #4a5260;
  --accent:     #c8a96e;
  --accent-dim: #8a7248;
  --accent-contrast: #1a1410;
  --accent-tint:      #231f14;
  --accent-2:   #90c890;

  --danger:         #e88080;
  --danger-border:  #5a2828;
  --danger-bg:      #7a2828;
  --danger-bg-hover:#8a3030;
  --danger-contrast:#f0c0c0;

  --success-bg:   #182218;
  --success-line: #2a4a2a;
  --success-text: #90c890;

  --warn-bg:   #272318;
  --warn-line: #6b5a2a;
  --flag-bg:   #291e18;
  --flag-line: #7a4020;
  --never-bg:  #1e2228;
  --never-line:#3a4a60;

  --radius: 6px;
  --bottom-nav-h: 60px;
}

/* -- Light theme overrides -- */
[data-theme="light"] {
  --bg:         #f7f6f3;
  --panel:      #ffffff;
  --panel-2:    #ececea;
  --border:     #ddd9d2;
  --text:       #2a2a28;
  --text-dim:   #6b6862;
  --text-faint: #9c988f;
  --accent:     #9c7a3c;
  --accent-dim: #c8a96e;
  --accent-contrast: #fdf8ee;
  --accent-tint:      #f3e9d3;
  --accent-2:   #2a7a2a;

  --danger:         #b03030;
  --danger-border:  #e0b0b0;
  --danger-bg:      #c84040;
  --danger-bg-hover:#b03030;
  --danger-contrast:#ffffff;

  --success-bg:   #e3f3e3;
  --success-line: #8ac08a;
  --success-text: #2a7a2a;

  --warn-bg:   #fbf3df;
  --warn-line: #c9a23a;
  --flag-bg:   #fbe9df;
  --flag-line: #c46a30;
  --never-bg:  #e9eef6;
  --never-line:#5878a8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

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

/* Smooth theme-switch transition, matching the reference app */
body, .topbar, .btn, .card, .exercise-block, table, input, select, textarea, .bottom-nav {
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--text-dim); font-size: 0.85rem; padding: 4px 2px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--accent); font-weight: 600; text-decoration: none; }

#theme-toggle { margin-left: auto; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table-scroll table { width: auto; min-width: 100%; }
.table-scroll th, .table-scroll td { white-space: nowrap; }

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 8px; color: var(--text-dim); }
.subtitle { color: var(--text-dim); margin-bottom: 20px; }

.flash {
  background: rgba(144, 200, 144, 0.12);
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* Category-coded left border, ported from the reference app's
   "overdue level" rows - here used for day/exercise type instead. */
.day-strength { border-left-color: var(--accent-dim); }
.day-cardio   { background: var(--success-bg); border-left-color: var(--success-line); }
.day-mixed    { background: var(--flag-bg);    border-left-color: var(--flag-line); }
.day-rest     { background: var(--never-bg);   border-left-color: var(--never-line); }

.card-list { display: flex; flex-direction: column; gap: 12px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; }

.muted { color: var(--text-dim); }
.small { font-size: 0.85rem; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge-strength { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-tint); }
.badge-cardio   { color: var(--success-text); border-color: var(--success-line); background: var(--success-bg); }
.badge-rest     { color: var(--text-dim); border-color: var(--border); background: var(--panel-2); }
.badge-mixed    { color: var(--flag-line); border-color: var(--flag-line); background: var(--flag-bg); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--text-dim); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }

form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
label { font-size: 0.8rem; color: var(--text-dim); }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 10px;
  color: var(--text);
  /* 16px minimum keeps iOS Safari from auto-zooming into the field on focus */
  font-size: 16px;
  font-family: inherit;
  width: 100%;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
textarea { min-height: 60px; resize: vertical; }
input[type="checkbox"] { width: auto; min-height: auto; accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 42px;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn:active { opacity: 0.75; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-danger { background: transparent; border: 1px solid var(--danger-border); color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 0.78rem; min-height: 36px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.theme-toggle { line-height: 1; }
.theme-icon { display: none; font-size: 0.95rem; }
.theme-icon-dark  { display: inline; }
.theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark  { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

.inline-form { display: inline; }

.set-row { display: grid; grid-template-columns: 22px 1.3fr 1fr 0.8fr 40px; gap: 6px; align-items: center; }
.set-row .set-num { color: var(--text-dim); font-size: 0.85rem; }
.set-row .remove-set { padding: 8px 0; min-height: 44px; }

.exercise-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--panel-2); margin-bottom: 12px; }
.exercise-block h3 { margin-top: 0; color: var(--text); }

.empty-state { color: var(--text-dim); font-style: italic; padding: 20px 0; }

.cycle-day { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cycle-day:last-child { border-bottom: none; }
.cycle-pos { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-dim); flex-shrink: 0; }

/* Bottom tab bar: hidden on wide screens, shown fixed-to-bottom on phones */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--bottom-nav-h);
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px 6px;
  color: var(--text-dim);
  font-size: 0.68rem;
  min-height: 52px;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--accent); font-weight: 600; text-decoration: none; }

@media (max-width: 720px) {
  .topbar .top-nav { display: none; }
  .bottom-nav { display: flex; }
  .container { padding-bottom: calc(var(--bottom-nav-h) + 10px + env(safe-area-inset-bottom, 0)); }
}

@media (max-width: 600px) {
  .set-row { grid-template-columns: 20px 1.3fr 1fr 0.8fr 40px; gap: 5px; }
  .topbar-inner { padding: 12px; }
}

@media (max-width: 360px) {
  .bottom-nav a span { font-size: 0.62rem; }
}
