/* =====================================================
   AG102 GAMIFICATION ENGINE — Styles
   =====================================================
   Dashboard panel, radar chart, exercise log modal,
   4-minute routine player, achievement notifications.
   Uses --ag-* CSS variables from global.css.
   ===================================================== */

/* =========================================================================
   GAMIFICATION DASHBOARD PANEL
   ========================================================================= */

.gamification-section {
  margin: 24px 0;
}

.gamification-panel {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  padding: 24px;
  box-shadow: var(--ag-shadow);
}

.gamification-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.gamification-panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ag-text);
  margin: 0;
}

.gam-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ag-primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Stats row: points, streak */
.gam-stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.gam-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ag-bg-alt);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  padding: 12px 16px;
  flex: 1;
  min-width: 140px;
}

.gam-stat-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.gam-stat-info {
  display: flex;
  flex-direction: column;
}

.gam-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ag-text);
  line-height: 1;
}

.gam-stat-label {
  font-size: 0.75rem;
  color: var(--ag-text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* Level progress bar */
.gam-level-progress {
  margin-bottom: 24px;
}

.gam-level-progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.gam-level-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ag-text);
}

.gam-level-subtitle {
  font-size: 0.8125rem;
  color: var(--ag-text-muted);
}

.gam-progress-bar-track {
  height: 10px;
  background: var(--ag-bg-alt);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--ag-border);
}

.gam-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ag-primary), var(--ag-accent));
  border-radius: 5px;
  transition: width 0.6s ease;
  min-width: 2px;
}

/* =========================================================================
   RADAR CHART + PILLAR LIST LAYOUT
   ========================================================================= */

.gam-radar-section {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.gam-radar-container {
  flex: 0 0 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gam-radar-container svg {
  max-width: 100%;
  height: auto;
}

.gam-pillar-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.gam-pillar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--ag-bg-alt);
  border-radius: var(--ag-radius-sm);
  border: 1px solid var(--ag-border);
}

.gam-pillar-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.gam-pillar-info {
  flex: 1;
}

.gam-pillar-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ag-text);
  line-height: 1;
}

.gam-pillar-title {
  font-size: 0.75rem;
  color: var(--ag-text-muted);
  margin-top: 1px;
}

.gam-pillar-pts {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ag-primary);
  white-space: nowrap;
}

/* =========================================================================
   QUICK ACTIONS
   ========================================================================= */

.gam-quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gam-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--ag-radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 48px;
  flex: 1;
  min-width: 150px;
  justify-content: center;
}

.gam-action-btn-primary {
  background: var(--ag-primary);
  color: #fff;
}

.gam-action-btn-primary:hover {
  background: var(--ag-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--ag-shadow-lg);
}

.gam-action-btn-secondary {
  background: var(--ag-bg-alt);
  color: var(--ag-text);
  border: 1px solid var(--ag-border);
}

.gam-action-btn-secondary:hover {
  background: var(--ag-border);
  transform: translateY(-1px);
}

.gam-action-btn-accent {
  background: var(--ag-accent);
  color: #fff;
}

.gam-action-btn-accent:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--ag-shadow-lg);
}

/* Active template progress */
.gam-template-progress {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--ag-bg-alt);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  border-left: 4px solid var(--ag-primary);
}

.gam-template-progress-label {
  font-size: 0.75rem;
  color: var(--ag-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.gam-template-progress-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ag-text);
  margin-bottom: 6px;
}

.gam-template-progress-bar-track {
  height: 6px;
  background: var(--ag-border);
  border-radius: 3px;
  overflow: hidden;
}

.gam-template-progress-bar-fill {
  height: 100%;
  background: var(--ag-primary);
  border-radius: 3px;
  transition: width 0.4s;
}

/* =========================================================================
   EXERCISE LOG MODAL
   ========================================================================= */

.gam-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gam-modal-overlay.hidden {
  display: none;
}

.gam-modal {
  background: var(--ag-surface);
  border-radius: var(--ag-radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.gam-modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ag-text);
  margin: 0 0 6px;
}

.gam-modal-subtitle {
  font-size: 0.875rem;
  color: var(--ag-text-muted);
  margin: 0 0 20px;
}

.gam-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--ag-text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--ag-radius-sm);
  transition: all 0.15s;
}

.gam-modal-close:hover {
  background: var(--ag-bg-alt);
  color: var(--ag-text);
}

.gam-form-group {
  margin-bottom: 16px;
}

.gam-form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ag-text);
  margin-bottom: 6px;
}

.gam-form-input,
.gam-form-select,
.gam-form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--ag-text);
  background: var(--ag-bg-alt);
  transition: border-color 0.2s;
  min-height: 48px;
  box-sizing: border-box;
}

.gam-form-input:focus,
.gam-form-select:focus,
.gam-form-textarea:focus {
  outline: none;
  border-color: var(--ag-primary);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.15);
}

.gam-form-textarea {
  min-height: 80px;
  resize: vertical;
}

.gam-form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.gam-form-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--ag-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.gam-form-check-label {
  font-size: 0.9375rem;
  color: var(--ag-text);
}

.gam-form-row {
  display: flex;
  gap: 12px;
}

.gam-form-row .gam-form-group {
  flex: 1;
}

.gam-form-submit {
  width: 100%;
  padding: 14px;
  background: var(--ag-primary);
  color: #fff;
  border: none;
  border-radius: var(--ag-radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  min-height: 48px;
  margin-top: 8px;
}

.gam-form-submit:hover {
  background: var(--ag-primary-hover);
  transform: translateY(-1px);
}

.gam-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.gam-points-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(139, 69, 19, 0.08);
  border: 1px solid rgba(139, 69, 19, 0.2);
  border-radius: var(--ag-radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ag-primary);
}

/* =========================================================================
   4-MINUTE ROUTINE PLAYER (full-screen overlay)
   ========================================================================= */

.routine-player-overlay {
  position: fixed;
  inset: 0;
  background: #0B1120;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.routine-player-overlay.hidden {
  display: none;
}

.routine-player-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--ag-radius-md);
  color: #fff;
  font-size: 1.25rem;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.routine-player-close:hover {
  background: rgba(255,255,255,0.15);
}

.routine-player-content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.routine-player-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-align: center;
  margin: 0;
}

/* Timer circle */
.routine-timer-wrap {
  position: relative;
  width: 200px;
  height: 200px;
}

.routine-timer-svg {
  transform: rotate(-90deg);
  width: 200px;
  height: 200px;
}

.routine-timer-track {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 12;
}

.routine-timer-progress {
  fill: none;
  stroke: #D4A574;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.routine-timer-progress.rest-phase {
  stroke: #4A90D9;
}

.routine-timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.routine-timer-seconds {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.routine-timer-phase {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Exercise info */
.routine-exercise-info {
  text-align: center;
}

.routine-exercise-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 8px;
}

.routine-exercise-instructions {
  font-size: 0.9375rem;
  color: rgba(255,255,255,0.6);
  margin: 0;
  line-height: 1.5;
  max-width: 360px;
}

/* Exercise progress bar */
.routine-exercise-progress {
  width: 100%;
}

.routine-exercise-progress-label {
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.routine-exercise-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.routine-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s;
}

.routine-dot.done {
  background: var(--ag-success);
}

.routine-dot.current {
  background: #D4A574;
  transform: scale(1.3);
}

/* Controls */
.routine-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.routine-btn {
  border: none;
  border-radius: var(--ag-radius-md);
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: all 0.2s;
  min-height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.routine-btn-play {
  background: #D4A574;
  color: #0B1120;
  font-size: 1rem;
  padding: 14px 28px;
  gap: 8px;
  min-width: 140px;
}

.routine-btn-play:hover {
  background: #C49060;
  transform: translateY(-1px);
}

.routine-btn-skip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  font-size: 0.9375rem;
  padding: 14px 20px;
}

.routine-btn-skip:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Completion screen */
.routine-completion {
  text-align: center;
  display: none;
}

.routine-completion.visible {
  display: block;
}

.routine-completion-icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

.routine-completion-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 8px;
}

.routine-completion-points {
  font-size: 1.25rem;
  color: #D4A574;
  font-weight: 700;
  margin-bottom: 20px;
}

.routine-completion-btn {
  background: var(--ag-primary);
  color: #fff;
  border: none;
  border-radius: var(--ag-radius-md);
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  min-height: 48px;
}

.routine-completion-btn:hover {
  background: var(--ag-primary-hover);
  transform: translateY(-1px);
}

/* =========================================================================
   ACHIEVEMENT TOAST NOTIFICATIONS
   ========================================================================= */

.gam-notifications {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  pointer-events: none;
}

.gam-toast {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: all;
  animation: gam-toast-in 0.3s ease;
}

.gam-toast.gam-toast-exit {
  animation: gam-toast-out 0.3s ease forwards;
}

@keyframes gam-toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gam-toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

.gam-toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.gam-toast-body {
  flex: 1;
}

.gam-toast-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ag-text);
  margin: 0 0 2px;
}

.gam-toast-message {
  font-size: 0.8125rem;
  color: var(--ag-text-muted);
  margin: 0;
}

.gam-toast-points {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--ag-primary);
  flex-shrink: 0;
  align-self: center;
}

/* Points toast variant */
.gam-toast-pts {
  border-left: 4px solid var(--ag-primary);
}

/* Achievement toast variant */
.gam-toast-achievement {
  border-left: 4px solid #D4A574;
}

/* Level up toast variant */
.gam-toast-levelup {
  border-left: 4px solid var(--ag-success);
}

/* =========================================================================
   TEMPLATE BROWSER
   ========================================================================= */

.gam-template-browser {
  margin-top: 24px;
}

.gam-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.gam-template-card {
  background: var(--ag-bg-alt);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.gam-template-card:hover {
  border-color: var(--ag-primary);
  box-shadow: var(--ag-shadow);
}

.gam-template-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.gam-template-card.enrolled {
  border-color: var(--ag-success);
  border-width: 2px;
}

.gam-template-pillar-tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(139, 69, 19, 0.1);
  color: var(--ag-primary);
  margin-bottom: 8px;
}

.gam-template-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ag-text);
  margin: 0 0 4px;
}

.gam-template-desc {
  font-size: 0.8125rem;
  color: var(--ag-text-muted);
  margin: 0;
  line-height: 1.4;
}

.gam-template-lock-icon {
  font-size: 1.25rem;
  margin-bottom: 4px;
  display: block;
}

/* =========================================================================
   MOBILE RESPONSIVE
   ========================================================================= */

@media (max-width: 600px) {
  .gamification-panel {
    padding: 16px;
  }

  .gam-stats-row {
    gap: 10px;
  }

  .gam-stat {
    min-width: 120px;
    padding: 10px 12px;
  }

  .gam-stat-value {
    font-size: 1.25rem;
  }

  .gam-radar-section {
    flex-direction: column;
    align-items: center;
  }

  .gam-radar-container {
    flex: none;
    width: 100%;
    max-width: 220px;
  }

  .gam-pillar-list {
    width: 100%;
  }

  .gam-quick-actions {
    gap: 8px;
  }

  .gam-action-btn {
    min-width: 0;
    font-size: 0.875rem;
    padding: 12px 12px;
  }

  .gam-notifications {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .routine-player-content {
    gap: 16px;
  }

  .routine-timer-wrap {
    width: 160px;
    height: 160px;
  }

  .routine-timer-svg {
    width: 160px;
    height: 160px;
  }

  .routine-timer-seconds {
    font-size: 2.25rem;
  }

  .routine-exercise-name {
    font-size: 1.25rem;
  }
}

@media (max-width: 400px) {
  .gam-stats-row {
    flex-direction: column;
  }

  .gam-stat {
    width: 100%;
  }
}
