/* ==========================================================================
   AuraFit — Components
   ========================================================================== */

/* ---------------------------- Brand ---------------------------- */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.brand--sm { font-size: 0.95rem; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: var(--sh-raised-xs);
}
.brand-accent { color: var(--accent); }

/* ---------------------------- Pill Nav ---------------------------- */
.pill-nav {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 5px;
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-inset-md);
}
.pill-nav__item {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-secondary);
  transition: color var(--dur-fast) var(--ease-soft);
  white-space: nowrap;
}
.pill-nav__item.is-active {
  color: #fff;
}
.pill-nav__glider {
  position: absolute;
  z-index: 0;
  top: 5px; bottom: 5px; left: 5px;
  width: 120px;
  border-radius: var(--r-pill);
  background: var(--gradient-accent);
  box-shadow: var(--sh-raised-xs);
  transition: transform var(--dur-med) var(--ease-soft), width var(--dur-med) var(--ease-soft);
}

/* ---------------------------- Topbar ---------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------- Search (inset field) ---------------------------- */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
  color: var(--text-muted);
  min-width: 200px;
}
.search-field input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.85rem;
  width: 100%;
  color: var(--text-primary);
}
.search-field input::placeholder { color: var(--text-muted); }

/* ---------------------------- Icon buttons ---------------------------- */
.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-raised-sm);
  color: var(--text-secondary);
  transition: box-shadow var(--dur-fast) var(--ease-soft), transform var(--dur-fast) var(--ease-soft), color var(--dur-fast);
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:active { box-shadow: var(--sh-pressed); transform: translateY(1px); }
.icon-btn--sm { width: 32px; height: 32px; }
.badge-dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------------------------- Theme toggle (pill switch) ---------------------------- */
.theme-toggle {
  position: relative;
  width: 56px; height: 30px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
  display: flex;
  align-items: center;
  padding: 0 7px;
  justify-content: space-between;
  color: var(--text-muted);
}
.theme-toggle__knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-raised-xs);
  transition: transform var(--dur-med) var(--ease-soft), background var(--dur-med);
}
.theme-toggle[aria-pressed='true'] .theme-toggle__knob {
  transform: translateX(26px);
  background: var(--gradient-accent);
}
.theme-toggle .icon-sun, .theme-toggle .icon-moon { position: relative; z-index: 0; }

/* ---------------------------- Avatar ---------------------------- */
.avatar-btn { border: none; background: none; padding: 0; }
.avatar-ring {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gradient-teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: var(--sh-raised-sm);
}

/* ---------------------------- Buttons ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--r-pill);
  padding: 11px 20px;
  font-weight: 700;
  font-size: 0.86rem;
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--sh-raised-sm);
  transition: box-shadow var(--dur-fast) var(--ease-soft), transform var(--dur-fast) var(--ease-soft), color var(--dur-fast);
}
.btn:hover { color: var(--accent); }
.btn:active { box-shadow: var(--sh-pressed); transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: var(--sh-inset-sm); }
.btn--primary {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: var(--sh-raised-md), 0 8px 18px -8px rgba(108, 92, 231, 0.6);
}
.btn--primary:hover { color: #fff; filter: brightness(1.05); }
.btn--primary:active { box-shadow: var(--sh-pressed); }
.btn--lg { padding: 14px 26px; font-size: 0.92rem; }
.btn--sm { padding: 8px 14px; font-size: 0.78rem; }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--surface); box-shadow: var(--sh-raised-xs); }

/* ---------------------------- Cards ---------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-raised-md);
  padding: 22px;
  min-width: 0; /* prevent grid/flex items from sizing to a canvas's intrinsic 300px */
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card canvas { display: block; width: 100%; height: 220px; }

/* ---------------------------- Grids ---------------------------- */
.grid { display: grid; gap: 20px; margin-top: 20px; }
.grid--stats { grid-template-columns: repeat(4, 1fr); }
.grid--split { grid-template-columns: 1.6fr 1fr; }
.grid--live { grid-template-columns: repeat(4, 1fr); }
.grid--equipment { grid-template-columns: repeat(2, 1fr); }

/* ---------------------------- Welcome row ---------------------------- */
.welcome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.welcome-copy h1 { margin: 2px 0 8px; }

/* ---------------------------- Stat cards ---------------------------- */
.stat-card__top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-raised-xs);
}
.stat-icon--violet { color: var(--accent); background: var(--accent-soft); }
.stat-icon--coral { color: var(--rose); background: var(--rose-soft); }
.stat-icon--teal { color: var(--accent-2); background: var(--accent-2-soft); }
.stat-icon--rose { color: var(--rose); background: var(--rose-soft); }

.trend-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  box-shadow: var(--sh-inset-sm);
}
.trend-chip--up { color: var(--success); }
.trend-chip--down { color: var(--danger); }
.trend-chip--neutral { color: var(--text-muted); }

.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; margin-top: 14px; }
.stat-label { color: var(--text-secondary); font-size: 0.8rem; margin-top: 2px; }
.sparkline { display: block; width: 100%; margin-top: 10px; }

/* ---------------------------- Legend ---------------------------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot--violet { background: var(--accent); }
.dot--teal { background: var(--accent-2); }
.dot--rose { background: var(--rose); }

/* ---------------------------- Goal ring ---------------------------- */
.goal-ring-wrap { position: relative; display: grid; place-items: center; margin: 6px auto 18px; width: 160px; height: 160px; }
.goal-ring { width: 160px; height: 160px; transform: rotate(-90deg); }
.goal-ring__track { fill: none; stroke: var(--shadow-dark); opacity: 0.35; stroke-width: 14; }
.goal-ring__progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 427.26;
  stroke-dashoffset: 427.26;
  transition: stroke-dashoffset 1.1s var(--ease-soft);
}
.goal-ring__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.goal-ring__value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; }
.goal-ring__unit { font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; }
.goal-legend { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-secondary); }
.goal-legend strong { display: block; color: var(--text-primary); font-size: 0.95rem; margin-top: 2px; }

/* ---------------------------- Battery list ---------------------------- */
.battery-list { display: flex; flex-direction: column; gap: 14px; }
.battery-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; }
.battery-item__icon {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-raised-xs);
  color: var(--accent);
}
.battery-item__name { font-weight: 700; font-size: 0.86rem; }
.battery-item__meta { font-size: 0.74rem; color: var(--text-secondary); }
.battery-track {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
  margin-top: 6px;
  overflow: hidden;
}
.battery-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--gradient-teal);
  transition: width 1s var(--ease-soft);
}
.battery-fill.is-low { background: linear-gradient(135deg, #ffb84d, #ff6b6b); }
.battery-pct { font-weight: 800; font-size: 0.86rem; min-width: 40px; text-align: right; }
.charging-tag { font-size: 0.68rem; color: var(--accent-2); font-weight: 700; }

/* ---------------------------- Agenda list ---------------------------- */
.agenda-list { display: flex; flex-direction: column; gap: 12px; }
.agenda-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
}
.agenda-time { font-family: var(--font-display); font-weight: 800; font-size: 0.82rem; color: var(--accent); min-width: 56px; }
.agenda-info { flex: 1; }
.agenda-title { font-weight: 700; font-size: 0.86rem; }
.agenda-sub { font-size: 0.74rem; color: var(--text-secondary); }

/* ---------------------------- Filter pills ---------------------------- */
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-pill {
  border: none;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-raised-xs);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: box-shadow var(--dur-fast) var(--ease-soft), color var(--dur-fast);
}
.filter-pill.is-active {
  box-shadow: var(--sh-pressed);
  color: var(--accent);
}

/* ---------------------------- View header ---------------------------- */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

/* ---------------------------- Live metric cards ---------------------------- */
.live-metric { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.live-metric__value { font-family: var(--font-display); font-size: 2rem; font-weight: 800; margin-top: 6px; }
.live-metric__value--mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.live-metric__zone { font-size: 0.76rem; color: var(--accent); font-weight: 700; }
.live-metric--hr canvas { width: 100%; height: 70px; margin: 6px 0; }
.timer-controls { display: flex; gap: 8px; margin-top: 10px; }

/* ---------------------------- Workout grid / cards ---------------------------- */
.workout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.workout-card {
  border-radius: var(--r-lg);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--sh-raised-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform var(--dur-fast) var(--ease-soft), box-shadow var(--dur-fast);
}
.workout-card:hover { transform: translateY(-3px); box-shadow: var(--sh-raised-md); }
.workout-card__top { display: flex; align-items: center; justify-content: space-between; }
.workout-card__badge {
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 9px; border-radius: var(--r-pill);
}
.badge--cardio { background: var(--accent-soft); color: var(--accent); }
.badge--strength { background: var(--accent-2-soft); color: var(--accent-2); }
.badge--yoga { background: var(--amber-soft); color: #b5791a; }
.badge--hiit { background: var(--rose-soft); color: var(--rose); }
.workout-card__title { font-weight: 800; font-size: 0.95rem; }
.workout-card__meta { display: flex; gap: 12px; font-size: 0.76rem; color: var(--text-secondary); }
.workout-card__meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------------------------- Equipment cards ---------------------------- */
.equip-card { display: flex; flex-direction: column; gap: 16px; }
.equip-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.equip-card__id { display: flex; align-items: center; gap: 12px; }
.equip-card__icon {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-raised-xs);
  color: var(--accent);
}
.equip-card__name { font-weight: 800; font-size: 0.95rem; }
.equip-card__status { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--text-secondary); font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-dot.is-online { background: var(--success); box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.18); }

/* Power toggle (physical switch look) */
.power-toggle {
  position: relative;
  width: 52px; height: 30px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-md);
}
.power-toggle__knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-raised-xs);
  transition: transform var(--dur-med) var(--ease-soft), background var(--dur-med);
}
.power-toggle.is-on .power-toggle__knob { transform: translateX(22px); background: var(--gradient-teal); }

.equip-card__row { display: flex; flex-direction: column; gap: 8px; }
.equip-card__row-label { display: flex; align-items: center; justify-content: space-between; font-size: 0.78rem; font-weight: 700; color: var(--text-secondary); }
.equip-card__row-label b { color: var(--text-primary); font-weight: 800; }

.equip-card.is-off .slider-track,
.equip-card.is-off .battery-track { opacity: 0.5; pointer-events: none; }
.equip-card.is-off .equip-card__row-label { opacity: 0.5; }

.equip-card__footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------- Custom range sliders (inset track) ---------------------------- */
.slider-track { position: relative; height: 30px; display: flex; align-items: center; }
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gradient-accent);
  box-shadow: var(--sh-raised-xs), 0 2px 6px rgba(108, 92, 231, 0.5);
  cursor: pointer;
  border: 3px solid var(--surface);
  margin-top: -6px;
  transition: transform var(--dur-fast) var(--ease-soft);
}
input[type='range']::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type='range']::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gradient-accent);
  box-shadow: var(--sh-raised-xs);
  cursor: pointer;
  border: 3px solid var(--surface);
}
input[type='range']::-moz-range-track {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
}

/* ---------------------------- Schedule ---------------------------- */
.schedule-days { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
.schedule-day { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-raised-md); padding: 20px; }
.schedule-day__title { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.schedule-day__title .today-chip { font-size: 0.65rem; background: var(--accent-soft); color: var(--accent); padding: 3px 9px; border-radius: var(--r-pill); font-weight: 800; }
.schedule-item {
  display: grid;
  grid-template-columns: 70px auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-inset-sm);
}
.schedule-item + .schedule-item { margin-top: 10px; }
.schedule-item__time { font-weight: 800; font-size: 0.8rem; color: var(--text-secondary); }
.schedule-item__info-title { font-weight: 700; font-size: 0.86rem; }
.schedule-item__info-sub { font-size: 0.74rem; color: var(--text-secondary); }

/* ---------------------------- Toast ---------------------------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--surface);
  color: var(--text-primary);
  padding: 13px 22px;
  border-radius: var(--r-pill);
  box-shadow: var(--sh-raised-md);
  font-weight: 700;
  font-size: 0.84rem;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur-med) var(--ease-soft), opacity var(--dur-med) var(--ease-soft);
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------- Footer ---------------------------- */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 24px 28px 40px;
}
.social-pills { display: flex; gap: 8px; }
