/* ==========================================================================
   FORGE — Lyfta-Style Design System
   Clean, modern, high-contrast fitness UI with precision typography,
   pure white cards, subtle borders, and Lyfta-blue accents.
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --card: #ffffff;
  --card-hover: #fcfdfe;
  --line: #e2e8f0;
  --line-subtle: #edf2f7;
  
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: #eff6ff;
  --blue-border: #bfdbfe;
  
  --green: #16a34a;
  --green-soft: #dcfce7;
  --green-border: #86efac;

  --orange: #ea580c;
  --orange-soft: #ffedd5;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.09);

  --sidebar: 250px;
  --bottom: 68px;
  --safe: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

/* Main App Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100%;
}

/* Sidebar (Desktop Lyfta Style) */
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  border-right: 1px solid var(--line);
  padding: 24px 16px 20px;
  display: flex; flex-direction: column; gap: 6px;
  background: #ffffff;
  z-index: 20;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 24px;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--blue);
  display: grid; place-items: center; font-weight: 900; font-size: 17px;
  color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.brand-text {
  font-weight: 850; letter-spacing: 0.15em; font-size: 17px;
  color: var(--ink);
}
.brand-badge {
  font-size: 9px; font-weight: 750; background: var(--blue-soft);
  color: var(--blue); padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--blue-border);
}

.nav-group {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.nav-btn {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600;
  text-align: left; width: 100%; transition: all 0.15s ease;
}
.nav-btn svg { width: 20px; height: 20px; flex: none; stroke-width: 2.2; }
.nav-btn:hover { background: var(--bg-subtle); color: var(--ink); }
.nav-btn.active {
  background: var(--blue-soft);
  border-color: var(--blue-border);
  color: var(--blue); font-weight: 750;
}

.sidebar .spacer { flex: 1; }

.athlete-pill {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 14px;
  background: var(--bg-subtle); border: 1px solid var(--line);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  flex: none; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.athlete-meta { min-width: 0; }
.athlete-name { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.athlete-sub { font-size: 11px; color: var(--muted); }

/* Main Content Area */
.content {
  min-width: 0;
  padding: 30px 40px 60px;
  max-width: 1140px;
}
.view { display: none; animation: viewFade 0.18s ease-out; }
.view.active { display: block; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typography */
.h1 { font-size: 28px; letter-spacing: -0.03em; margin: 0 0 6px; font-weight: 800; color: var(--ink); }
.h2 { font-size: 19px; letter-spacing: -0.02em; margin: 0 0 4px; font-weight: 750; color: var(--ink); }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; line-height: 1.5; }

/* Grid and Cards */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 280px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.18s ease;
}
.card:hover { border-color: #cbd5e1; }
.card.highlight {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: var(--blue-border);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.08);
}

/* Buttons (Lyfta Style) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: 0;
  padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 14px;
  transition: all 0.15s ease; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn:hover { background: var(--blue-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn.ghost {
  background: var(--bg-subtle); color: var(--ink-secondary);
  border: 1px solid var(--line); box-shadow: none;
}
.btn.ghost:hover { background: #e2e8f0; color: var(--ink); }
.btn.accent {
  background: #111827; color: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.btn.accent:hover { background: #000000; }
.btn.small { padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* Badges & Pills */
.badge {
  font-size: 11px; font-weight: 700; background: var(--blue-soft);
  color: var(--blue); padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--blue-border); text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.green {
  background: var(--green-soft); color: var(--green);
  border-color: var(--green-border);
}
.badge.orange {
  background: var(--orange-soft); color: var(--orange);
  border-color: #fed7aa;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  border: 1px solid var(--line); background: #ffffff; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 650;
  transition: all 0.15s ease; cursor: pointer;
}
.pill:hover { border-color: #cbd5e1; color: var(--ink); }
.pill.active {
  background: var(--ink); color: #fff; border-color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

/* Today Workout Hero Card (Lyfta Banner) */
.hero-workout {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-lg);
}
.kicker {
  font-size: 12px; font-weight: 800; color: var(--blue);
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px;
}
.hero-title { font-size: 26px; font-weight: 850; margin: 0 0 6px; letter-spacing: -0.02em; color: var(--ink); }
.hero-desc { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }

/* Exercise Previews in Workout Hero */
.ex-preview-list {
  display: flex; flex-direction: column; gap: 8px; margin: 16px 0 20px;
}
.ex-preview-item {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center;
  padding: 8px 12px; border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.ex-preview-thumb {
  width: 56px; height: 56px; border-radius: 10px; background: #ffffff;
  object-fit: cover; border: 1px solid var(--line);
}
.ex-preview-item .name { font-weight: 700; font-size: 14px; color: var(--ink); }
.ex-preview-item .detail { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Search and Muscle Filter Chips */
.search-box {
  width: 100%; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 18px 13px 44px; font-size: 15px; color: var(--ink);
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3-3'/%3E%3C/svg%3E") 16px 50% no-repeat;
  outline: none; transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.search-box:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.muscle-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 8px;
  scrollbar-width: none;
}
.muscle-chips::-webkit-scrollbar { display: none; }
.m-chip {
  padding: 8px 16px; border-radius: 999px; background: #ffffff;
  border: 1px solid var(--line); color: var(--muted); font-size: 13px;
  font-weight: 650; white-space: nowrap; transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.m-chip:hover { border-color: #cbd5e1; color: var(--ink); }
.m-chip.active {
  background: var(--blue); color: #fff; border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Exercise Library Grid (Lyfta Cards) */
.ex-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-top: 18px;
}
.ex-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #ffffff; overflow: hidden; cursor: pointer;
  text-align: left; padding: 0; width: 100%; transition: all 0.18s ease;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.ex-card:hover {
  border-color: var(--blue-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.ex-card-thumb-box {
  height: 180px; background: #fafbfe; display: flex;
  align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line-subtle);
  overflow: hidden;
}
.ex-card-media {
  width: 100%; height: 100%; object-fit: contain;
}
.ex-card-info { padding: 16px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.ex-card-title { font-size: 15px; font-weight: 750; color: var(--ink); margin: 0 0 4px; }
.ex-card-muscles { font-size: 12px; color: var(--blue); margin: 0 0 8px; font-weight: 650; }
.ex-card-why {
  font-size: 12px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ==========================================================================
   LYFTA SIGNATURE WORKOUT OVERLAY
   ========================================================================== */
.overlay {
  position: fixed; inset: 0; background: #ffffff;
  z-index: 50; overflow-y: auto;
  padding: 16px 20px calc(24px + var(--safe)); display: none;
}
.overlay.open { display: block; }
.wo-modal {
  max-width: 640px; margin: 0 auto;
}
.wo-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 16px; border-bottom: 1px solid var(--line);
}
.wo-stats-bar {
  display: grid; grid-template-columns: 1fr 1fr 1fr; text-align: center;
  background: var(--bg-subtle); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; margin: 16px 0;
}
.wo-stats-bar strong { display: block; font-size: 18px; font-weight: 800; color: var(--ink); }
.wo-stats-bar span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; }

/* 3D Model Stage */
.stage-3d {
  width: 100%; height: 260px; max-height: 260px;
  background: #fafbfe; border: 1px solid var(--line);
  border-radius: var(--radius); display: flex;
  align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: 16px;
}
.stage-3d video, .stage-3d img {
  width: 100%; height: 100%; object-fit: contain;
}

/* Active Exercise Card in Workout */
.wo-active-card {
  background: #ffffff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.wo-active-title { font-size: 22px; font-weight: 800; color: var(--ink); margin: 0 0 4px; }
.wo-active-meta { font-size: 13px; color: var(--blue); margin: 0 0 14px; font-weight: 650; }

/* Lyfta Signature Set Table */
.set-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.set-table th {
  text-align: left; font-size: 11px; color: var(--muted);
  font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 6px;
}
.set-table td { padding: 8px 6px; }
.set-table tr.done td { background: #f0fdf4; border-radius: 8px; }
.set-table input {
  width: 76px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 16px; font-weight: 750;
  text-align: center; padding: 10px 6px; outline: none; transition: border-color 0.15s ease;
}
.set-table input:focus { border-color: var(--blue); background: #ffffff; }

/* The Lyfta Large Check Button */
.check-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #ffffff; color: var(--muted); font-size: 16px; font-weight: 800;
  display: grid; place-items: center; transition: all 0.15s ease;
}
.check-btn.done {
  background: var(--green); border-color: var(--green); color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
}

/* Floating Rest Timer Pill */
.timer-bar {
  position: fixed; inset: auto 20px calc(80px + var(--safe)) 20px;
  max-width: 440px; margin: 0 auto; background: #0f172a; color: #fff;
  border-radius: 16px; padding: 14px 20px; display: none; z-index: 60;
  align-items: center; justify-content: space-between;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
}
.timer-bar.show { display: flex; }
.timer-bar b { font-size: 26px; font-weight: 850; letter-spacing: -0.03em; color: #38bdf8; }

/* Mobile Bottom Navigation (Lyfta Style) */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #ffffff;
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + var(--safe));
  z-index: 40; justify-content: space-around;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}
.bottom-nav button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; flex: 1; padding: 4px 0;
  transition: color 0.15s ease;
}
.bottom-nav button svg { width: 22px; height: 22px; stroke-width: 2.2; }
.bottom-nav button.active {
  color: var(--blue);
}

/* AI Coach System View (Clean Lyfta Assistant) */
.coach-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 22px;
  color: #fff; box-shadow: var(--shadow);
}
.coach-header .h1 { color: #fff; }
.coach-avatar {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; font-size: 22px; color: #fff;
  flex: none; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.chat-response-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; margin-top: 16px;
  line-height: 1.6; font-size: 14px; color: var(--ink-secondary);
}
.chat-response-card h3 { color: var(--blue); margin: 0 0 8px; font-size: 16px; }
.chat-response-card li { margin-bottom: 8px; }
.chat-chips {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;
}
.chat-chip {
  background: var(--bg-subtle); border: 1px solid var(--line);
  color: var(--ink-secondary); padding: 8px 14px; border-radius: 10px; font-size: 12.5px;
  font-weight: 650; cursor: pointer; transition: all 0.15s ease;
}
.chat-chip:hover {
  background: var(--blue-soft); border-color: var(--blue-border); color: var(--blue);
}
.chat-chip.active {
  background: var(--blue); border-color: var(--blue); color: #fff;
}

/* Progress Calendar & Charts */
.cal-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.cal-table th { color: var(--muted); font-size: 12px; font-weight: 700; padding: 8px; }
.cal-table td { text-align: center; padding: 6px 2px; }
.cal-cell {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid;
  place-items: center; font-size: 13px; font-weight: 650; color: var(--muted);
}
.cal-cell.today {
  background: var(--blue); color: #fff; font-weight: 800;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.cal-cell.done {
  background: var(--green-soft); color: var(--green); font-weight: 800;
  border: 1.5px solid var(--green-border);
}
.cal-cell.planned {
  border: 1.5px dashed var(--blue); color: var(--blue);
}

/* Volume Bar Chart */
.volume-chart {
  display: flex; align-items: flex-end; gap: 8px; height: 130px;
  padding-top: 12px;
}
.v-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 6px; height: 100%; justify-content: flex-end;
}
.v-bar {
  width: 100%; max-width: 22px; background: var(--blue);
  border-radius: 6px 6px 2px 2px; min-height: 4px;
}
.v-label { font-size: 10px; color: var(--muted); font-weight: 700; }

/* Responsive Media Queries */
@media (max-width: 860px) {
  .app { display: block; }
  .sidebar { display: none; }
  .content { padding: 18px 16px calc(var(--bottom) + 30px); }
  .bottom-nav { display: flex; }
  .h1 { font-size: 24px; }
  .h2 { font-size: 18px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero-workout { padding: 18px; }
  .hero-title { font-size: 22px; }
}
