/* ForgeAI — Dark Theme Mobile-First PWA */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --accent: #0099ff;
  --accent-glow: rgba(0,153,255,0.3);
  --accent2: #00d4ff;
  --success: #00e676;
  --warning: #ffab00;
  --danger: #ff5252;
  --text: #ffffff;
  --text-dim: #a0aec0;
  --text-muted: #6b7b8d;
  --border: rgba(255,255,255,0.08);
  --radius: 16px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Screen System */
.screen { display: none; min-height: 100vh; padding: 1.5rem; padding-bottom: 6rem; animation: fadeIn 0.4s ease; }
.screen.active { display: flex; flex-direction: column; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ============ WELCOME SCREEN ============ */
.welcome { align-items: center; justify-content: center; text-align: center; }
.welcome .logo { font-size: 4rem; margin-bottom: 0.5rem; }
.welcome h1 { font-family: 'Fredoka', sans-serif; font-size: 3rem; font-weight: 700; }
.welcome h1 span { color: var(--accent); }
.welcome .tagline { color: var(--text-dim); font-size: 1.1rem; margin: 0.5rem 0 2.5rem; }
.welcome .features { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin-bottom: 3rem; max-width: 400px; }
.welcome .feature { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem 1rem; font-size: 0.85rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.5rem; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 1rem;
  padding: 1rem 2rem; border-radius: 50px; border: none; cursor: pointer;
  transition: all 0.3s ease; text-decoration: none; width: 100%; max-width: 360px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white; box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }
.btn-sm { padding: 0.6rem 1.2rem; font-size: 0.85rem; }
.btn-icon { width: auto; padding: 0.8rem; border-radius: 12px; }

/* ============ ONBOARDING ============ */
.onboarding { max-width: 500px; margin: 0 auto; width: 100%; }
.progress-bar { height: 4px; background: var(--border); border-radius: 4px; margin-bottom: 2rem; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width 0.5s ease; }
.step-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 0.5rem; }
.step-title { font-family: 'Fredoka', sans-serif; font-size: 1.8rem; font-weight: 600; margin-bottom: 0.5rem; }
.step-desc { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 2rem; line-height: 1.5; }
.step { display: none; animation: fadeIn 0.4s ease; }
.step.active { display: block; }

/* Form Elements */
.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); margin-bottom: 0.4rem; }
.form-input {
  width: 100%; padding: 0.9rem 1rem; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 1rem; font-family: 'Inter', sans-serif;
  transition: border-color 0.3s ease; outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0aec0' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; }
textarea.form-input { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

/* Sex Selector */
.sex-select { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.8rem; margin-bottom: 1.2rem; }
.sex-option {
  background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem; text-align: center; cursor: pointer; transition: all 0.3s ease;
}
.sex-option.selected { border-color: var(--accent); background: rgba(0,153,255,0.1); }
.sex-option .icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
.sex-option .label { font-size: 0.8rem; color: var(--text-dim); }

/* Photo Upload */
.photo-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.photo-upload {
  background: var(--bg-input); border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; cursor: pointer; transition: all 0.3s ease;
  position: relative; overflow: hidden;
}
.photo-upload:hover { border-color: var(--accent); }
.photo-upload.has-photo { border-style: solid; border-color: var(--success); }
.photo-upload .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.photo-upload .text { font-size: 0.8rem; color: var(--text-dim); }
.photo-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.photo-upload input { display: none; }

/* Fitness Assessment */
.assessment-grid { display: grid; gap: 0.8rem; }
.assessment-item {
  display: flex; align-items: center; gap: 1rem; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem 1rem;
}
.assessment-item .emoji { font-size: 1.3rem; }
.assessment-item .info { flex: 1; }
.assessment-item .info .name { font-size: 0.85rem; font-weight: 500; }
.assessment-item .info .hint { font-size: 0.7rem; color: var(--text-muted); }
.assessment-item input {
  width: 70px; padding: 0.5rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.9rem; text-align: center; outline: none;
}
.assessment-item input:focus { border-color: var(--accent); }
.skip-btn { text-align: center; margin-top: 1rem; }
.skip-btn a { color: var(--accent); text-decoration: none; font-size: 0.9rem; cursor: pointer; }

/* Equipment Grid */
.equipment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.equipment-item {
  background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 1.2rem 0.8rem; text-align: center; cursor: pointer; transition: all 0.3s ease;
}
.equipment-item.selected { border-color: var(--accent); background: rgba(0,153,255,0.1); }
.equipment-item .icon { font-size: 1.8rem; margin-bottom: 0.3rem; }
.equipment-item .name { font-size: 0.8rem; font-weight: 500; }
.equipment-item .desc { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Sliders */
.slider-group { margin-bottom: 1.5rem; }
.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.slider-header .label { font-size: 0.9rem; font-weight: 500; }
.slider-header .value { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
input[type="range"] {
  width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 6px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); cursor: pointer; box-shadow: 0 2px 8px var(--accent-glow);
}

/* Goal Cards */
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.goal-card {
  background: var(--bg-input); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem; text-align: center; cursor: pointer; transition: all 0.3s ease;
}
.goal-card.selected { border-color: var(--accent); background: rgba(0,153,255,0.1); }
.goal-card .icon { font-size: 2rem; margin-bottom: 0.3rem; }
.goal-card .name { font-size: 0.85rem; font-weight: 600; }

/* Stress/Diet visual selectors */
.option-row { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.option-pill {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 50px;
  padding: 0.5rem 1rem; font-size: 0.8rem; cursor: pointer; transition: all 0.3s ease;
  color: var(--text-dim);
}
.option-pill.selected { border-color: var(--accent); color: var(--text); background: rgba(0,153,255,0.15); }

/* ============ NAV BUTTONS ============ */
.nav-buttons { display: flex; gap: 0.8rem; margin-top: 2rem; }
.nav-buttons .btn { flex: 1; }

/* ============ GENERATING SCREEN ============ */
.generating { align-items: center; justify-content: center; text-align: center; }
.generating .spinner { width: 80px; height: 80px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 2rem; }
.generating h2 { font-family: 'Fredoka', sans-serif; font-size: 1.6rem; margin-bottom: 0.5rem; }
.generating .sub { color: var(--text-dim); font-size: 0.9rem; }
.gen-steps { margin-top: 2rem; text-align: left; max-width: 300px; }
.gen-step { display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0; font-size: 0.85rem; color: var(--text-muted); transition: color 0.3s ease; }
.gen-step.done { color: var(--success); }
.gen-step.active { color: var(--text); }

/* ============ DASHBOARD ============ */
.dashboard { max-width: 500px; margin: 0 auto; width: 100%; }
.dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.dash-header h1 { font-family: 'Fredoka', sans-serif; font-size: 1.6rem; }
.dash-header .streak { background: var(--bg-card); border-radius: 50px; padding: 0.4rem 1rem; font-size: 0.85rem; display: flex; align-items: center; gap: 0.4rem; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; margin-bottom: 1rem; animation: slideUp 0.5s ease both;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.card-title { font-family: 'Fredoka', sans-serif; font-size: 1.1rem; font-weight: 600; }
.card-badge { font-size: 0.7rem; padding: 0.3rem 0.6rem; border-radius: 50px; font-weight: 600; }
.card-badge.today { background: rgba(0,153,255,0.2); color: var(--accent); }
.card-badge.rest { background: rgba(255,171,0,0.2); color: var(--warning); }

/* Stats Row */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; }
.stat .value { font-family: 'Fredoka', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat .label { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* Week Grid */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; }
.week-day {
  text-align: center; padding: 0.6rem 0.2rem; border-radius: var(--radius-sm);
  background: var(--bg-input); cursor: pointer; transition: all 0.3s ease;
}
.week-day.active { background: var(--accent); }
.week-day.rest-day { opacity: 0.5; }
.week-day .day-name { font-size: 0.6rem; text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.2rem; }
.week-day .day-type { font-size: 0.6rem; margin-top: 0.2rem; }
.week-day.active .day-name, .week-day.active .day-type { color: white; }

/* ============ WORKOUT SCREEN ============ */
.workout-screen { max-width: 500px; margin: 0 auto; width: 100%; }
.workout-header { margin-bottom: 1.5rem; }
.workout-header h1 { font-family: 'Fredoka', sans-serif; font-size: 1.5rem; }
.workout-header .muscle-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.muscle-tag { background: rgba(0,153,255,0.15); color: var(--accent); font-size: 0.7rem; padding: 0.2rem 0.6rem; border-radius: 50px; }

.exercise-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.8rem; transition: all 0.3s ease;
}
.exercise-card.completed { border-color: var(--success); opacity: 0.7; }
.exercise-top { display: flex; justify-content: space-between; align-items: flex-start; }
.exercise-name { font-weight: 600; font-size: 0.95rem; }
.exercise-detail { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.3rem; }
.exercise-sets { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }
.set-bubble {
  width: 36px; height: 36px; border-radius: 50%; background: var(--bg-input);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
}
.set-bubble.done { background: var(--accent); border-color: var(--accent); color: white; }

/* Rest Timer */
.rest-timer {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-card);
  border-top: 1px solid var(--border); padding: 1rem 1.5rem;
  display: none; align-items: center; justify-content: space-between;
  z-index: 100;
}
.rest-timer.active { display: flex; }
.timer-display { font-family: 'Fredoka', sans-serif; font-size: 2rem; font-weight: 700; color: var(--accent); }
.timer-label { font-size: 0.75rem; color: var(--text-dim); }

/* ============ NUTRITION SCREEN ============ */
.nutrition { max-width: 500px; margin: 0 auto; width: 100%; }
.macro-ring { display: flex; justify-content: center; gap: 1.5rem; margin: 1rem 0; }
.macro { text-align: center; }
.macro .circle {
  width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: 1rem; margin: 0 auto 0.3rem; border: 3px solid;
}
.macro .circle.protein { border-color: var(--accent); color: var(--accent); }
.macro .circle.carbs { border-color: var(--warning); color: var(--warning); }
.macro .circle.fat { border-color: var(--danger); color: var(--danger); }
.macro .name { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; }

.meal-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.8rem; }
.meal-card .meal-time { font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.meal-card .meal-name { font-weight: 600; margin: 0.3rem 0; }
.meal-card .meal-macros { font-size: 0.75rem; color: var(--text-dim); }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-card);
  border-top: 1px solid var(--border); display: none; justify-content: space-around;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom)); z-index: 50;
}
.bottom-nav.visible { display: flex; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  font-size: 0.65rem; color: var(--text-muted); cursor: pointer; padding: 0.3rem 1rem;
  transition: color 0.3s ease; text-decoration: none;
}
.nav-item.active { color: var(--accent); }
.nav-item .icon { font-size: 1.3rem; }

/* ============ UTILITIES ============ */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* Calories display */
.cal-display { text-align: center; margin: 1rem 0; }
.cal-number { font-family: 'Fredoka', sans-serif; font-size: 3rem; font-weight: 700; color: var(--accent); }
.cal-label { font-size: 0.8rem; color: var(--text-dim); }

@media (min-width: 600px) {
  .screen { padding: 2rem; }
  .welcome h1 { font-size: 4rem; }
}
