/* FitMini — Shared Components */

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  padding: var(--sp-12) var(--sp-20);
  border-radius: var(--r-full);
  font-size: var(--fz-md);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn-primary   { background: var(--c-accent); color: var(--tg-button-text); }
.btn-secondary { background: var(--c-bg-2); color: var(--c-text); }
.btn-green     { background: var(--c-green); color: #fff; }
.btn-danger    { background: var(--c-red); color: #fff; }
.btn-ghost     { background: transparent; color: var(--c-accent); }
.btn-outline   { background: transparent; color: var(--c-accent); border: 1.5px solid var(--c-accent); }

.btn-sm { padding: var(--sp-6) var(--sp-12); font-size: var(--fz-sm); }
.btn-lg { padding: var(--sp-16) var(--sp-24); font-size: var(--fz-lg); }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.4; pointer-events: none; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--c-bg-card);
  border-radius: var(--r-lg);
  padding: var(--sp-16);
  box-shadow: var(--shadow-card);
}
.card-sm { padding: var(--sp-12); border-radius: var(--r-md); }
.card-flat { box-shadow: none; border: 1px solid var(--c-border); }

/* ── Chips ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-10);
  border-radius: var(--r-full);
  font-size: var(--fz-sm);
  font-weight: 500;
  background: var(--c-bg-2);
  color: var(--c-text-2);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}
.chip.active {
  background: var(--c-blue-dim);
  color: var(--c-blue);
  border-color: var(--c-blue);
}
.chip:active { transform: scale(0.96); }

/* ── Chip groups (scrollable row) ───────────────────────────────── */
.chip-group {
  display: flex;
  gap: var(--sp-8);
  overflow-x: auto;
  padding-bottom: var(--sp-4);
}

/* ── Progress bar ───────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--c-bg-2);
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--c-accent);
  transition: width var(--t-normal);
}

/* ── Progress ring (SVG) ────────────────────────────────────────── */
.progress-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring__track { fill: none; stroke: var(--c-bg-2); }
.progress-ring__fill  { fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--t-normal); }
.progress-ring__label { position: absolute; text-align: center; }

/* ── Input ──────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--r-md);
  border: 1.5px solid var(--c-border);
  background: var(--c-bg-2);
  color: var(--c-text);
  font-size: var(--fz-md);
  transition: border-color var(--t-fast);
  outline: none;
}
.input:focus { border-color: var(--c-accent); }
.input::placeholder { color: var(--c-text-2); }

.input-label {
  display: block;
  font-size: var(--fz-sm);
  font-weight: 500;
  color: var(--c-text-2);
  margin-bottom: var(--sp-4);
}

/* ── Textarea ───────────────────────────────────────────────────── */
.textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── List (iOS-style) ───────────────────────────────────────────── */
.list {
  background: var(--c-bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-16);
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background var(--t-fast);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--c-bg-2); }
.list-item__icon { font-size: 20px; flex-shrink: 0; }
.list-item__text { flex: 1; min-width: 0; }
.list-item__title { font-size: var(--fz-md); font-weight: 500; }
.list-item__sub   { font-size: var(--fz-sm); color: var(--c-text-2); }
.list-item__right { color: var(--c-text-2); flex-shrink: 0; }

/* ── Badge ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: var(--fz-xs);
  font-weight: 700;
}
.badge-green  { background: var(--c-green-light); color: var(--c-green); }
.badge-orange { background: var(--c-orange-light); color: var(--c-orange); }
.badge-red    { background: var(--c-red-dim); color: var(--c-red); }
.badge-blue   { background: var(--c-blue-dim); color: var(--c-blue); }
.badge-purple { background: var(--c-purple-dim); color: var(--c-purple); }

/* ── Toast ──────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  pointer-events: none;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--r-lg);
  font-size: var(--fz-sm);
  font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: toast-in 0.25s ease, toast-out 0.25s ease forwards;
  animation-delay: 0s, 2.75s;
  pointer-events: auto;
}
.toast-success { background: var(--c-green); color: #fff; }
.toast-error   { background: var(--c-red); color: #fff; }
.toast-info    { background: var(--c-bg-card); color: var(--c-text); box-shadow: var(--shadow-float); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* ── Bottom sheet ───────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}
.overlay.open { opacity: 1; pointer-events: all; }

.bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--c-bg-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-8) var(--sp-16) calc(var(--sp-32) + var(--safe-bottom));
  z-index: 101;
  transform: translateY(100%);
  transition: transform var(--t-normal);
  max-height: 90dvh;
  overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet__handle {
  width: 36px; height: 4px;
  background: var(--c-border);
  border-radius: var(--r-full);
  margin: 0 auto var(--sp-16);
}
.bottom-sheet__title {
  font-size: var(--fz-lg);
  font-weight: 700;
  margin-bottom: var(--sp-16);
  text-align: center;
}

/* ── Tab bar ────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--c-bg-card);
  border-top: 1px solid var(--c-border);
  display: flex;
  z-index: 50;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--c-text-2);
  font-size: var(--fz-xs);
  font-weight: 500;
  transition: color var(--t-fast);
  padding-top: var(--sp-8);
}
.tab-btn.active { color: var(--c-accent); }
.tab-btn__icon { font-size: 22px; line-height: 1; }

/* ── Macro pills ────────────────────────────────────────────────── */
.macro-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-8) var(--sp-12);
  border-radius: var(--r-md);
  background: var(--c-bg-2);
  min-width: 72px;
}
.macro-pill__value { font-size: var(--fz-lg); font-weight: 700; }
.macro-pill__label { font-size: var(--fz-xs); color: var(--c-text-2); }

/* ── Streak badge ───────────────────────────────────────────────── */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-10);
  border-radius: var(--r-full);
  background: var(--c-orange-dim);
  color: var(--c-orange);
  font-size: var(--fz-sm);
  font-weight: 700;
}

/* ── Water progress ─────────────────────────────────────────────── */
.water-bar {
  background: var(--c-bg-2);
  border-radius: var(--r-full);
  height: 8px;
  overflow: hidden;
}
.water-bar__fill {
  height: 100%;
  background: var(--c-water);
  border-radius: var(--r-full);
  transition: width var(--t-normal);
}

/* ── Divider ────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--c-border); margin: var(--sp-16) 0; }

/* ── Empty state ────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-48) var(--sp-24);
  color: var(--c-text-2);
  text-align: center;
}
.empty-state__icon { font-size: 48px; }
.empty-state__title { font-size: var(--fz-lg); font-weight: 600; color: var(--c-text); }
.empty-state__text  { font-size: var(--fz-sm); }

/* ── Spinner ────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
