/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 20px;
  height: 20px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:active {
  background: var(--bg-elevated);
  transform: scale(0.98);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:active {
  opacity: 0.9;
  transform: scale(0.98);
}

.btn-large {
  padding: 16px 32px;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Icon Button */
.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

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

.icon-btn:active {
  background: var(--bg-elevated);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn var(--transition-fast);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-secondary);
  width: 100%;
  max-height: 95vh;
  max-height: 95dvh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--transition-normal);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h2 {
  flex: 1;
  font-size: 1.1rem;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* Workout Player */
.workout-player-content {
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-area-top) + 12px) 16px 12px;
  background: var(--bg-primary);
}

.player-header h2 {
  flex: 1;
  font-size: 1rem;
  text-align: center;
}

.player-progress {
  padding: 0 20px 16px;
  background: var(--bg-primary);
}

.player-progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.player-progress-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.exercise-display {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.exercise-image {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.exercise-image svg {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
}

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

.exercise-name {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.exercise-instruction {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

/* Timer Display */
.timer-display {
  text-align: center;
}

.timer-circle {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}

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

.timer-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-label {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

/* Set Tracker */
.set-tracker {
  width: 100%;
  max-width: 320px;
  margin-top: 24px;
}

.set-info {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 20px;
}

.set-label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-right: 8px;
}

.set-current {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.set-separator {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.set-total {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.rep-weight-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input {
  width: 100%;
  padding: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  outline: none;
}

.input-group input:focus {
  border-color: var(--primary);
}

/* Player Controls */
.player-controls {
  display: flex;
  gap: 12px;
  padding: 16px 20px calc(16px + var(--safe-area-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.player-controls .btn {
  flex: 1;
}

.player-controls .btn-primary {
  flex: 2;
}

/* Exercise Detail Modal */
.exercise-detail-content {
  max-height: 90vh;
  max-height: 90dvh;
}

.exercise-detail-image {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.exercise-detail-image svg {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
}

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

.exercise-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.exercise-section {
  margin-bottom: 24px;
}

.exercise-section h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.exercise-steps {
  padding-left: 20px;
}

.exercise-steps li {
  margin-bottom: 8px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.exercise-cues,
.exercise-mistakes {
  list-style: none;
}

.exercise-cues li,
.exercise-mistakes li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.exercise-cues li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--secondary);
  font-weight: bold;
}

.exercise-mistakes li::before {
  content: "✗";
  position: absolute;
  left: 0;
  color: var(--danger);
  font-weight: bold;
}

/* Program Detail Modal */
.program-detail-content {
  max-height: 90vh;
  max-height: 90dvh;
}

.program-detail-header {
  margin-bottom: 24px;
}

.program-description {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.program-meta {
  display: flex;
  gap: 20px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.meta-item svg {
  width: 18px;
  height: 18px;
}

.program-schedule {
  margin-bottom: 24px;
}

.week-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.week-header {
  padding: 14px 16px;
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.week-header .completed-badge {
  background: var(--secondary);
  color: white;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: var(--radius-full);
}

.week-days {
  padding: 12px 16px;
}

.day-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.day-item:last-child {
  border-bottom: none;
}

.day-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.day-workout {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Settings Modal */
.settings-content {
  max-height: 85vh;
  max-height: 85dvh;
}

.settings-group {
  margin-bottom: 28px;
}

.settings-group h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.settings-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.settings-text.small {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-group .btn {
  margin-bottom: 12px;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--transition-normal);
  pointer-events: auto;
}

.toast.success {
  background: var(--secondary);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

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

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

/* Attribution Link */
.attribution {
  padding: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.attribution a {
  color: var(--primary-light);
  text-decoration: none;
}

/* Video Link Button */
.video-link {
  margin-top: 8px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  color: white;
}

.video-link:active {
  opacity: 0.9;
  transform: scale(0.98);
}

.video-link svg {
  width: 18px;
  height: 18px;
}
