/* ============ Apex features + layout polish ============ */

/* Light mode */
body.light {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d8dde6;
  --text: #1a1d24;
  --muted: #5d6470;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Smooth transitions */
body, .card, .btn, .nav-tab, .tile, input, textarea, select {
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Card hover lift */
.card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.slide-in { animation: slideIn 0.35s ease both; }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.fade-in { animation: fadeIn 0.4s ease both; }

.overview-stat:nth-child(1) { animation-delay: 0.05s; }
.overview-stat:nth-child(2) { animation-delay: 0.1s; }
.overview-stat:nth-child(3) { animation-delay: 0.15s; }
.overview-stat:nth-child(4) { animation-delay: 0.2s; }
.overview-stat:nth-child(5) { animation-delay: 0.25s; }
.overview-stat:nth-child(6) { animation-delay: 0.3s; }

.overview-stat-icon { font-size: 1.4rem; }

/* ============ Chart cards — fixed height ============ */
.chart-card {
  padding: 1rem;
}
.chart-card .card-title {
  margin-bottom: 0.5rem;
}
.chart-card .chart-wrapper {
  position: relative;
  width: 100%;
  height: 300px;
}
.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Dashboard grid */
.dashboard { grid-template-columns: repeat(12, 1fr); }
.macro-card { grid-column: 1 / -1; }
.overview-card { grid-column: 1 / -1; }
.chart-card { grid-column: span 6; }
.pr-card { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .chart-card { grid-column: 1 / -1; }
}

/* ============ PR ============ */
.pr-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.pr-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pr-exercise { font-weight: 600; }
.pr-value { color: var(--accent); font-weight: 700; }
.pr-date { font-size: 0.75rem; }
.pr-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.pr-entry-card { grid-column: 1 / -1; }

/* ============ Water ============ */
.water-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.water-total { font-weight: 700; font-size: 1.1rem; color: var(--accent); }

/* ============ Favorites ============ */
.favorites-container { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.favorite-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.35rem 0.7rem; color: var(--text);
  cursor: pointer; font-size: 0.85rem; transition: all 0.2s ease;
}
.favorite-item:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-1px); }

/* ============ Rest timer ============ */
.rest-timer-display { font-size: 1.5rem; font-weight: 700; color: var(--accent); }

/* ============ PR badges ============ */
.pr-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.badge {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.25rem 0.6rem; font-size: 0.75rem;
  transition: all 0.2s ease;
}
.badge:hover { background: var(--accent); color: #fff; transform: scale(1.05); }

/* ============ Social / Friends ============ */
.social-page { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; padding: 1rem; }
.friends-card, .friend-progress-card { height: fit-content; }
.friend-add-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.friend-add-row input { flex: 1; min-width: 0; }
.friend-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.8rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}
.friend-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.friend-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.friend-avatar.large { width: 52px; height: 52px; font-size: 1.4rem; }
.friend-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.friend-name { font-weight: 600; }
.friend-email { font-size: 0.75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.remove-friend { color: var(--red); }
.remove-friend:hover { background: rgba(248, 81, 73, 0.1); }
.friend-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.friend-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.75rem; }
.friend-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; text-align: center; }
.friend-stat span { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.friend-stat b { font-size: 1.15rem; }
.friend-data h4 { margin: 0.75rem 0 0.4rem; font-size: 0.9rem; }

/* ============ Manual watch ============ */
.manual-watch-form { display: flex; flex-direction: column; gap: 0.6rem; }
.watch-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}
.watch-charts-grid .chart-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
}
.watch-charts-grid canvas {
  width: 100% !important;
  height: 100% !important;
}
.health-score {
  text-align: center;
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 1rem;
}
.health-score-number { font-size: 2rem; font-weight: 700; color: var(--accent); }
.health-score-label { font-size: 0.85rem; color: var(--muted); }
.health-score-detail { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

/* ============ Workout tools ============ */
.template-row, .rest-timer-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; align-items: center; }

/* ============ Admin mini-toggle ============ */
.mini-switch { position: relative; display: inline-block; width: 38px; height: 20px; }
.mini-switch input { opacity: 0; width: 0; height: 0; }
.mini-switch span {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; transition: 0.25s ease;
}
.mini-switch span:before {
  content: ""; position: absolute; height: 14px; width: 14px;
  left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: 0.25s ease;
}
.mini-switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.mini-switch input:checked + span:before { transform: translateX(18px); background: #fff; }

/* ============ Admin chart cards ============ */
.admin-chart-card { padding: 1rem; margin-bottom: 1rem; }
.admin-chart-card .card-title { margin-bottom: 0.5rem; }
.admin-chart-card .chart-wrapper { position: relative; width: 100%; height: 240px; }
.admin-chart-card canvas { width: 100% !important; height: 100% !important; }

/* ============ Button + nav polish ============ */
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(77, 107, 254, 0.25); }
.nav-tab:hover { background: var(--surface-2); color: var(--text); }
.progress-fill { transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.nav-tab.hidden { display: none !important; }

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .template-row, .rest-timer-row { flex-wrap: wrap; }
  .chart-card .chart-wrapper { height: 240px; }
  .admin-chart-card .chart-wrapper { height: 200px; }
  .pr-row { grid-template-columns: 1fr auto; }
  .pr-date { grid-column: 1 / -1; }
  .pr-form { grid-template-columns: 1fr 1fr; }
  .friend-stats-row { grid-template-columns: 1fr; }
  .social-page { grid-template-columns: 1fr; }
  .watch-charts-grid { grid-template-columns: 1fr; }
}
