/* ═══════════════════════════════════════
   Workout Tracker — styles.css
   ═══════════════════════════════════════ */

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

:root {
  --g7: #15803d;
  --g6: #16a34a;
  --g5: #22c55e;
  --g4: #4ade80;
  --g1: #dcfce7;
  --g0: #f0fdf4;
  --gr0: #f9fafb;
  --gr1: #f3f4f6;
  --gr2: #e5e7eb;
  --gr3: #d1d5db;
  --gr4: #9ca3af;
  --gr5: #6b7280;
  --gr6: #4b5563;
  --gr8: #1f2937;
  --w: #fff;
  --r5: #ef4444;
  --r0: #fef2f2;
  --blue: #3b82f6;
  --blue1: #dbeafe;
}

body {
  font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
  background: var(--gr0) url('dumbells.png') center center / cover no-repeat fixed;
  color: var(--gr8);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app { max-width: 480px; margin: 0 auto; padding: 20px 16px 100px; background: rgba(249,250,251,0.88); min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--g6); text-decoration: none; }

/* ── Buttons ────────────────────────────── */

.btn { border: none; border-radius: 10px; padding: 12px 20px; font-size: 14px; font-weight: 700; width: 100%; transition: background .15s; }
.btn-green { background: var(--g6); color: var(--w); }
.btn-green:active { background: var(--g7); }
.btn-gray { background: var(--gr1); color: var(--gr6); }
.btn-ghost { background: none; border: none; color: var(--g6); font-size: 14px; font-weight: 600; padding: 4px 0; width: auto; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; border-radius: 8px; }
.btn-danger { background: none; border: none; color: var(--r5); font-size: 12px; font-weight: 600; padding: 4px 8px; width: auto; }

/* ── Header ─────────────────────────────── */

.pg-header { text-align: center; margin-bottom: 24px; padding-top: 16px; }
.pg-header h1 { font-size: 22px; font-weight: 800; letter-spacing: 1px; color: var(--g7); }
.pg-header p { font-size: 13px; color: var(--gr4); margin-top: 4px; }

/* ── Cards ──────────────────────────────── */

.card { background: var(--w); border: 1px solid var(--gr2); border-radius: 12px; padding: 16px 18px; margin-bottom: 10px; cursor: pointer; user-select: none; border-left: 4px solid var(--g5); }
.card:active { box-shadow: 0 0 0 2px #bbf7d0; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card-label { font-weight: 700; font-size: 16px; color: var(--gr8); display: block; }
.card-sub { font-size: 12px; color: var(--gr4); margin-top: 2px; display: block; }
.card-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px; margin-top: 6px; background: var(--g1); color: var(--g7); }
.card-actions { display: flex; gap: 4px; }
.card-actions button { background: none; border: none; font-size: 16px; padding: 4px 6px; color: var(--gr4); }
.card-blue { border-left-color: var(--blue); }
.card-blue .card-tag { background: var(--blue1); color: var(--blue); }

/* ── Top bar ────────────────────────────── */

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar-title { font-size: 18px; font-weight: 800; letter-spacing: 1px; color: var(--gr8); }
.topbar-right { display: flex; gap: 8px; align-items: center; }

/* ── Progress ───────────────────────────── */

.progress-bar { height: 5px; background: var(--gr2); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--g5), var(--g4)); border-radius: 3px; transition: width .3s ease; width: 0%; }
.progress-text { font-size: 12px; color: var(--gr4); margin-bottom: 20px; }

/* ── Warmup ─────────────────────────────── */

.warmup-block { background: var(--w); border: 1px solid var(--gr2); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; cursor: pointer; width: 100%; user-select: none; text-align: left; font-family: inherit; color: inherit; transition: opacity .2s; }
.warmup-block.done { opacity: .5; }
.warmup-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sec-label { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--g6); }
.chk-circle { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--gr3); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--w); font-weight: 700; flex-shrink: 0; }
.chk-circle.on { background: var(--g5); border-color: var(--g5); }
.warmup-item { font-size: 13px; color: var(--gr5); margin: 3px 0; line-height: 1.4; }

/* ── Exercise card (session) ────────────── */

.ex-card { background: var(--w); border: 1px solid var(--gr2); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; transition: opacity .2s; }
.ex-card.all-done { opacity: .5; }
.ex-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.ex-top-left { flex: 1; min-width: 0; }
.ex-name { font-size: 14px; font-weight: 700; color: var(--gr8); display: block; }
.ex-note { font-size: 11px; color: var(--g6); font-weight: 500; margin-top: 2px; display: block; }
.info-btn { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--g5); background: var(--g0); color: var(--g6); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-left: 10px; }

/* ── Set row (logging) ──────────────────── */

.set-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--gr1); }
.set-row:last-child { border-bottom: none; }
.set-label { font-size: 12px; font-weight: 700; color: var(--gr4); min-width: 42px; flex-shrink: 0; }
.set-target { font-size: 11px; color: var(--gr4); min-width: 48px; flex-shrink: 0; }
.set-input { width: 60px; padding: 7px 6px; border: 1.5px solid var(--gr2); border-radius: 6px; font-size: 13px; font-family: inherit; color: var(--gr8); text-align: center; background: var(--gr0); }
.set-input:focus { outline: none; border-color: var(--g5); background: var(--w); }
.set-input::placeholder { color: var(--gr3); font-size: 11px; }
.set-unit { font-size: 11px; color: var(--gr4); flex-shrink: 0; }
.set-check { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--gr2); background: var(--w); color: var(--gr4); font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s; }
.set-check.on { background: var(--g5); border-color: var(--g5); color: var(--w); }

/* ── Tabs ───────────────────────────────── */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--gr1); border-radius: 10px; padding: 3px; }
.tab { flex: 1; padding: 8px; text-align: center; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--gr5); background: none; border: none; transition: all .15s; }
.tab.active { background: var(--w); color: var(--gr8); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Log entries ────────────────────────── */

.log-entry { background: var(--w); border: 1px solid var(--gr2); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.log-entry:active { background: var(--gr0); }
.log-date { font-size: 12px; color: var(--gr4); font-weight: 500; }
.log-name { font-size: 14px; font-weight: 700; color: var(--gr8); }
.log-stats { font-size: 12px; color: var(--g6); font-weight: 600; margin-top: 2px; }
.log-incomplete { color: var(--r5); }

/* ── Detail log ─────────────────────────── */

.detail-ex { margin-bottom: 12px; }
.detail-ex-name { font-size: 13px; font-weight: 700; color: var(--gr8); margin-bottom: 4px; }
.detail-set { font-size: 12px; color: var(--gr5); padding: 2px 0; display: flex; gap: 12px; }
.detail-set .done { color: var(--g6); font-weight: 600; }
.detail-set .missed { color: var(--gr3); }

/* ── Login ──────────────────────────────── */

.login-box { max-width: 320px; margin: 80px auto 0; text-align: center; }
.login-box h1 { font-size: 24px; font-weight: 800; color: var(--g7); margin-bottom: 6px; }
.login-box p { font-size: 13px; color: var(--gr4); margin-bottom: 24px; }
.login-box .form-group { margin-bottom: 14px; text-align: left; }
.login-err { color: var(--r5); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ── Modal ──────────────────────────────── */

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.35); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal { background: var(--w); border-radius: 16px 16px 0 0; padding: 20px 18px 32px; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; animation: slideUp .2s ease; }
.modal h2 { font-size: 17px; font-weight: 800; color: var(--gr8); margin-bottom: 16px; }

/* ── Forms ──────────────────────────────── */

.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gr5); letter-spacing: .5px; margin-bottom: 5px; display: block; }
.form-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--gr2); border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--gr8); background: var(--gr0); transition: border-color .15s; }
.form-input:focus { outline: none; border-color: var(--g5); background: var(--w); }
.form-input::placeholder { color: var(--gr3); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.ex-edit-item { background: var(--gr0); border: 1px solid var(--gr2); border-radius: 10px; padding: 12px; margin-bottom: 8px; position: relative; }
.ex-edit-item .del-btn { position: absolute; top: 8px; right: 8px; background: none; border: none; color: var(--r5); font-size: 18px; padding: 0 4px; line-height: 1; }
.add-ex-btn { width: 100%; padding: 10px; border: 1.5px dashed var(--g5); border-radius: 10px; background: var(--g0); color: var(--g7); font-size: 13px; font-weight: 600; margin-bottom: 16px; font-family: inherit; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions button { flex: 1; }

/* ── Exercise info ──────────────────────── */

.info-title { font-size: 18px; font-weight: 800; color: var(--gr8); margin-bottom: 2px; }
.info-meta { font-size: 12px; color: var(--g6); font-weight: 600; margin-bottom: 14px; }
.info-meta span { display: inline-block; background: var(--g1); padding: 2px 8px; border-radius: 4px; margin: 0 4px 4px 0; }

.anim-viewer { position: relative; width: 100%; max-width: 320px; margin: 0 auto 16px; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; background: var(--gr1); border: 1px solid var(--gr2); }
.anim-viewer img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; background: var(--w); transition: opacity .15s ease; }
.anim-viewer img.hf { opacity: 0; }
.anim-badge { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 4px; pointer-events: none; }

.info-steps { margin-bottom: 16px; }
.info-steps h3 { font-size: 13px; font-weight: 700; color: var(--gr8); margin-bottom: 8px; letter-spacing: .5px; }
.info-step { font-size: 13px; color: var(--gr6); line-height: 1.5; margin-bottom: 8px; padding-left: 22px; position: relative; }
.info-step .sn { position: absolute; left: 0; top: 0; font-weight: 800; color: var(--g5); font-size: 12px; }
.info-close { width: 100%; padding: 12px; background: var(--gr1); border: none; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--gr6); font-family: inherit; }

.info-loading { text-align: center; padding: 40px 0; color: var(--gr4); font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--gr2); border-top-color: var(--g5); border-radius: 50%; animation: spin .6s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.info-empty { font-size: 13px; color: var(--gr4); padding: 20px 0; text-align: center; line-height: 1.5; }

/* ── Dashboard ──────────────────────────── */

.dash-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card { background: var(--w); border: 1px solid var(--gr2); border-radius: 12px; padding: 14px 16px; text-align: center; }
.stat-num { font-size: 28px; font-weight: 800; color: var(--g6); display: block; line-height: 1.2; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--gr4); letter-spacing: 0.5px; margin-top: 4px; display: block; }
.stat-card.wide { grid-column: span 2; }

.dash-section { margin-bottom: 24px; }
.dash-section-title { font-size: 14px; font-weight: 800; color: var(--gr8); margin-bottom: 10px; letter-spacing: 0.5px; }

.chart-container { background: var(--w); border: 1px solid var(--gr2); border-radius: 12px; padding: 16px; margin-bottom: 12px; overflow-x: auto; }
.chart-label { font-size: 12px; font-weight: 700; color: var(--gr6); margin-bottom: 8px; }
.chart-canvas { width: 100%; height: 180px; display: block; }

.pb-list { display: flex; flex-direction: column; gap: 6px; }
.pb-item { background: var(--w); border: 1px solid var(--gr2); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.pb-name { font-size: 13px; font-weight: 600; color: var(--gr8); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-val { font-size: 14px; font-weight: 800; color: var(--g6); flex-shrink: 0; margin-left: 10px; }
.pb-reps { font-size: 11px; color: var(--gr4); margin-left: 4px; font-weight: 500; }

.ex-select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--gr2); border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--gr8); background: var(--gr0); margin-bottom: 12px; }
.ex-select:focus { outline: none; border-color: var(--g5); }

/* ── Autocomplete ───────────────────────── */

.ac-wrap { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--w); border: 1.5px solid var(--gr2); border-top: none; border-radius: 0 0 8px 8px; max-height: 200px; overflow-y: auto; z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.ac-item { padding: 10px 12px; font-size: 13px; color: var(--gr8); cursor: pointer; border-bottom: 1px solid var(--gr1); }
.ac-item:last-child { border-bottom: none; }
.ac-item:active, .ac-item:hover { background: var(--g0); }
.ac-item .ac-muscles { font-size: 11px; color: var(--gr4); margin-top: 2px; }

/* ── Utility ────────────────────────────── */

.hidden { display: none; }
