/* Martial Arts Trainer — Mobile-first PWA */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #f97316;
  --accent-dim: #ea580c;
  --green: #22c55e;
  --red: #ef4444;
  --border: #334155;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Safe area for iOS notch */
.app {
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}

.header h1 {
  font-size: 18px;
  font-weight: 700;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

.header-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Bottom nav --- */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}

.nav button.active {
  color: var(--accent);
}

.nav button svg {
  width: 22px;
  height: 22px;
}

/* --- Page content --- */
.page {
  display: none;
  padding: 16px;
}

.page.active {
  display: block;
}

/* --- Calendar --- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.cal-nav {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 16px;
}

.cal-day-label {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0;
  font-weight: 600;
}

.cal-day {
  text-align: center;
  padding: 8px 0;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.cal-day:hover { background: var(--bg-input); }
.cal-day.today { border: 2px solid var(--accent); }
.cal-day.selected { background: var(--accent); color: white; font-weight: 700; }
.cal-day.other-month { color: var(--bg-input); }
.cal-day.has-event {
  background: rgba(249, 115, 22, 0.15);
  font-weight: 600;
}

.cal-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Keep accent bg when selected + has-event */
.cal-day.selected.has-event {
  background: var(--accent);
}

/* --- Calendar view toggle --- */
.cal-view-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 3px;
}

.cal-view-toggle button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.cal-view-toggle button svg {
  width: 16px;
  height: 16px;
}

.cal-view-toggle button.active {
  background: var(--accent);
  color: white;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--border); }
.card:active { border-color: var(--accent); }

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-meta {
  font-size: 13px;
  color: var(--text-dim);
}

.card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-training { background: #1e3a5f; color: #60a5fa; }
.badge-competition { background: #3b1f2b; color: #f472b6; }
.badge-camp { background: #1a3329; color: #4ade80; }

/* --- Exercise type badges --- */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text-dim);
}

/* --- Buttons --- */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:active { opacity: 0.8; }
.btn-primary { background: var(--accent); color: white; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-success { background: var(--green); color: white; }

/* --- Form inputs --- */
.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 500;
}

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.input-group input:focus,
.input-group textarea:focus {
  border-color: var(--accent);
}

/* --- Rating --- */
.rating {
  display: flex;
  gap: 8px;
}

.rating button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.rating button.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* --- Exercise log sets --- */
.set-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.set-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

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

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

/* --- Previous data --- */
.prev-data {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.prev-data h4 {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prev-data .prev-set {
  font-size: 13px;
  color: var(--text-dim);
  padding: 2px 0;
}

/* --- Summary --- */
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-child { border-bottom: none; }

/* --- Search --- */
.search-bar {
  position: relative;
  margin-bottom: 12px;
}

.search-bar input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

/* --- Filter chips --- */
.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* --- Video link --- */
.video-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.video-link:active { background: var(--bg-input); }

/* --- Video embed --- */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 177%; /* 9:16 aspect ratio for Shorts/Reels */
  max-height: 70vh;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
  background: #000;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* --- Progress indicator --- */
.progress-bar {
  display: flex;
  gap: 4px;
  margin: 12px 0;
}

.progress-dot {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: var(--bg-input);
}

.progress-dot.done { background: var(--green); }
.progress-dot.current { background: var(--accent); }

/* --- Empty state --- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty p { font-size: 14px; }

/* --- Section header --- */
.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 16px 0 8px;
  font-weight: 600;
}

/* --- Utilities --- */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.fw-600 { font-weight: 600; }

/* --- Step-by-step --- */
.steps-list { display: flex; flex-direction: column; gap: 12px; }
.step-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px;
  border-left: 3px solid var(--accent);
}
.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.step-num {
  background: var(--accent);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}
.step-time {
  font-size: 12px;
  color: var(--accent);
  background: rgba(255,107,53,0.12);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 600;
}
.step-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
}
