/* ─────────────────────────────────────────
   FitTrack – styles.css
   ───────────────────────────────────────── */

/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 240px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: .2s ease;

  /* Light palette */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #f0f2f8;
  --text: #1a1d27;
  --text-muted: #6b7280;
  --border: #e5e7ef;
  --sidebar-bg: #1a1d27;
  --sidebar-text: #c9cdd6;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(255,255,255,.1);

  --blue:   #4f7ef8;
  --green:  #22c55e;
  --purple: #a855f7;
  --orange: #f97316;
  --red:    #ef4444;

  --blue-light:   #eff4ff;
  --green-light:  #f0fdf4;
  --purple-light: #faf5ff;
  --orange-light: #fff7ed;
}

body.dark {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222636;
  --text: #e8eaf0;
  --text-muted: #9095a3;
  --border: #2e3347;
  --blue-light:   #1e2a45;
  --green-light:  #112a1c;
  --purple-light: #271938;
  --orange-light: #2a1a0e;
  --shadow: 0 2px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo-icon { font-size: 22px; }
.logo-text  { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--sidebar-text);
  font-size: .9rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.nav-item:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.06); }
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--sidebar-text); font-size: .85rem;
  transition: background var(--transition);
}
.theme-toggle:hover { background: var(--sidebar-hover); color: #fff; }

/* ── Mobile Header ── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 20px; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.hamburger, .add-btn-mobile {
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text);
}
.mobile-logo { font-weight: 700; font-size: 17px; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  max-width: 1200px;
  width: 100%;
}

/* ── Section ── */
.section { display: none; }
.section.active { display: block; }
.section-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.section-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.section-sub   { color: var(--text-muted); margin-top: 3px; font-size: .9rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; border: none; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #6366f1);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,126,248,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,126,248,.45); }
.btn-ghost {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.card-blue::before   { background: linear-gradient(90deg, var(--blue), #818cf8); }
.card-green::before  { background: linear-gradient(90deg, var(--green), #86efac); }
.card-purple::before { background: linear-gradient(90deg, var(--purple), #e879f9); }
.card-orange::before { background: linear-gradient(90deg, var(--orange), #fbbf24); }

.stat-icon { font-size: 26px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.stat-trend { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: background var(--transition);
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.view-all { font-size: .85rem; color: var(--blue); text-decoration: none; font-weight: 600; }
.view-all:hover { text-decoration: underline; }

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid; grid-template-columns: 1fr 280px; gap: 20px; margin-bottom: 24px;
}
.chart-card canvas { width: 100% !important; }

/* ── Workout List ── */
.workout-list { display: flex; flex-direction: column; gap: 10px; }
.workout-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  transition: all var(--transition); position: relative;
}
.workout-item:hover { transform: translateX(3px); border-color: var(--blue); }
.w-type-badge {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  flex-shrink: 0;
}
.badge-cardio     { background: var(--blue-light); }
.badge-strength   { background: var(--orange-light); }
.badge-flexibility{ background: var(--purple-light); }
.badge-sports     { background: var(--green-light); }

.w-info { flex: 1; min-width: 0; }
.w-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-meta { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.w-stats { display: flex; gap: 14px; flex-shrink: 0; }
.w-stat { text-align: center; }
.w-stat-val { font-size: .95rem; font-weight: 700; display: block; }
.w-stat-lbl { font-size: .72rem; color: var(--text-muted); }
.w-intensity { font-size: 13px; }
.w-delete {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 16px; opacity: 0; transition: opacity var(--transition);
  padding: 4px 6px; border-radius: 6px;
}
.workout-item:hover .w-delete { opacity: 1; }
.w-delete:hover { background: var(--red); color: #fff; }

/* ── Empty State ── */
.empty-state {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 16px; gap: 10px; color: var(--text-muted);
}
.empty-state.show { display: flex; }
.empty-icon { font-size: 40px; }
.empty-state p { font-size: .95rem; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 20px;
}
.filter-btn {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); font-size: .85rem; font-weight: 500;
  cursor: pointer; color: var(--text-muted); transition: all var(--transition);
}
.filter-btn.active, .filter-btn:hover {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
.search-input {
  margin-left: auto; padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .85rem; min-width: 200px;
  outline: none; transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--blue); }

/* ── Goals ── */
.goals-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
.goal-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.goal-icon { font-size: 40px; }
.goal-card h3 { font-size: 1rem; font-weight: 600; }
.goal-input-row { display: flex; align-items: center; gap: 8px; }
.goal-input {
  width: 90px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 1.1rem; font-weight: 700; text-align: center;
  outline: none; transition: border-color var(--transition);
}
.goal-input:focus { border-color: var(--blue); }
.goal-unit { color: var(--text-muted); font-size: .85rem; }
.goal-progress-wrap { display: flex; align-items: center; gap: 10px; width: 100%; }
.goal-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), #818cf8); transition: width .6s ease; width: 0%; }
.goal-pct { font-size: .8rem; font-weight: 600; color: var(--blue); min-width: 36px; }
.goal-status { font-size: .82rem; color: var(--text-muted); }

/* ── Progress ── */
.progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.monthly-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.month-card {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; border: 1px solid var(--border);
}
.month-name { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.month-val  { font-size: 1.4rem; font-weight: 800; margin: 4px 0; }
.month-sub  { font-size: .72rem; color: var(--text-muted); }

/* ── Split Legend ── */
.split-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform var(--transition);
  margin: 16px;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px; border-radius: 6px;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

/* ── Form ── */
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: .95rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,126,248,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.intensity-row { display: flex; gap: 8px; }
.intensity-btn {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text); cursor: pointer; font-size: .85rem; font-weight: 500;
  transition: all var(--transition);
}
.intensity-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #1a1d27; color: #fff; padding: 12px 22px;
  border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); transform: translateY(80px);
  opacity: 0; transition: all .3s ease; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .progress-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 80px 20px 24px; }
  .mobile-header { display: flex; }
  .goals-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .w-stats { gap: 8px; }
}
