/* ========================================
   CPFT Trainer - Styles
   Premium Military-Inspired Dark Theme
======================================== */

:root {
  /* Colors */
  --bg-primary: #0a0f1c;
  --bg-secondary: #111827;
  --bg-card: rgba(30, 41, 59, 0.7);
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(148, 163, 184, 0.1);
  
  /* Spacing */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  
  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Effects */
  --glass-bg: rgba(30, 41, 59, 0.6);
  --glass-border: rgba(148, 163, 184, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

#app {
  height: 100%;
  overflow: hidden;
}

/* ========================================
   Glass Effect
======================================== */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

/* ========================================
   Screens
======================================== */

.screen {
  display: none;
  height: 100%;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

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

/* ========================================
   Onboarding Screen
======================================== */

#onboarding {
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #0a0f1c 0%, #1e293b 100%);
}

.onboard-content {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo-badge {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border-radius: 20px;
  box-shadow: 0 0 40px var(--accent-glow);
}

.logo-icon {
  font-size: 40px;
}

#onboarding h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 15px;
}

.setup-card {
  padding: 24px;
  text-align: left;
}

.setup-card h2 {
  font-size: 18px;
  margin-bottom: 20px;
  text-align: center;
}

/* ========================================
   Form Elements
======================================== */

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font);
  transition: all 0.2s ease;
}

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

.toggle-group {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.toggle-btn:active {
  transform: scale(0.98);
}

/* ========================================
   Buttons
======================================== */

.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

.btn-secondary {
  padding: 14px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-success {
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--success), #059669);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger {
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 12px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
}

/* ========================================
   Dashboard
======================================== */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.greeting {
  display: flex;
  flex-direction: column;
}

.greeting-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.user-name {
  font-size: 24px;
  font-weight: 700;
}

.test-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  margin-bottom: 24px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.badge-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.badge-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  display: block;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.exercise-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.exercise-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.exercise-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border-radius: 14px;
  font-size: 24px;
}

.exercise-info {
  flex: 1;
}

.exercise-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.exercise-goal {
  font-size: 13px;
  color: var(--text-secondary);
}

.exercise-arrow {
  color: var(--text-muted);
  font-size: 20px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.action-icon {
  font-size: 28px;
}

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

/* ========================================
   Exercise Screen
======================================== */

.screen-title {
  font-size: 18px;
  font-weight: 700;
}

.back-btn {
  font-size: 22px;
}

.spacer {
  width: 44px;
}

.exercise-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.timer-ring {
  position: relative;
  width: 220px;
  height: 220px;
}

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

.ring-bg {
  fill: none;
  stroke: var(--bg-secondary);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

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

.timer-value {
  font-size: 48px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timer-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.rep-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  margin-bottom: 16px;
}

.rep-btn {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 50%;
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rep-btn:active {
  transform: scale(0.95);
  background: var(--accent);
  border-color: var(--accent);
}

.rep-btn.plus {
  background: var(--accent);
  border-color: var(--accent);
}

.rep-display {
  text-align: center;
}

.rep-value {
  font-size: 64px;
  font-weight: 800;
  display: block;
  line-height: 1;
}

.rep-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.goal-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  margin-bottom: 24px;
}

.goal-label {
  color: var(--text-secondary);
}

.goal-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
}

.goal-unit {
  color: var(--text-secondary);
}

.exercise-controls {
  display: flex;
  gap: 12px;
}

.exercise-controls button {
  flex: 1;
}

/* ========================================
   Standards Screen
======================================== */

.standards-toggle {
  display: flex;
  padding: 6px;
  margin-bottom: 20px;
}

.std-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}

.std-btn.active {
  background: var(--accent);
  color: white;
}

.standards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.standard-card {
  padding: 16px;
}

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

.standard-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border-radius: 10px;
  font-size: 18px;
}

.standard-name {
  font-size: 16px;
  font-weight: 600;
}

.standard-values {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.std-value-box {
  background: rgba(15, 23, 42, 0.6);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}

.std-value-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.std-value-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--success);
}

/* ========================================
   Progress Screen
======================================== */

.progress-tabs {
  display: flex;
  padding: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.chart-container {
  padding: 20px;
  margin-bottom: 20px;
  height: 200px;
}

#progressChart {
  width: 100% !important;
  height: 100% !important;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.history-date {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-value {
  font-size: 18px;
  font-weight: 700;
}

/* ========================================
   Modal
======================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions button {
  flex: 1;
}

/* ========================================
   Utilities
======================================== */

.hidden {
  display: none !important;
}
