/* ============================================================
   FITCOACH PRO - Design System
   Aesthetic: Dark Industrial / High-Performance
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-0: #0a0a0c;
  --bg-1: #111116;
  --bg-2: #1a1a22;
  --bg-3: #22222e;
  --bg-4: #2a2a38;

  --accent-fire: #ff4d1c;
  --accent-fire-dim: #c03210;
  --accent-neon: #00e5ff;
  --accent-neon-dim: #00a8bc;
  --accent-gold: #ffd166;
  --accent-green: #06d6a0;
  --accent-purple: #9b5de5;

  --text-0: #f0f0f8;
  --text-1: #b0b0c8;
  --text-2: #707088;
  --text-3: #404058;

  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(255,77,28,0.4);

  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;

  --shadow-glow-fire: 0 0 30px rgba(255,77,28,0.2);
  --shadow-glow-neon: 0 0 30px rgba(0,229,255,0.2);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);

  --sidebar-w: 240px;
  --header-h: 64px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }
ul { list-style: none; }

/* ── Layout ── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent-fire), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-2);
  margin-top: 2px;
}

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(255,77,28,0.15), rgba(255,77,28,0.05));
  color: var(--accent-fire);
  border-left: 2px solid var(--accent-fire);
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  cursor: pointer;
  transition: background var(--transition);
}

.user-card:hover { background: var(--bg-3); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-fire), var(--accent-gold));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-level { font-size: 11px; color: var(--accent-gold); }

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
.header {
  height: var(--header-h);
  background: rgba(10,10,12,0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--text-0);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-date {
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-mono);
}

/* ── Content Area ── */
.content {
  padding: 28px;
  flex: 1;
}

/* ── Page (hidden/shown) ── */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover { border-color: rgba(255,255,255,0.12); }

.card-fire {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow-fire);
}

.card-neon { border-color: rgba(0,229,255,0.2); box-shadow: var(--shadow-glow-neon); }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── Stats Widget ── */
.stat-widget {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.stat-widget::before {
  content: attr(data-icon);
  position: absolute;
  right: 16px; top: 12px;
  font-size: 32px;
  opacity: 0.15;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 1px;
  line-height: 1;
}

.stat-unit { font-size: 16px; color: var(--text-1); margin-left: 4px; }
.stat-trend { font-size: 12px; color: var(--accent-green); }
.stat-trend.down { color: var(--accent-fire); }

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--text-0);
}

.section-title span { color: var(--accent-fire); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-fire), var(--accent-fire-dim));
  color: white;
  box-shadow: 0 4px 16px rgba(255,77,28,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255,77,28,0.5);
}

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-0);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-4); border-color: rgba(255,255,255,0.15); }

.btn-ghost {
  color: var(--text-1);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-2); color: var(--text-0); }

.btn-neon {
  background: rgba(0,229,255,0.1);
  color: var(--accent-neon);
  border: 1px solid rgba(0,229,255,0.3);
}

.btn-neon:hover {
  background: rgba(0,229,255,0.2);
  box-shadow: 0 0 20px rgba(0,229,255,0.2);
}

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-0);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-fire);
  box-shadow: 0 0 0 3px rgba(255,77,28,0.1);
}

.form-select { cursor: pointer; }
.form-select option { background: var(--bg-3); }

.form-textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }

/* ── Badge / Tag ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.badge-fire { background: rgba(255,77,28,0.15); color: var(--accent-fire); border: 1px solid rgba(255,77,28,0.3); }
.badge-neon { background: rgba(0,229,255,0.1); color: var(--accent-neon); border: 1px solid rgba(0,229,255,0.2); }
.badge-gold { background: rgba(255,209,102,0.1); color: var(--accent-gold); border: 1px solid rgba(255,209,102,0.2); }
.badge-green { background: rgba(6,214,160,0.1); color: var(--accent-green); border: 1px solid rgba(6,214,160,0.2); }
.badge-purple { background: rgba(155,93,229,0.1); color: var(--accent-purple); border: 1px solid rgba(155,93,229,0.2); }

/* ── Progress Bar ── */
.progress-bar {
  background: var(--bg-4);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent-fire), var(--accent-gold));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.neon { background: linear-gradient(90deg, var(--accent-neon), var(--accent-purple)); }
.progress-fill.green { background: var(--accent-green); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.tab.active {
  background: var(--bg-4);
  color: var(--text-0);
}

.tab:hover:not(.active) { color: var(--text-1); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-1);
}

tbody tr:hover td { background: var(--bg-3); color: var(--text-0); }
tbody tr:last-child td { border-bottom: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 1px;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 18px;
}

.modal-close:hover { background: var(--bg-4); color: var(--text-0); }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── AI Chat Panel ── */
.ai-panel {
  position: fixed;
  right: -440px;
  top: var(--header-h);
  bottom: 0;
  width: 420px;
  background: var(--bg-1);
  border-left: 1px solid rgba(0,229,255,0.2);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}

.ai-panel.open { right: 0; }

.ai-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(0,229,255,0.08), transparent);
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--accent-neon);
}

.ai-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(6,214,160,0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(6,214,160,0); }
}

.ai-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  gap: 10px;
  animation: msgIn 0.2s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.ai-msg.user { flex-direction: row-reverse; }

.ai-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.ai-msg-avatar.coach { background: linear-gradient(135deg, var(--accent-neon), var(--accent-purple)); }
.ai-msg-avatar.user-av { background: linear-gradient(135deg, var(--accent-fire), var(--accent-gold)); }

.ai-msg-bubble {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-0);
  max-width: 80%;
  line-height: 1.5;
}

.ai-msg.user .ai-msg-bubble {
  background: rgba(255,77,28,0.1);
  border-color: rgba(255,77,28,0.2);
}

.ai-msg-bubble.coach-bubble {
  background: rgba(0,229,255,0.05);
  border-color: rgba(0,229,255,0.2);
}

.ai-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-0);
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 100px;
  font-family: var(--font-body);
  transition: border-color var(--transition);
}

.ai-input:focus { border-color: rgba(0,229,255,0.5); }

.ai-send-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-neon);
  color: var(--bg-0);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: all var(--transition);
}

.ai-send-btn:hover { background: var(--accent-neon-dim); transform: scale(1.05); }

/* ── AI Toggle Button ── */
.ai-toggle-btn {
  position: fixed;
  bottom: 76px;
  right: 28px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-neon), var(--accent-purple));
  color: white;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(0,229,255,0.4);
  z-index: 95;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
}

.ai-toggle-btn:hover { transform: scale(1.1); box-shadow: 0 12px 40px rgba(0,229,255,0.6); }
.ai-toggle-btn.open { background: linear-gradient(135deg, var(--accent-fire), var(--accent-gold)); }

/* ── Calendar ── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-header {
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-2);
  padding: 4px;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  position: relative;
  min-height: 48px;
  gap: 2px;
}

.cal-day:hover { background: var(--bg-3); }
.cal-day.today { background: rgba(255,77,28,0.15); color: var(--accent-fire); font-weight: 600; }
.cal-day.has-workout::after {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent-fire);
  position: absolute;
  bottom: 6px;
}

.cal-day.other-month { opacity: 0.3; }

/* ── Chart ── */
.chart-container {
  position: relative;
  width: 100%;
  padding: 0;
}

canvas { width: 100% !important; }

/* ── Exercise Entry ── */
.exercise-entry {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: border-color var(--transition);
}

.exercise-entry:hover { border-color: rgba(255,77,28,0.3); }

.exercise-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.set-row {
  display: grid;
  grid-template-columns: 40px 80px 80px 80px auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}

.set-row label { color: var(--text-2); text-align: center; }

.set-input {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text-0);
  font-size: 12px;
  text-align: center;
  outline: none;
  width: 100%;
  transition: border-color var(--transition);
}

.set-input:focus { border-color: var(--accent-fire); }

/* ── Timer ── */
.timer-display {
  font-family: var(--font-display);
  font-size: 72px;
  letter-spacing: 4px;
  text-align: center;
  color: var(--text-0);
  line-height: 1;
  text-shadow: 0 0 30px rgba(255,77,28,0.5);
}

.timer-display.running { color: var(--accent-fire); }
.timer-display.paused { color: var(--accent-gold); }

/* ── Gamification ── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}

.achievement-badge {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 28px;
  cursor: default;
  transition: transform var(--transition);
  position: relative;
  overflow: hidden;
}

.achievement-badge.unlocked {
  background: var(--bg-3);
  border: 1px solid var(--border);
}

.achievement-badge.locked {
  background: var(--bg-3);
  border: 1px dashed var(--border);
  opacity: 0.4;
  filter: grayscale(1);
}

.achievement-badge:hover { transform: scale(1.05); }

.achievement-badge span {
  font-size: 10px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
}

/* ── XP Bar ── */
.xp-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.xp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.level-badge {
  font-family: var(--font-display);
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-fire));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Streak ── */
.streak-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--accent-gold);
}

.streak-fire { animation: flicker 0.5s ease-in-out infinite alternate; }

@keyframes flicker {
  from { opacity: 0.8; transform: scale(1); }
  to { opacity: 1; transform: scale(1.1) rotate(-3deg); }
}

/* ── Toast / Notification ── */
.toast-container {
  position: fixed;
  bottom: 90px;
  right: 28px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-0);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-card);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-fire); }
.toast.info { border-left: 3px solid var(--accent-neon); }
.toast.pr { border-left: 3px solid var(--accent-gold); }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-neon);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Donut Chart ── */
.donut-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-center {
  position: absolute;
  text-align: center;
}

/* ── Misc ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-fire { color: var(--accent-fire); }
.text-neon { color: var(--accent-neon); }
.text-gold { color: var(--accent-gold); }
.text-green { color: var(--accent-green); }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 12px; }
.text-mono { font-family: var(--font-mono); }
.text-display { font-family: var(--font-display); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .nav-item span { display: none; }
  .sidebar-section-label { display: none; }
  .logo-sub { display: none; }
  .logo-text { font-size: 20px; }
  .sidebar-footer .user-name, .sidebar-footer .user-level { display: none; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: none; width: 240px; box-shadow: 4px 0 32px rgba(0,0,0,0.7); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 12px; padding-bottom: 80px; }
  .header { padding: 0 16px; }
  .ai-panel { width: 100%; right: -100%; }
  .main { padding-bottom: 64px; }
  .ai-toggle-btn { bottom: 80px; right: 16px; width: 48px; height: 48px; font-size: 18px; }
}

/* ── Mobile Bottom Navigation ── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  backdrop-filter: blur(12px);
}

@media (max-width: 640px) {
  .mobile-nav { display: flex; }
  .mobile-menu-btn { display: flex !important; }
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  color: var(--text-2);
  min-width: 0;
}

.mobile-nav-item.active {
  color: var(--accent-fire);
}

.mobile-nav-item:active { opacity: 0.7; }

.mobile-nav-icon { font-size: 20px; line-height: 1; }
.mobile-nav-label { font-size: 9px; letter-spacing: 0.3px; text-transform: uppercase; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-align: center; }

/* Mobile overlay when sidebar open */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Page transition ── */
.page.active {
  animation: pageIn 0.25s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Program / Template Cards ── */
.program-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.program-card:hover { border-color: rgba(255,77,28,0.4); transform: translateY(-2px); box-shadow: var(--shadow-glow-fire); }
.program-card-type {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 6px;
}
.program-card-title { font-family: var(--font-display); font-size: 18px; margin-bottom: 4px; }
.program-card-meta { font-size: 12px; color: var(--text-2); }
.program-card-badge {
  position: absolute; top: 12px; right: 12px;
  font-size: 22px;
}

/* ── Interval rows (fractionné) ── */
.interval-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.interval-row:last-child { border-bottom: none; }

/* ── Sport type pills ── */
.sport-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 100px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  background: var(--bg-3);
  color: var(--text-1);
  white-space: nowrap;
}
.sport-pill.selected, .sport-pill:hover { background: rgba(255,77,28,0.15); border-color: var(--accent-fire); color: var(--accent-fire); }

/* ── Workout type selector ── */
.workout-type-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px;
}
@media (max-width: 480px) { .workout-type-grid { grid-template-columns: 1fr 1fr; } }

.workout-type-btn {
  padding: 10px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-3);
  color: var(--text-1); font-size: 12px; font-weight: 500;
  cursor: pointer; text-align: center; transition: all var(--transition);
}
.workout-type-btn.active { background: rgba(255,77,28,0.15); border-color: var(--accent-fire); color: var(--accent-fire); }
.workout-type-btn .wt-icon { font-size: 20px; display: block; margin-bottom: 4px; }

/* ── Swim metrics ── */
.swim-pool-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pool-btn {
  padding: 5px 12px; border-radius: 100px; font-size: 12px;
  border: 1px solid var(--border); background: var(--bg-3);
  color: var(--text-1); cursor: pointer; transition: all var(--transition);
}
.pool-btn.active { background: rgba(0,229,255,0.15); border-color: var(--accent-neon); color: var(--accent-neon); }

/* ── Multi-session day indicator ── */
.cal-day-sessions {
  display: flex; gap: 2px; justify-content: center;
  position: absolute; bottom: 4px; left: 0; right: 0;
}
.cal-session-dot {
  width: 5px; height: 5px; border-radius: 50%;
}

/* ── Collapsible ── */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 10px 0; user-select: none;
}
.collapsible-header .chevron {
  transition: transform var(--transition); font-size: 12px; color: var(--text-2);
}
.collapsible-header.open .chevron { transform: rotate(180deg); }
.collapsible-body { display: none; }
.collapsible-body.open { display: block; }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-2);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; }

/* ── Range input styling ── */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--bg-4); border-radius: 2px; outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-fire); cursor: pointer;
  box-shadow: 0 0 8px rgba(255,77,28,0.5);
  transition: transform var(--transition);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── Last session hint ── */
.last-session-hint {
  font-size: 11px; color: var(--accent-neon); opacity: 0.8;
  font-family: var(--font-mono); margin-top: 2px;
}

/* ══════════════════════════════════════════════
   MOBILE BOTTOM NAV (added v3)
   ══════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  z-index: 110;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 56px;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  flex: 1;
  min-width: 0;
}

.mobile-nav-item .mnav-icon { font-size: 20px; }
.mobile-nav-item .mnav-label { font-size: 9px; color: var(--text-2); letter-spacing: 0.3px; white-space: nowrap; }
.mobile-nav-item.active .mnav-icon { filter: drop-shadow(0 0 6px var(--accent-fire)); }
.mobile-nav-item.active .mnav-label { color: var(--accent-fire); }

/* Mobile "more" sheet */
.mobile-more-sheet {
  position: fixed;
  bottom: -100%; left: 0; right: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 120;
  padding: 20px 20px 40px;
  transition: bottom 0.3s cubic-bezier(0.4,0,0.2,1);
}
.mobile-more-sheet.open { bottom: 0; }
.mobile-more-sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 119; display: none;
}
.mobile-more-sheet-overlay.open { display: block; }
.more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.more-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  background: var(--bg-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 22px;
  transition: background var(--transition);
}
.more-item:hover { background: var(--bg-4); }
.more-item span { font-size: 10px; color: var(--text-1); }

@media (max-width: 640px) {
  .ai-panel { bottom: 56px; }
  .ai-input-area { padding-bottom: 12px; }
  :root { --sidebar-w: 0px; }
  .sidebar { display: none !important; }
  .main { margin-left: 0 !important; padding-bottom: 60px; }
  .mobile-bottom-nav { display: block; }
  .ai-toggle-btn { bottom: 80px; right: 16px; width: 48px; height: 48px; font-size: 20px; }
  .content { padding: 12px; }
  .header { padding: 0 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
  .set-headers, .set-row-grid { font-size: 11px; }
}
