/* Sport Program — styles */
:root {
  --bg: #0b0f14;
  --bg-elev: #131a22;
  --bg-card: #171e27;
  --bg-card-hi: #1c2530;
  --border: #232c38;
  --border-hi: #2d3947;
  --text: #e6edf3;
  --text-muted: #8b96a5;
  --text-dim: #5c6674;
  --accent: #2ea043;
  --accent-hi: #3fb950;
  --accent-soft: rgba(46, 160, 67, .14);
  --blue: #58a6ff;
  --pink: #d67be6;
  --danger: #f85149;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-fa: "Segoe UI", Tahoma, "Iran Sans", Vazirmatn, "Iranian Sans", Arial, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(88, 166, 255, .07), transparent 60%),
    radial-gradient(800px 400px at 120% 20%, rgba(214, 123, 230, .05), transparent 60%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

html[dir="rtl"] body,
html[data-lang="fa"] body { font-family: var(--font-fa); }

button { font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* -------- Layout -------- */
.app-shell {
  max-width: 780px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* -------- Header -------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0 10px;
  margin: 0 -16px 18px;
  padding-inline: 16px;
  background: linear-gradient(180deg, rgba(11, 15, 20, .96) 0%, rgba(11, 15, 20, .82) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #1d7a34);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(46, 160, 67, .3);
}

.brand-icon svg { width: 22px; height: 22px; }

.app-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.2px;
  line-height: 1.1;
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.lang-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, background-color .15s;
  min-width: 34px;
}

.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(46, 160, 67, .35); }

.user-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.user-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .18s;
  text-align: start;
}

.user-tab:hover { background: var(--bg-card-hi); color: var(--text); }
.user-tab.active {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border-color: var(--accent);
  color: var(--text);
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  color: white;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  background: linear-gradient(135deg, var(--blue), #4c92e3);
  flex-shrink: 0;
}

.user-tab[data-user-set="razieh"] .user-avatar {
  background: linear-gradient(135deg, var(--pink), #b263c8);
}

.user-name { font-size: 15px; font-weight: 700; }

.progress-bar { padding-top: 2px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.progress-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.progress-count {
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.progress-count .slash { color: var(--text-dim); font-weight: 500; }

.progress-track {
  height: 6px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  border-radius: 999px;
  transition: width .35s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 0 12px rgba(63, 185, 80, .5);
}

/* -------- Content / cards -------- */
.content { flex: 1; }

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  animation: cardIn .35s cubic-bezier(.2, .8, .2, 1) both;
}
.exercise-card.completed {
  border-color: rgba(46, 160, 67, .55);
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 60%),
    var(--bg-card);
}
.exercise-card.completed .exercise-name {
  color: var(--text-muted);
}

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

/* Hero image on each card */
.exercise-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-elev);
  overflow: hidden;
}
.exercise-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}
.exercise-hero:hover img { transform: scale(1.04); }
.exercise-hero.placeholder {
  display: grid; place-items: center;
  color: var(--text-dim);
  aspect-ratio: 16 / 9;
}
.exercise-hero.placeholder svg { width: 64px; height: 64px; }

.hero-grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, transparent 40%, rgba(0,0,0,.7) 100%);
  pointer-events: none;
}

.hero-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  z-index: 2;
  pointer-events: none;
}

.hero-meta {
  position: absolute;
  bottom: 12px;
  inset-inline-start: 14px;
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
  z-index: 2;
  pointer-events: none;
  letter-spacing: .2px;
}

.hero-play {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 10px;
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #ff0033, #cc0022);
  color: white;
  border: 3px solid rgba(255, 255, 255, .95);
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .18s, box-shadow .18s;
  box-shadow: 0 6px 20px rgba(255, 0, 51, .45), 0 0 0 1px rgba(0, 0, 0, .3);
  z-index: 3;
}
.hero-play:hover { transform: scale(1.08); }
.hero-play:active { transform: scale(.96); }
.hero-play svg { width: 20px; height: 20px; margin-inline-start: 3px; }

.exercise-body {
  padding: 12px 14px 14px;
}

.exercise-name {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -.1px;
}

.set-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.set-item {
  --sz: 60px;
  min-width: var(--sz);
  height: var(--sz);
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  transition: all .18s;
  padding: 4px 10px;
  position: relative;
  overflow: hidden;
}
.set-item:hover { border-color: var(--border-hi); background: var(--bg-card-hi); }
.set-item:active { transform: scale(.97); }

.set-item .set-num {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.set-item .set-reps {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.set-item .set-unit {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 1px;
}

.set-item.done {
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  border-color: var(--accent-hi);
  color: white;
  box-shadow: 0 4px 14px rgba(46, 160, 67, .35);
}
.set-item.done .set-num,
.set-item.done .set-reps,
.set-item.done .set-unit { color: white; }
.set-item.done::after {
  content: "";
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 12px; height: 12px;
  background: white;
  color: var(--accent);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 900;
  display: grid; place-items: center;
  content: "✓";
  line-height: 12px;
}

.set-item.cardio {
  min-width: 140px;
  flex-direction: row;
  gap: 8px;
  padding-inline: 16px;
}
.set-item.cardio .set-num { font-size: 10px; }
.set-item.cardio .set-reps { font-size: 18px; }

/* -------- Footer -------- */
.footer {
  padding: 26px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
}

.footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 6px 18px rgba(46, 160, 67, .35);
  font-family: inherit;
}
.install-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(46, 160, 67, .45); }
.install-btn[hidden] { display: none; }

.reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.reset-btn:hover { color: var(--danger); border-color: rgba(248, 81, 73, .55); background: rgba(248, 81, 73, .08); }

.link-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}
.link-btn:hover { color: var(--text-muted); }

.footer-info { font-size: 11px; color: var(--text-dim); line-height: 1.5; padding: 0 8px; }
.footer-info .dot { margin: 0 6px; color: var(--text-dim); }

/* Install diagnostic modal */
.install-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
}
.check-row .check-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.check-row .check-detail {
  color: var(--text-dim);
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
}
.check-row .check-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  color: white;
  margin-top: 1px;
}
.check-row.pass .check-icon { background: var(--accent); }
.check-row.fail .check-icon { background: var(--danger); }
.check-row.fail { border-color: rgba(248, 81, 73, .4); }

.install-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}
.install-banner.ok { background: var(--accent-soft); color: var(--accent-hi); border: 1px solid rgba(46, 160, 67, .35); }
.install-banner.warn { background: rgba(210, 153, 34, .12); color: #d29922; border: 1px solid rgba(210, 153, 34, .35); }

.install-hint p { font-size: 13px; color: var(--text-muted); line-height: 1.5; padding: 0 4px; margin-bottom: 12px; }

.install-debug {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  word-break: break-all;
}
.install-debug code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* -------- Modals -------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: modalIn .18s ease;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: modalPop .22s cubic-bezier(.2, .8, .2, 1);
}
.modal-content-img { background: transparent; border: none; box-shadow: none; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.modal-header h2 { font-size: 15px; font-weight: 700; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 0 6px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--bg-card-hi); }

.modal-close-floating {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  background: rgba(0, 0, 0, .6);
  color: white;
  border-radius: 50%;
  width: 36px; height: 36px;
  z-index: 5;
  font-size: 22px;
  display: grid; place-items: center;
}

.modal-body { padding: 16px; }

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}
.video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.btn-search-yt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 16px;
  background: #ff0000;
  color: white !important;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  transition: transform .15s, box-shadow .15s;
}
.btn-search-yt:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 0, 0, .35); }

.modal-content-img img {
  width: 100%;
  max-height: 92vh;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
}

@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* -------- Toast -------- */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toastIn .22s ease;
  color: var(--text);
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

/* -------- Responsive -------- */
@media (max-width: 480px) {
  .exercise-name { font-size: 16px; }
  .set-item { --sz: 54px; }
  .set-item .set-reps { font-size: 15px; }
  .brand-icon { width: 36px; height: 36px; }
  .brand-icon svg { width: 20px; height: 20px; }
  .app-title { font-size: 17px; }
  .footer-info { font-size: 10.5px; }
  .hero-play { width: 46px; height: 46px; }
  .hero-play svg { width: 18px; height: 18px; }
  .hero-badge { font-size: 10.5px; padding: 3px 9px; }
  .hero-meta { font-size: 12px; bottom: 10px; }
}

@media (max-width: 360px) {
  .set-item { --sz: 50px; min-width: 50px; }
  .app-subtitle { display: none; }
}

/* -------- RTL tweaks -------- */
html[dir="rtl"] .hero-play svg { transform: scaleX(-1); margin-inline-start: 0; margin-inline-end: 3px; }
html[dir="rtl"] .modal-close-floating { inset-inline-end: auto; inset-inline-start: 8px; }
