/* ============================================================
   styles.css — Tema oscuro, mobile-first
   ============================================================ */

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --border: #2a2f3a;
  --text: #eef0f4;
  --text-dim: #9aa0ac;
  --accent: #ff6a3d;
  --accent-2: #3d8de0;
  --green: #5fbf6f;
  --yellow: #e0c23d;
  --red: #e05a5a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}

button {
  cursor: pointer;
  border: none;
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  transition: transform .08s ease, background .15s ease;
}
button:active { transform: scale(0.96); }

input, select, textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; }
p { margin: 0 0 8px; color: var(--text-dim); }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe-bottom));
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15,17,21,0.92);
  backdrop-filter: blur(8px);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.app-header .title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { font-size: 1.25rem; }
.app-header .subtitle { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.header-btn {
  background: var(--bg-elev-2);
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

/* ---------- Views ---------- */
.view { padding: 14px 16px 24px; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform:none; } }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
}
.card + .card { margin-top: 0; }
.card-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.card-title-row h3 { margin: 0; font-size: 1rem; }

.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.stat-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.stat-box .val { font-size: 1.3rem; font-weight: 700; }
.stat-box .lbl { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff8a5c);
  color: #1a0d06;
  font-weight: 700;
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(255,106,61,0.28);
}
.btn-secondary {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  width: 100%;
  padding: 12px;
  border-radius: 12px;
}
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger { background: var(--red); color: #2a0a0a; font-weight: 700; }
.btn-small { padding: 6px 10px; font-size: 0.85rem; border-radius: 8px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 0.78rem; color: var(--text-dim); }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: 8px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  background: rgba(23,26,33,0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.nav-btn {
  background: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 8px;
  color: var(--text-dim);
  flex: 1;
  border-radius: 10px;
}
.nav-btn .ic { font-size: 1.25rem; }
.nav-btn .lbl { font-size: 0.65rem; font-weight: 600; }
.nav-btn.active { color: var(--accent); background: rgba(255,106,61,0.12); }

/* ---------- Rest timer widget ---------- */
.rest-widget { position: fixed; right: 14px; bottom: calc(76px + var(--safe-bottom)); z-index: 40; }
.rest-fab {
  background: linear-gradient(135deg, var(--accent), #ff8a5c);
  color: #1a0d06;
  border-radius: 999px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 6px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.rest-fab.active { background: var(--green); }
.rest-fab.done-flash { animation: flash .3s ease 4; }
@keyframes flash { 0%,100% { transform: scale(1);} 50% { transform: scale(1.15);} }
.rest-fab-icon { font-size: 1.1rem; }

.rest-panel {
  position: absolute;
  bottom: 62px; right: 0;
  width: min(280px, calc(100vw - 28px));
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: none;
}
.rest-panel.open { display: block; }
.rest-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; color: var(--text-dim); margin-bottom: 8px;
}
.icon-btn { background: none; padding: 4px 8px; color: var(--text-dim); border-radius: 8px; }
.icon-btn:active { background: var(--bg-elev-2); }
.rest-display {
  font-size: 2.6rem; font-weight: 800; text-align: center;
  margin: 6px 0 12px; font-variant-numeric: tabular-nums;
}
.rest-presets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px;
}
.rest-presets button { background: var(--bg-elev-2); padding: 10px 0; }
.rest-custom { display: flex; gap: 6px; margin-bottom: 6px; }
.rest-custom input { flex: 1; }
.rest-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rest-controls button { padding: 10px 4px; font-size: 0.85rem; min-width: 0; }
.rest-controls .danger { background: var(--red); color: #2a0a0a; }

/* ---------- Calendar (plan mensual) ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow { text-align: center; font-size: 0.7rem; color: var(--text-dim); padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--bg-elev-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.78rem;
  gap: 2px;
  position: relative;
  border: 1px solid transparent;
}
.cal-day.today { border-color: var(--accent); }
.cal-day .dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-day.empty { background: none; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--text-dim); }
.cal-legend-item .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Sets / workout log ---------- */
.set-row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
}
.set-row .set-num { color: var(--text-dim); font-size: 0.85rem; text-align: center; }
.felt-select { display: flex; gap: 4px; }
.felt-btn {
  flex: 1; padding: 8px 0; text-align: center; border-radius: 8px;
  background: var(--bg-elev-2); font-size: 1.1rem;
}
.felt-btn.selected { background: linear-gradient(135deg, var(--accent), #ff8a5c); }
.exercise-card .ex-header { display: flex; justify-content: space-between; align-items: center; }
.exercise-card .ex-target { font-size: 0.78rem; color: var(--text-dim); }

/* ---------- Meal groups (calorías) ---------- */
.meal-group { margin-bottom: 14px; }
.meal-group h4 { display: flex; justify-content: space-between; font-size: 0.9rem; }
.macro-bar { height: 8px; border-radius: 6px; background: var(--bg-elev-2); overflow: hidden; margin: 4px 0 2px; }
.macro-bar-fill { height: 100%; }

/* ---------- Progress chart (medidas) ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
canvas.chart { width: 100%; height: 160px; display: block; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.modal-sheet {
  background: var(--bg-elev);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  width: 100%; max-width: 560px;
  max-height: 86vh; overflow-y: auto;
  animation: sheetup .2s ease;
}
@keyframes sheetup { from { transform: translateY(30px); opacity: 0; } to { transform:none; opacity:1; } }
.modal-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* ---------- Toasts ---------- */
.toast-holder {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center;
  width: 100%; padding: 0 16px; pointer-events: none;
}
.toast {
  background: #23262f; border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 10px; font-size: 0.85rem;
  opacity: 0; transform: translateY(-8px);
  transition: opacity .25s ease, transform .25s ease;
  max-width: 480px; text-align: center;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- Group colors ---------- */
.grp-pecho { color: #e0663d; } .grp-espalda { color: #3d8de0; } .grp-pierna { color: #5fbf6f; }
.grp-hombro { color: #e0c23d; } .grp-brazo { color: #c26fe0; } .grp-core { color: #e0e0e0; }
.grp-cardio { color: #e05a5a; } .grp-otro { color: #9aa0ac; } .grp-movilidad { color: #3de0c2; }

.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.mt-8 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.small { font-size: 0.8rem; }
.link-btn { background: none; color: var(--accent-2); padding: 4px; }
