/* ========================================
   CSS Design System — Workout Plan App
   Mobile-first, RTL, Dark theme
   ======================================== */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #12121f;
  --bg-surface: #1a1a2e;
  --bg-surface-hover: #222240;
  --bg-card: #16162b;
  --bg-card-hover: #1e1e3a;

  --accent-primary: #7c6cf0;
  --accent-secondary: #a78bfa;
  --accent-glow: rgba(124, 108, 240, 0.3);
  --accent-gradient: linear-gradient(135deg, #7c6cf0 0%, #a78bfa 100%);

  --color-success: #00d68f;
  --color-warning: #ffb020;
  --color-danger: #ff4757;
  --color-info: #3b82f6;

  --text-primary: #e8e8f4;
  --text-secondary: #9898b8;
  --text-muted: #6868a0;
  --text-on-accent: #ffffff;

  --border-color: rgba(124, 108, 240, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.06);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background subtle gradient */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(124, 108, 240, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(167, 139, 250, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- App Header ---------- */
.app-header {
  position: relative;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 20px 16px 16px;
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.header-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 8px rgba(124, 108, 240, 0.4));
}

.header-title h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-stats {
  display: flex;
  gap: 10px;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  flex: 1;
  transition: var(--transition-normal);
}

.stat-badge:hover {
  border-color: var(--border-color);
  transform: translateY(-2px);
}

.stat-badge.accent {
  border-color: var(--accent-primary);
  background: rgba(124, 108, 240, 0.1);
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-secondary);
}

.stat-badge.accent .stat-value {
  font-size: 1.2rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Day Tabs ---------- */
.day-tabs {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 6px;
  padding: 12px 12px;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.day-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex: 1;
  min-width: 80px;
  transition: var(--transition-normal);
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

.tab-btn:active {
  transform: scale(0.96);
}

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.tab-sub {
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.tab-btn.active .tab-sub {
  color: rgba(255, 255, 255, 0.8);
}

/* ---------- Main Content ---------- */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 12px;
}

/* ---------- Section Header ---------- */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.section-icon {
  font-size: 1.4rem;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---------- Warmup Section ---------- */
.warmup-section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
}

.warmup-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.warmup-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-normal);
}

.warmup-step:hover {
  border-color: var(--border-color);
}

.warmup-number {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.warmup-info {
  flex: 1;
}

.warmup-info h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.warmup-info p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.warmup-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-secondary);
  white-space: nowrap;
  background: rgba(124, 108, 240, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Knee warmup warning */
.knee-warmup {
  border-color: rgba(255, 176, 32, 0.3);
  background: rgba(255, 176, 32, 0.05);
}

.warning-header h2 {
  color: var(--color-warning);
}

.warning-step {
  border-color: rgba(255, 176, 32, 0.2);
}

.warning-step .warmup-number {
  background: linear-gradient(135deg, #ffb020, #ff8c00);
}

/* ---------- Exercises Section ---------- */
.exercises-section {
  margin-bottom: 24px;
}

.exercises-section .section-header {
  padding: 0 4px;
}

.exercises-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Exercise Card ---------- */
.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-normal);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.exercise-card:hover {
  border-color: var(--border-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.exercise-card:active {
  transform: scale(0.98);
}

.exercise-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.exercise-number {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.exercise-title-group {
  flex: 1;
}

.exercise-name-fa {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.exercise-name-en {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  direction: ltr;
  text-align: right;
}

.exercise-expand-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: var(--transition-normal);
}

.exercise-card.expanded .exercise-expand-icon {
  transform: rotate(180deg);
}

/* Exercise Stats Bar */
.exercise-stats {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.exercise-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-left: 1px solid var(--border-subtle);
}

.exercise-stat:last-child {
  border-left: none;
}

.exercise-stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-secondary);
}

.exercise-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Exercise Image */
.exercise-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-surface);
  overflow: hidden;
}

.exercise-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-slow);
}

.exercise-image-container:hover img {
  transform: scale(1.05);
}

.exercise-image-label {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  color: var(--text-primary);
  font-weight: 600;
}

.image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
}

.image-placeholder .placeholder-icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

.image-placeholder .placeholder-text {
  font-size: 0.75rem;
  opacity: 0.5;
}

/* Exercise Detail (Expandable) */
.exercise-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.exercise-card.expanded .exercise-detail {
  max-height: 2000px;
}

.exercise-detail-inner {
  padding: 16px;
}

/* Target Muscles */
.target-muscles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.muscle-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(124, 108, 240, 0.1);
  border: 1px solid rgba(124, 108, 240, 0.2);
  font-size: 0.7rem;
  color: var(--accent-secondary);
  font-weight: 500;
}

.muscle-tag.primary {
  background: rgba(0, 214, 143, 0.1);
  border-color: rgba(0, 214, 143, 0.2);
  color: var(--color-success);
}

/* How To Steps */
.how-to-section {
  margin-bottom: 16px;
}

.how-to-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.how-to-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.how-to-step {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--accent-primary);
}

.step-number {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--bg-card-hover);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Safety Tips */
.safety-tips {
  background: rgba(255, 71, 87, 0.06);
  border: 1px solid rgba(255, 71, 87, 0.15);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.safety-tips-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-danger);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.safety-tip-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.safety-tip-item:last-child {
  margin-bottom: 0;
}

.safety-tip-item::before {
  content: '⚠️';
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---------- Cardio Section ---------- */
.cardio-section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
}

.cardio-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cardio-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.cardio-step-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cardio-step-detail {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.cardio-step-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-success);
  white-space: nowrap;
  background: rgba(0, 214, 143, 0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.hiit-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.62rem;
  font-weight: 700;
  margin-right: 6px;
}

/* ---------- Stretch Section ---------- */
.stretch-section {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid rgba(0, 214, 143, 0.15);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
}

.stretch-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stretch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.stretch-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stretch-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stretch-duration {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-info);
  white-space: nowrap;
}

.stretch-warning {
  border-color: rgba(255, 176, 32, 0.2);
}

.stretch-warning .stretch-duration {
  color: var(--color-warning);
}

/* ---------- Safety Section ---------- */
.safety-section {
  max-width: 600px;
  margin: 0 auto 24px;
  padding: 0 12px;
  position: relative;
  z-index: 1;
}

.safety-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.safety-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border-subtle);
}

.safety-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.knee-safety {
  border-color: rgba(255, 176, 32, 0.2);
}

.knee-safety h3 {
  color: var(--color-warning);
}

.back-safety {
  border-color: rgba(255, 71, 87, 0.2);
}

.back-safety h3 {
  color: var(--color-danger);
}

.safety-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.safety-card li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-right: 16px;
  position: relative;
}

.safety-card li::before {
  content: '•';
  position: absolute;
  right: 0;
  color: var(--text-muted);
  font-weight: 800;
}

/* ---------- Tips Section ---------- */
.tips-section {
  max-width: 600px;
  margin: 0 auto 40px;
  padding: 0 12px;
  position: relative;
  z-index: 1;
}

.tips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tip-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition-normal);
}

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

.tip-icon {
  font-size: 1.3rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overscroll-behavior: contain;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  font-family: var(--font-family);
}

.modal-close::before {
  content: '';
  width: 40px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  position: absolute;
  top: 8px;
}

.modal-body {
  padding: 0;
}

/* Modal Exercise Image */
.modal-exercise-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-surface);
  overflow: hidden;
}

.modal-exercise-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-exercise-info {
  padding: 20px 16px;
}

.modal-exercise-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.modal-exercise-name-en {
  font-size: 0.82rem;
  color: var(--text-muted);
  direction: ltr;
  text-align: right;
  margin-bottom: 16px;
}

.modal-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-stat {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.modal-stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-secondary);
  display: block;
}

.modal-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
@media (min-width: 480px) {
  .safety-grid {
    grid-template-columns: 1fr 1fr;
  }

  .exercise-card-header {
    padding: 18px 20px;
  }

  .main-content {
    padding: 20px 16px;
  }
}

@media (min-width: 600px) {
  .app-header {
    padding: 28px 24px 20px;
  }

  .header-title h1 {
    font-size: 1.8rem;
  }

  .tab-btn {
    padding: 12px 18px;
  }
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.exercise-card {
  animation: fadeInUp 0.4s ease both;
}

.exercise-card:nth-child(1) { animation-delay: 0.05s; }
.exercise-card:nth-child(2) { animation-delay: 0.1s; }
.exercise-card:nth-child(3) { animation-delay: 0.15s; }
.exercise-card:nth-child(4) { animation-delay: 0.2s; }
.exercise-card:nth-child(5) { animation-delay: 0.25s; }
.exercise-card:nth-child(6) { animation-delay: 0.3s; }

/* Loading shimmer */
.shimmer {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface-hover);
  border-radius: var(--radius-full);
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(124, 108, 240, 0.3);
  color: var(--text-primary);
}
