/**
 * fitness-app.css — Standalone Fitness App.
 *
 * Apple Fitness / Nike Training inspired.
 * Emerald-green gradients, activity ring, glass cards.
 */

/* ── Container ───────────────────────────────────────────────────── */

.fapp {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 44px) + 12px) 16px
           calc(env(safe-area-inset-bottom, 0px) + 80px);
  background: linear-gradient(170deg,
    var(--fapp-bg1, #071a10) 0%,
    var(--fapp-bg2, #0a2218) 45%,
    var(--fapp-bg3, #040e08) 100%);
  color: #f0f0f0;
  position: relative;
}

.fapp::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 10%, rgba(16, 185, 129, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 80% 60%, rgba(6, 95, 70, 0.08), transparent);
  pointer-events: none;
}

/* ── Back Button ─────────────────────────────────────────────────── */

.fapp-back {
  position: fixed;
  top: calc(env(safe-area-inset-top, 44px) + 10px);
  left: 14px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.fapp-back:active { background: rgba(0, 0, 0, 0.55); }

/* ── Hero: Activity Ring ─────────────────────────────────────────── */

.fapp-hero {
  position: relative;
  text-align: center;
  padding: 32px 0 20px;
}

.fapp-date {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 16px;
}

.fapp-ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}

.fapp-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.fapp-ring-bg {
  fill: none;
  stroke: rgba(16, 185, 129, 0.15);
  stroke-width: 10;
}

.fapp-ring-fill {
  fill: none;
  stroke: #10b981;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4));
}

.fapp-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.fapp-ring-count {
  font-size: 3.2rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.03em;
}

.fapp-ring-goal {
  font-size: 0.85rem;
  opacity: 0.5;
  margin-top: 4px;
}

.fapp-ring-text {
  font-size: 1.05rem;
  opacity: 0.8;
}

/* ── Stat Strip ──────────────────────────────────────────────────── */

.fapp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
  position: relative;
}

.fapp-stat {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}

.fapp-stat-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.fapp-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}

.fapp-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.5;
  margin-top: 2px;
}

/* ── Section ─────────────────────────────────────────────────────── */

.fapp-section {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}

.fapp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.fapp-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
  font-weight: 600;
}

.fapp-add-btn {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.fapp-add-btn:active { background: rgba(16, 185, 129, 0.35); }

/* ── Form (collapsed by default) ─────────────────────────────────── */

.fapp-form {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  animation: fapp-slide 0.25s ease;
}

.fapp-form.open { display: flex; }

@keyframes fapp-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fapp-form-row {
  display: flex;
  gap: 8px;
}

.fapp-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  color: #f0f0f0;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.fapp-input:focus { border-color: rgba(16, 185, 129, 0.5); }
.fapp-input::placeholder { color: rgba(255, 255, 255, 0.3); }

.fapp-input option { background: #0a2218; color: #f0f0f0; }

.fapp-save-btn {
  background: #10b981;
  border: none;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.fapp-save-btn:active { opacity: 0.7; }

/* ── Activity rows ───────────────────────────────────────────────── */

.fapp-rows { display: flex; flex-direction: column; gap: 2px; }

.fapp-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fapp-row:last-child { border-bottom: none; }

.fapp-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.fapp-row-icon.sleep { background: rgba(99, 102, 241, 0.15); }
.fapp-row-icon.weight { background: rgba(245, 158, 11, 0.15); }

.fapp-row-title {
  font-size: 0.92rem;
  font-weight: 600;
}

.fapp-row-meta {
  font-size: 0.75rem;
  opacity: 0.5;
  margin-top: 1px;
}

.fapp-row-value {
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.fapp-row-sub {
  font-size: 0.72rem;
  opacity: 0.45;
  text-align: right;
}

/* ── Empty state ─────────────────────────────────────────────────── */

.fapp-empty {
  text-align: center;
  padding: 18px 0;
  opacity: 0.4;
  font-size: 0.85rem;
}

/* ── Weight trend ────────────────────────────────────────────────── */

.fapp-trend {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0 14px;
}

.fapp-trend-value {
  font-size: 2rem;
  font-weight: 200;
}

.fapp-trend-diff {
  font-size: 0.95rem;
  font-weight: 700;
}

.fapp-trend-diff.up { color: #f87171; }
.fapp-trend-diff.down { color: #34d399; }
.fapp-trend-diff.flat { color: rgba(255,255,255,0.4); }

.fapp-trend-period {
  font-size: 0.72rem;
  opacity: 0.4;
}

/* ── Toast ───────────────────────────────────────────────────────── */

.fapp-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #10b981;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 26px;
  z-index: 200;
  animation: fapp-toast-in 0.3s ease, fapp-toast-out 0.3s ease 2s forwards;
  pointer-events: none;
}

@keyframes fapp-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes fapp-toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Compliance card ──────────────────────────────────────────────── */

.fapp-compliance { position: relative; }
.fapp-compliance-pct { font-size: 1.1rem; font-weight: 700; }
.fapp-compliance-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 0;
  overflow: hidden;
}
.fapp-compliance-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.fapp-compliance-meta {
  font-size: 0.72rem;
  opacity: 0.6;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (min-width: 500px) {
  .fapp { padding-left: 24px; padding-right: 24px; }
  .fapp-ring-wrap { width: 200px; height: 200px; }
  .fapp-ring-count { font-size: 3.6rem; }
}
