/* ============================================================
   بدنساز هوشمند — Round 4 Styling Upgrade
   Rest timer, achievement badges, calendar view, polish
   ============================================================ */

/* ============================================================
   REST TIMER MODAL
   ============================================================ */
.timer-modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(9,9,15,.85); backdrop-filter: blur(12px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.timer-modal.open { display: flex; animation: fadeIn .25s; }
.timer-card {
  background: var(--surf1); border: 1px solid var(--border2); border-radius: 24px;
  padding: 40px 36px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: var(--shadow-gold); position: relative;
}
.timer-close {
  position: absolute; top: 16px; left: 16px; width: 36px; height: 36px;
  background: var(--surf2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 10px; font-size: 18px; cursor: pointer; transition: var(--transition);
}
.timer-close:hover { color: var(--danger); border-color: var(--danger); }
.timer-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 16px; }
.timer-display {
  font-size: 80px; font-weight: 900; line-height: 1; color: var(--gold);
  font-variant-numeric: tabular-nums; margin-bottom: 8px; letter-spacing: -.02em;
}
.timer-display.warn { color: var(--push); animation: pulseGold 1s infinite; }
.timer-status { font-size: 14px; color: var(--text-2); margin-bottom: 24px; min-height: 20px; }

/* Circular progress */
.timer-ring-wrap { position: relative; width: 240px; height: 240px; margin: 0 auto 24px; }
.timer-ring { transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 8; }
.timer-ring .bg { stroke: var(--surf3); }
.timer-ring .fg { stroke: url(#timerGrad); stroke-linecap: round; transition: stroke-dashoffset .9s linear; }
.timer-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.timer-presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.timer-preset {
  background: var(--surf2); border: 1px solid var(--border); color: var(--text-2);
  padding: 8px 14px; border-radius: 10px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: var(--transition); font-family: inherit;
}
.timer-preset:hover { border-color: var(--gold); color: var(--gold); }
.timer-preset.active { background: var(--gold); color: #1a1208; border-color: var(--gold); }

.timer-controls { display: flex; gap: 10px; justify-content: center; }
.timer-controls .btn { min-width: 90px; }

/* Rest timer trigger button (in program) */
.rest-timer-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(74,141,224,.1); border: 1px solid rgba(74,141,224,.3);
  color: var(--pull); padding: 5px 11px; border-radius: 8px;
  font-size: 11px; font-weight: 700; cursor: pointer; transition: var(--transition);
  font-family: inherit; vertical-align: middle;
}
.rest-timer-btn:hover { background: rgba(74,141,224,.2); }

/* ============================================================
   ACHIEVEMENT BADGES
   ============================================================ */
.badge-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.badge-card {
  background: var(--surf1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 22px 16px; text-align: center; position: relative; overflow: hidden;
  transition: var(--transition);
}
.badge-card.earned { border-color: rgba(212,168,67,.3); background: linear-gradient(160deg, var(--surf1), var(--gold-dim)); }
.badge-card.earned::before {
  content: ''; position: absolute; top: -50%; right: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, var(--gold-glow), transparent 50%);
  opacity: .15; pointer-events: none;
}
.badge-card:hover { transform: translateY(-3px); border-color: var(--gold); }

.badge-icon {
  width: 70px; height: 70px; margin: 0 auto 14px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 32px; position: relative;
  background: var(--surf3); border: 2px solid var(--border2);
}
.badge-card.earned .badge-icon {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border-color: var(--gold2); box-shadow: 0 0 20px var(--gold-glow);
}
.badge-card.earned .badge-icon::after {
  content: '✓'; position: absolute; bottom: -4px; right: -4px;
  width: 24px; height: 24px; background: var(--success); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; border: 2px solid var(--bg);
}
.badge-card:not(.earned) .badge-icon { filter: grayscale(1); opacity: .5; }

.badge-title { font-size: 13px; font-weight: 800; margin-bottom: 4px; }
.badge-card:not(.earned) .badge-title { color: var(--muted); }
.badge-desc { font-size: 11px; color: var(--muted); line-height: 1.6; min-height: 32px; }
.badge-tier {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 5px; margin-top: 8px; text-transform: uppercase; letter-spacing: .05em;
}
.badge-tier.bronze   { background: rgba(205,127,50,.15); color: #cd7f32; }
.badge-tier.silver   { background: rgba(192,192,192,.15); color: #c0c0c0; }
.badge-tier.gold     { background: var(--gold-dim); color: var(--gold); }
.badge-tier.platinum { background: rgba(229,228,226,.15); color: #e5e4e2; }

.badge-progress-summary {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  background: var(--surf1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px 24px; margin-bottom: 24px;
}
.bps-count { font-size: 32px; font-weight: 900; color: var(--gold); line-height: 1; }
.bps-label { font-size: 13px; color: var(--muted); }
.bps-bar-wrap { flex: 1; min-width: 160px; }
.bps-bar { height: 8px; background: var(--surf3); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bps-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 6px; transition: width 1s cubic-bezier(.2,.7,.2,1); }

/* Achievement toast (celebration) */
.toast.achievement {
  border-right-color: var(--gold); background: linear-gradient(135deg, var(--surf1), var(--gold-dim));
  border: 1px solid rgba(212,168,67,.4);
}
.toast.achievement .ic { font-size: 24px; animation: pulseGold 1s infinite; }

/* ============================================================
   WEEKLY CALENDAR VIEW (program)
   ============================================================ */
.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 24px;
}
@media (max-width: 900px) { .cal-week { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .cal-week { grid-template-columns: 1fr; } }

.cal-cell {
  background: var(--surf1); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; min-height: 140px; cursor: pointer; transition: var(--transition);
  position: relative; display: flex; flex-direction: column; gap: 8px;
}
.cal-cell:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow); }
.cal-cell.today { border-color: var(--gold); background: linear-gradient(160deg, var(--surf1), var(--gold-dim)); }
.cal-cell.rest { background: var(--surf2); opacity: .7; }
.cal-cell.done { border-color: var(--success); }
.cal-cell.done::after {
  content: '✓'; position: absolute; top: 10px; left: 10px;
  width: 26px; height: 26px; background: var(--success); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; box-shadow: 0 2px 8px rgba(62,188,120,.4);
}

.cal-day-name { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cal-cell.today .cal-day-name { color: var(--gold); }
.cal-type-pill {
  font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 5px;
  align-self: flex-start; white-space: nowrap;
}
.cal-cell .cal-label { font-size: 14px; font-weight: 700; }
.cal-cell .cal-desc { font-size: 11px; color: var(--muted); line-height: 1.5; flex: 1; }
.cal-cell .cal-go {
  font-size: 11px; color: var(--gold); font-weight: 700;
  display: flex; align-items: center; gap: 4px; margin-top: auto;
}
.cal-cell:hover .cal-go { gap: 7px; }

.cal-legend {
  display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted);
  margin-bottom: 20px; padding: 14px 18px; background: var(--surf1);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.cal-legend .li { display: flex; align-items: center; gap: 6px; }
.cal-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ============================================================
   VIEW TOGGLE (tabs/calendar)
   ============================================================ */
.prog-view-toggle {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.view-toggle-pill {
  display: inline-flex; background: var(--surf2); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; gap: 2px;
}
.view-toggle-pill button {
  padding: 9px 18px; border-radius: 9px; font-size: 13px; font-weight: 700;
  background: none; border: none; color: var(--muted); cursor: pointer;
  transition: var(--transition); font-family: inherit; display: flex; align-items: center; gap: 6px;
}
.view-toggle-pill button:hover { color: var(--text); }
.view-toggle-pill button.active { background: var(--gold); color: #1a1208; }

/* ============================================================
   PROFILE PAGE BADGES SECTION
   ============================================================ */
.profile-badges {
  background: var(--surf1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 24px; margin-top: 22px;
}
.profile-badges h3 { font-size: 16px; font-weight: 800; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.profile-badge-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.profile-badge-strip::-webkit-scrollbar { height: 6px; }
.profile-badge-strip::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.mini-badge {
  flex-shrink: 0; width: 80px; text-align: center;
}
.mini-badge .mb-ic {
  width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border: 2px solid var(--gold2);
}
.mini-badge.locked .mb-ic { background: var(--surf3); border-color: var(--border2); filter: grayscale(1); opacity: .4; }
.mini-badge .mb-lb { font-size: 10px; color: var(--muted); line-height: 1.3; }
.mini-badge.locked .mb-lb { opacity: .5; }

/* ============================================================
   IMPROVED DASHBOARD (round 4)
   ============================================================ */
.dash-hero {
  background: linear-gradient(135deg, var(--surf1), var(--surf2));
  border: 1px solid var(--border2); border-radius: var(--r);
  padding: 28px; position: relative; overflow: hidden; margin-bottom: 22px;
}
.dash-hero::before {
  content: ''; position: absolute; top: -60px; left: -60px; width: 200px; height: 200px;
  background: radial-gradient(circle, var(--gold-glow), transparent 60%); opacity: .5;
}
.dash-hero-content { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.dash-hero h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.dash-hero p { font-size: 13px; color: var(--muted); }

.dash-quick-stat {
  display: flex; align-items: center; gap: 10px;
  background: var(--surf2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-size: 13px;
}
.dash-quick-stat .ic { font-size: 20px; }
.dash-quick-stat .v { font-weight: 800; color: var(--gold); }

/* ============================================================
   IMPROVED SECTION DIVIDERS
   ============================================================ */
.section-divider {
  display: flex; align-items: center; gap: 14px; margin: 30px 0 18px;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.section-divider span { font-size: 12px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }

/* ============================================================
   STATS IMPROVEMENT (sparkline)
   ============================================================ */
.spark-stat { position: relative; }
.spark-stat .sparkline {
  position: absolute; bottom: 10px; left: 16px; right: 16px; height: 24px; opacity: .5;
}

/* ============================================================
   ACHIEVEMENT UNLOCK MODAL (celebration)
   ============================================================ */
.celebration-modal {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(9,9,15,.92); backdrop-filter: blur(16px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.celebration-modal.open { display: flex; animation: fadeIn .4s; }
.celebration-card {
  background: linear-gradient(160deg, var(--surf1), var(--surf2));
  border: 1px solid rgba(212,168,67,.4); border-radius: 24px;
  padding: 44px 36px; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px -10px rgba(212,168,67,.4); position: relative;
}
.celebration-icon {
  width: 110px; height: 110px; margin: 0 auto 24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 56px; background: linear-gradient(135deg, var(--gold), var(--gold2));
  border: 4px solid var(--gold2); box-shadow: 0 0 40px var(--gold-glow);
  animation: bounceIn .6s cubic-bezier(.2,.7,.2,1);
}
@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.celebration-card h2 { font-size: 22px; font-weight: 900; margin-bottom: 10px; color: var(--gold); }
.celebration-card .ach-name { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.celebration-card .ach-desc { font-size: 14px; color: var(--text-2); margin-bottom: 24px; line-height: 1.7; }
.celebration-tier { margin-bottom: 24px; }

.confetti {
  position: absolute; width: 8px; height: 8px; opacity: 0;
  animation: confetti-fall 2s ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(-100px) rotate(0); }
  100% { opacity: 0; transform: translateY(400px) rotate(720deg); }
}
