/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --bg-input: #0f0f1a;

  --text-primary: #eaeaf0;
  --text-secondary: #8888a0;
  --text-muted: #55556a;

  --accent: #7c5cfc;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 92, 252, 0.25);
  --accent-gradient: linear-gradient(135deg, #7c5cfc 0%, #c084fc 100%);

  --success: #34d399;
  --warning: #fbbf24;

  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(124, 92, 252, 0.3);

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

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   RESET & BASE
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ========================================
   PAGE SYSTEM
   ======================================== */
.page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateX(30px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    visibility 0s 0.35s;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    visibility 0s 0s;
}

.page.slide-out-left {
  opacity: 0;
  transform: translateX(-30px);
}

/* ========================================
   HOME PAGE
   ======================================== */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  position: relative;
}

/* Ambient glow behind the hero */
.home-container::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero-section {
  text-align: center;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}

.hero-icon-wrapper {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: var(--shadow-glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: var(--shadow-glow);
  }
  50% {
    box-shadow:
      0 0 60px var(--accent-glow),
      0 0 80px rgba(124, 92, 252, 0.1);
  }
}

.hero-icon {
  font-size: 36px;
  color: #fff;
}

.hero-title {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 4px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

/* Menu Buttons */
.menu-buttons {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.menu-btn:active {
  transform: scale(0.97);
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.menu-btn-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  color: #fff;
}

.menu-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.menu-btn-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.menu-btn-desc {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.menu-btn-arrow {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.menu-btn:active .menu-btn-arrow {
  transform: translateX(3px);
}

/* ========================================
   TOP BAR / NAVIGATION
   ======================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent-light);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-family: var(--font);
}

.back-btn:active {
  background: rgba(124, 92, 252, 0.1);
  transform: scale(0.95);
}

.back-btn i {
  font-size: 20px;
}

.top-bar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.top-bar-spacer {
  width: 72px;
}

/* ========================================
   PAGE CONTENT
   ======================================== */
.page-content {
  flex: 1;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ========================================
   CALCULATOR CARD
   ======================================== */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.calc-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-light);
}

.calc-card-header i {
  font-size: 20px;
}

/* Input Groups */
.input-group-custom {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group-custom label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  height: 56px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-icon {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font);
  outline: none;
  width: 0;
  min-width: 0;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* Remove number input spinners */
.input-wrapper input[type='number']::-webkit-inner-spin-button,
.input-wrapper input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-wrapper input[type='number'] {
  -moz-appearance: textfield;
}

.input-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Calculate Button */
.calc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 56px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-glow);
  margin-top: 4px;
}

.calc-btn:active {
  transform: scale(0.97);
  box-shadow: 0 0 20px var(--accent-glow);
}

.calc-btn i {
  font-size: 20px;
}

/* ========================================
   RESULT CARD
   ======================================== */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 32px 20px 24px;
  text-align: center;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: slide-up 0.4s ease;
}

.result-card.visible {
  display: flex;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.result-value {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.result-unit {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-breakdown {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Percentage Table */
.percentage-table {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

.pct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

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

.pct-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pct-bar-container {
  flex: 1;
  margin: 0 16px;
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.pct-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pct-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 55px;
  text-align: right;
}

/* ========================================
   EMPTY STATE (TRAINING PAGE)
   ======================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 40px 24px;
}

.empty-icon-wrapper {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-muted);
  margin-bottom: 20px;
  animation: gentle-bounce 2.5s ease-in-out infinite;
}

@keyframes gentle-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.empty-state h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ========================================
   SHAKE ANIMATION (Validation Error)
   ======================================== */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.4s ease;
}

.input-wrapper.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ========================================
   TRAINING PAGE - SETS
   ======================================== */
.training-sets {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.set-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: slide-up 0.4s ease;
  animation-fill-mode: backwards;
  transition: all var(--transition);
}

.set-card.pr-set {
  border-color: var(--border-accent);
  background: linear-gradient(
    135deg,
    rgba(124, 92, 252, 0.08) 0%,
    rgba(192, 132, 252, 0.05) 100%
  );
}

.set-card.completed {
  opacity: 0.5;
  border-color: rgba(52, 211, 153, 0.3);
}

.set-number {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.set-card.pr-set .set-number {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
}

.set-card.completed .set-number {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.set-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.set-weight {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.set-card.pr-set .set-weight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.set-details {
  display: flex;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-direction: column;
}

.set-details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.set-details i {
  font-size: 13px;
}

.set-timer-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 252, 0.12);
  border: 1px solid var(--border-accent);
  color: var(--accent-light);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.set-timer-btn:active {
  transform: scale(0.92);
  background: rgba(124, 92, 252, 0.25);
}

.set-timer-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.set-timer-btn.done {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.set-pr-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-light);
  background: rgba(124, 92, 252, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ========================================
   TIMER OVERLAY
   ======================================== */
.timer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0s 0.3s;
}

.timer-overlay.active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.3s ease,
    visibility 0s 0s;
}

.timer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.timer-set-info {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.timer-display {
  font-size: 80px;
  font-weight: 700;
  letter-spacing: -4px;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

.timer-progress-ring {
  width: 350px;
  height: 350px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.timer-progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 4;
}

.timer-ring-fill {
  fill: none;
  stroke: url(#timer-gradient);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.timer-actions {
  margin-top: 32px;
  z-index: 2;
}

.timer-btn-cancel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #ef4444;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.timer-btn-cancel:active {
  transform: scale(0.95);
  background: rgba(239, 68, 68, 0.25);
}

.timer-btn-success {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-sm);
  color: #34d399;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.timer-btn-success:active {
  transform: scale(0.95);
  background: rgba(52, 211, 153, 0.25);
}

/* Timer flash effect when done */
@keyframes timer-flash {
  0%,
  100% {
    background: rgba(10, 10, 15, 0.95);
  }
  25%,
  75% {
    background: rgba(52, 211, 153, 0.15);
  }
  50% {
    background: rgba(52, 211, 153, 0.25);
  }
}

.timer-overlay.finished {
  animation: timer-flash 1.5s ease 3;
}

.timer-overlay.finished .timer-display {
  color: var(--success);
  animation: pulse-scale 0.6s ease infinite alternate;
}

@keyframes pulse-scale {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}
