/* ============================================================================
   fitnotes — full style sheet (extracted from dieta.html)
   ============================================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #F5F4EF; color: #1A1A1A; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }
body { padding-bottom: 80px; min-height: 100vh; }

/* Main area switcher (Dieta vs Treino) */
/* ----------------------------------------------------------------------------
   Area switch + Header + Tabs — bloco fixo no topo respeitando safe-area iOS
   Fix de 2026-04-23: status bar do iOS (black-translucent) estava sobrepondo
   o título. Agora o area-switch absorve o safe-area-inset-top e o header
   + tabs não usam sticky com top hardcoded.
   ---------------------------------------------------------------------------- */
.area-switch {
  display: flex;
  background: #0F6E56;
  /* max() garante um padding mínimo de 44px mesmo se safe-area-inset-top = 0.
     Isso cobre: iPhone com notch (safe-area ~47-59), iPhone sem notch (0 → usa 44),
     Android sem cutout (0 → usa 44), Safari em PWA mode (respeita safe-area).
     Os 44px cobrem a altura típica da status bar do iOS quando black-translucent. */
  padding: max(env(safe-area-inset-top, 0px), 44px) 12px 0;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 110;
}
.area-btn { flex: 1; padding: 10px 12px; border: none; background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.7); border-radius: 10px 10px 0 0; font-size: 14px; font-weight: 600; }
.area-btn.active { background: white; color: #0F6E56; }

/* Header per-area — NÃO mais sticky. Rola com a página, como um card principal. */
.header {
  background: #0F6E56;
  color: white;
  padding: 12px 16px 16px;
  position: sticky;
  top: 44px; /* abaixo do area-switch aproximadamente — recalculado via JS abaixo */
  z-index: 100;
}
.header.treino { background: #1A5490; }
.area-switch.treino { background: #1A5490; }
.header h1 { margin: 0; font-size: 17px; font-weight: 600; }
.header .subtitle { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.date-nav button { background: rgba(255,255,255,0.15); border: none; color: white; width: 36px; height: 36px; border-radius: 8px; font-size: 18px; min-width: 36px; }
.date-nav .current-date { font-size: 14px; font-weight: 500; }

/* Tabs — sticky abaixo do header. Top setado dinamicamente via CSS var. */
.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid #E5E3DB;
  position: sticky;
  top: var(--tabs-sticky-top, 180px); /* fallback aproximado; JS recalcula */
  z-index: 90;
  overflow-x: auto;
}
.tab { flex: 1; min-width: 70px; padding: 12px 4px; text-align: center; font-size: 12px; font-weight: 500; color: #888780; border: none; background: transparent; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: #0F6E56; border-bottom-color: #0F6E56; }
.tab.treino.active { color: #1A5490; border-bottom-color: #1A5490; }

.content { padding: 16px; }
.hidden { display: none !important; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-card { background: white; padding: 12px; border-radius: 10px; border: 0.5px solid #E5E3DB; }
.stat-label { font-size: 11px; color: #888780; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-value { font-size: 20px; font-weight: 600; margin-top: 2px; }
.stat-target { font-size: 11px; color: #888780; margin-top: 2px; }
.stat-progress { height: 4px; background: #E5E3DB; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.stat-bar { height: 100%; background: #0F6E56; transition: width 0.3s; }
.stat-bar.treino { background: #1A5490; }
.stat-bar.over { background: #D85A30; }

.meal, .workout { background: white; border-radius: 12px; border: 0.5px solid #E5E3DB; margin-bottom: 12px; overflow: hidden; }
.meal-header, .workout-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; cursor: pointer; }
.meal-title, .workout-title { font-size: 15px; font-weight: 600; }
.meal-subtitle, .workout-subtitle { font-size: 12px; color: #888780; margin-top: 2px; }
.meal-check { width: 26px; height: 26px; border: 2px solid #D3D1C7; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.meal-check.done { background: #0F6E56; border-color: #0F6E56; }
.meal-check.done.treino { background: #1A5490; border-color: #1A5490; }
.meal-check.done::after { content: "✓"; color: white; font-weight: bold; font-size: 14px; }
.meal-body, .workout-body { padding: 0 16px 14px; border-top: 0.5px solid #E5E3DB; background: #FAFAF7; }
.meal-body.collapsed, .workout-body.collapsed { display: none; }

.food-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 0.5px solid #EEECE4; }
.food-item:last-child { border-bottom: none; }
.food-name { font-size: 14px; flex: 1; }
.food-qty { font-size: 12px; color: #888780; }
.food-check { width: 22px; height: 22px; border: 2px solid #D3D1C7; border-radius: 6px; margin-right: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.food-check.done { background: #0F6E56; border-color: #0F6E56; }
.food-check.done::after { content: "✓"; color: white; font-size: 12px; font-weight: bold; }

.option-tabs { display: flex; gap: 6px; padding: 10px 0 0; }
.option-tab { flex: 1; padding: 8px 4px; text-align: center; font-size: 12px; border: 0.5px solid #D3D1C7; border-radius: 6px; background: white; font-weight: 500; }
.option-tab.active { background: #0F6E56; color: white; border-color: #0F6E56; }

.sub-select { width: 100%; padding: 8px; border: 0.5px solid #D3D1C7; border-radius: 6px; background: white; font-size: 13px; margin-top: 4px; color: #1A1A1A; }

.exercise { padding: 12px 0; border-bottom: 0.5px solid #EEECE4; }
.exercise:last-child { border-bottom: none; }
.exercise-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exercise-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.exercise-prescription { font-size: 12px; color: #888780; margin-top: 2px; }

/* Botão "▶ Ver vídeo" — discreto, azul do design system de treino */
.video-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #E6F1FB;
  color: #0C447C;
  border: 1px solid #B4D4F1;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: rgba(12,68,124,0.15);
  min-height: 32px;
}
.video-link:active { background: #D4E6F7; }
.exercise-prev { font-size: 11px; color: #0C447C; margin-top: 4px; background: #E6F1FB; padding: 4px 8px; border-radius: 4px; display: inline-block; }
/* Sets grid — WCAG AAA touch targets (44×44) + iOS-safe font (16px evita auto-zoom) */
.sets-grid { display: grid; grid-template-columns: 28px 1fr 1fr 44px; gap: 8px; margin-top: 10px; align-items: stretch; }
.sets-header { font-size: 10px; color: #888780; text-transform: uppercase; letter-spacing: 0.3px; text-align: center; font-weight: 600; align-self: center; }
.set-num { text-align: center; font-size: 13px; color: #888780; font-weight: 600; align-self: center; }

/* Stepper (− input +) — agrupa botões e input em um único touch-friendly cluster */
.stepper { display: flex; align-items: stretch; gap: 0; min-height: 44px; }
.stepper button {
  width: 36px; min-height: 44px;
  background: #F1EFE8; border: 0.5px solid #D3D1C7; color: #444441;
  font-size: 20px; font-weight: 600; line-height: 1;
  cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: rgba(26,84,144,0.2);
}
.stepper button:active { background: #E5E3DB; }
.stepper button.step-minus { border-radius: 8px 0 0 8px; border-right: none; }
.stepper button.step-plus  { border-radius: 0 8px 8px 0; border-left: none; }
.stepper .set-input { flex: 1; border-radius: 0; min-width: 0; }

.set-input {
  width: 100%; min-height: 44px; padding: 8px 4px;
  border: 0.5px solid #D3D1C7; border-radius: 8px;
  font-size: 16px; /* CRÍTICO: 16px evita auto-zoom em iOS ao focar */
  text-align: center; background: white; color: #1A1A1A; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.set-input:focus { outline: none; border-color: #1A5490; box-shadow: 0 0 0 2px rgba(26,84,144,0.15); }
/* Valor sugerido (autofill da última vez) aparece em cinza; ao interagir, escurece */
.set-input.suggested { color: #B4B2A9; }

/* Feedback visual quando usuário tenta marcar done sem reps (Melhoria #1) */
@keyframes shake-invalid-anim {
  0%, 100% { transform: translateX(0); border-color: #D3D1C7; }
  15%, 45%, 75% { transform: translateX(-6px); border-color: #D85A30; }
  30%, 60%, 90% { transform: translateX(6px); border-color: #D85A30; }
}
.set-input.shake-invalid {
  animation: shake-invalid-anim 0.5s ease-in-out;
  background: #FDECE5;
}

.set-check {
  width: 44px; height: 44px; min-width: 44px;
  border: 2px solid #D3D1C7; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; cursor: pointer;
  -webkit-tap-highlight-color: rgba(26,84,144,0.2);
}
.set-check:active { background: #EEECE4; }
.set-check.done { background: #1A5490; border-color: #1A5490; }
.set-check.done:active { background: #154775; }
.set-check.done::after { content: "✓"; color: white; font-size: 20px; font-weight: bold; }

/* Quick Log — "registrar todas as séries" em 1 toque */
.quick-log-btn {
  display: block; width: 100%; min-height: 44px;
  padding: 12px; margin: 10px 0;
  background: #E6F1FB; color: #0C447C;
  border: 1px solid #B4D4F1; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(12,68,124,0.15);
}
.quick-log-btn:active { background: #D4E6F7; }
.quick-log-btn.subtle { background: transparent; color: #0C447C; border-color: #D3D1C7; }

.timer-btn { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; min-height: 44px; padding: 10px 14px; background: #F1EFE8; border: 0.5px solid #D3D1C7; border-radius: 8px; font-size: 13px; color: #444441; font-weight: 600; cursor: pointer; width: 100%; }
.timer-btn:active { background: #E5E3DB; }

.workout-switch { display: flex; gap: 6px; margin-bottom: 10px; padding-top: 10px; }
.workout-switch button { flex: 1; padding: 10px; border: 0.5px solid #D3D1C7; border-radius: 8px; background: white; font-size: 13px; font-weight: 500; }
.workout-switch button.active { background: #1A5490; color: white; border-color: #1A5490; }
.workout-switch button.rest.active { background: #888780; border-color: #888780; }

.history-day { background: white; padding: 12px 14px; border-radius: 10px; border: 0.5px solid #E5E3DB; margin-bottom: 8px; }
.history-row { display: flex; justify-content: space-between; align-items: center; }
.history-date { font-size: 13px; font-weight: 500; }
.history-stats { font-size: 12px; color: #888780; }
.history-meals { margin-top: 8px; display: flex; gap: 4px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #E5E3DB; }
.dot.done { background: #0F6E56; }
.workout-badge { font-size: 10px; padding: 3px 8px; border-radius: 4px; background: #F1EFE8; color: #444441; font-weight: 600; }
.workout-badge.A { background: #E6F1FB; color: #0C447C; }
.workout-badge.B { background: #FAEEDA; color: #633806; }
.workout-badge.done-full { background: #1A5490; color: white; }

.chart-card { background: white; padding: 12px 14px; border-radius: 10px; border: 0.5px solid #E5E3DB; margin-bottom: 8px; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.chart-subtitle { font-size: 11px; color: #888780; margin-bottom: 10px; }
.chart-svg { width: 100%; height: 80px; }

.shop-section { background: white; border-radius: 12px; border: 0.5px solid #E5E3DB; margin-bottom: 12px; overflow: hidden; }
.shop-header { padding: 12px 16px; font-size: 14px; font-weight: 600; background: #FAFAF7; border-bottom: 0.5px solid #E5E3DB; }
.shop-item { display: flex; align-items: center; padding: 10px 16px; border-bottom: 0.5px solid #EEECE4; }
.shop-item:last-child { border-bottom: none; }
.shop-item.done .shop-name { text-decoration: line-through; color: #B4B2A9; }

.btn { display: block; width: 100%; padding: 12px; background: #0F6E56; color: white; border: none; border-radius: 10px; font-size: 14px; font-weight: 500; margin-top: 12px; }
.btn-ghost { background: transparent; color: #0F6E56; border: 1px solid #0F6E56; }
.btn-danger { background: transparent; color: #D85A30; border: 1px solid #D85A30; }

.info { background: #E1F5EE; color: #04342C; padding: 10px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 12px; line-height: 1.5; }
.info.treino { background: #E6F1FB; color: #042C53; }
.section-title { font-size: 13px; font-weight: 600; color: #888780; text-transform: uppercase; letter-spacing: 0.5px; margin: 20px 0 8px; padding: 0 4px; }
.exercise-select { background: white; border: 0.5px solid #D3D1C7; padding: 10px; border-radius: 8px; width: 100%; font-size: 14px; margin-bottom: 12px; color: #1A1A1A; }

.rest-hero { background: white; padding: 24px 16px; border-radius: 12px; border: 0.5px solid #E5E3DB; text-align: center; margin-bottom: 12px; }
.rest-hero h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; color: #1A5490; }
.rest-hero p { margin: 0; font-size: 13px; color: #888780; }

.floating-timer-container { position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 200; pointer-events: none; transition: all 0.2s ease; }
.floating-timer-container.minimized { left: auto; right: 12px; bottom: 12px; }
.floating-timer { background: #D85A30; color: white; padding: 14px 16px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto; transition: all 0.2s ease; }
.floating-timer-container.minimized .floating-timer { padding: 10px 14px; border-radius: 24px; }
.floating-timer-container.minimized .floating-timer .label { display: none; }
.floating-timer-container.minimized .floating-timer .time { font-size: 16px; }
.floating-timer-container.minimized .floating-timer .timer-actions button.btn-add { display: none; }
.floating-timer .time { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.floating-timer button { background: rgba(255,255,255,0.25); border: none; color: white; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-left: 4px; min-height: 36px; }
.floating-timer button:active { background: rgba(255,255,255,0.35); }
.timer-actions { display: flex; gap: 4px; align-items: center; }

/* ============================================================================
   Offline banner (Story 5.4)
   ============================================================================ */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #D85A30;
  color: white;
  text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
