/* The Man Plan - Intake Core Styles
   Shared styles for all intake forms (Nutrition, Fitness, etc.)
*/

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Man Plan Brand Colors */
  --brand-blue: #2E3748;
  --brand-white: #EDE8D0;
  --brand-red: #E63946;

  /* Semantic mapping */
  --primary: var(--brand-red);
  --primary-dark: #c42d39;
  --primary-light: rgba(230, 57, 70, 0.15);
  --secondary: #8b9cb3;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: var(--brand-red);
  --error: #ef4444;

  /* Dark theme */
  --text: var(--brand-white);
  --text-light: #a8a28f;
  --bg: var(--brand-blue);
  --bg-card: #3a4556;
  --bg-input: #252d3a;
  --white: var(--brand-white);
  --border: #4a5568;

  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Selection color */
::selection {
  background: var(--primary);
  color: var(--brand-white);
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.tagline {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* Brand Header */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-logo {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
}

.brand-logo span {
  color: #e74c3c;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.4);
}

/* Progress Bar */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-bottom: 8px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 12.5%;
}

.step-indicator {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Form Sections */
.form-section {
  display: none;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.form-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.form-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.section-subtitle {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 1rem;
}

/* Form Groups */
.form-group {
  margin-bottom: 24px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group > label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-light);
}

/* Select dropdown arrow for dark theme */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23EDE8D0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  appearance: none;
}

/* Time input icon color fix */
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.help-text {
  display: block;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* Height Picker */
.height-picker {
  display: flex;
  gap: 12px;
}

.height-picker select {
  flex: 1;
}

/* Character Counter */
.char-count {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* Checkbox and Radio Groups */
.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

@media (max-width: 480px) {
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.checkbox-label:hover,
.radio-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.checkbox-label input,
.radio-label input {
  margin-top: 2px;
  accent-color: var(--primary);
}

.checkbox-label span,
.radio-label span {
  flex: 1;
}

.checkbox-label input:checked + span,
.radio-label input:checked + span {
  color: var(--primary);
  font-weight: 500;
}

/* Radio Cards */
.radio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.radio-card {
  display: block;
  padding: 20px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.radio-card:hover {
  border-color: var(--primary);
}

.radio-card input {
  display: none;
}

.radio-card input:checked + .card-content {
  color: var(--primary);
}

.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.card-content strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.card-content span {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Inline Checkbox */
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.checkbox-inline input {
  accent-color: var(--primary);
}

/* Tag Input */
.tag-input-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-input);
}

.tag-input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: var(--brand-white);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.875rem;
}

.tag-remove {
  background: none;
  border: none;
  color: var(--brand-white);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
}

.tag-remove:hover {
  opacity: 1;
}

.tag-input-container input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 120px;
  padding: 4px 0;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
}

.tag-input-container input:focus {
  box-shadow: none;
}

.suggestions {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--text-light);
}

.suggestion-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  margin-left: 4px;
  transition: all 0.2s;
}

.suggestion-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Form Navigation */
.form-navigation {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

#next-btn,
#submit-btn {
  margin-left: auto;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  color: var(--text);
}

.modal-content h2 {
  margin-bottom: 24px;
  font-size: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 24px;
}

/* Results Summary */
#results-summary {
  display: grid;
  gap: 16px;
}

.summary-card {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.summary-card h3 {
  font-size: 0.875rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.summary-card p {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.summary-card .value-highlight {
  color: var(--primary);
}

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

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* Validation States */
.form-group.error input,
.form-group.error select,
.form-group.error textarea {
  border-color: var(--danger);
}

.form-group.error .help-text {
  color: var(--danger);
}

.radio-group.error {
  padding: 8px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

/* Calculated Stats Panel */
.calculated-stats {
  margin-top: 32px;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg-input) 0%, var(--bg) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.calculated-stats h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.stats-note {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-status {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 4px;
  min-height: 1.2em;
}

.stat-status.status-good { color: var(--success); }
.stat-status.status-warning { color: var(--warning); }
.stat-status.status-danger { color: var(--danger); }

/* IR Likelihood Meter */
.ir-likelihood {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.ir-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ir-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.ir-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
}

.ir-value.risk-low { color: var(--success); }
.ir-value.risk-moderate { color: var(--warning); }
.ir-value.risk-high { color: var(--danger); }

.ir-meter {
  height: 8px;
  background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
  border-radius: 4px;
  position: relative;
  margin-bottom: 8px;
}

.ir-meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.ir-meter-indicator {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: var(--brand-white);
  border: 3px solid var(--bg);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 0.3s ease;
  left: 0;
  opacity: 0;
}

.ir-meter-indicator.visible {
  opacity: 1;
}

.ir-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Method Explanation */
.method-explanation {
  font-size: 0.875rem;
  color: var(--text-light);
}

.method-explanation summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--primary);
  padding: 8px 0;
}

.method-explanation summary:hover {
  text-decoration: underline;
}

.method-explanation p {
  margin-top: 8px;
  line-height: 1.6;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}

/* Welcome Modal Styles */
.welcome-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  box-sizing: border-box;
}

.welcome-modal.hidden {
  display: none;
}

.welcome-content {
  background: linear-gradient(135deg, #1a2332 0%, #2d3a4d 100%);
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  color: #fff;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.welcome-logo {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 2px;
  margin-bottom: 8px;
  color: #fff;
}

.welcome-logo span {
  color: #e74c3c;
}

.welcome-tagline {
  font-size: 14px;
  opacity: 0.7;
  margin-bottom: 32px;
  font-style: italic;
}

.welcome-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.welcome-subtitle {
  font-size: 18px;
  opacity: 0.9;
  margin-bottom: 32px;
  line-height: 1.5;
}

.welcome-features {
  text-align: left;
  margin-bottom: 32px;
  padding: 0 20px;
}

.welcome-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 15px;
  opacity: 0.95;
}

.welcome-feature:last-child {
  margin-bottom: 0;
}

.welcome-feature-icon {
  color: #27ae60;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.welcome-time {
  font-size: 14px;
  opacity: 0.6;
  margin-bottom: 24px;
}

.welcome-btn {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: 'Montserrat', sans-serif;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(231, 76, 60, 0.4);
}

.welcome-footer {
  margin-top: 24px;
  font-size: 13px;
  opacity: 0.5;
}

/* Cross-intake offer modal */
.offer-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 20px;
}

.offer-modal.active {
  display: flex;
}

.offer-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
}

.offer-content h3 {
  font-size: 1.5rem;
  margin-bottom: 16px;
  color: var(--text);
}

.offer-content p {
  color: var(--text-light);
  margin-bottom: 24px;
  line-height: 1.5;
}

.offer-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.offer-actions .btn-primary {
  width: 100%;
}

.offer-actions .btn-secondary {
  width: 100%;
  background: transparent;
}

/* Equipment suggestion callout */
.equipment-suggestion {
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.15) 0%, rgba(74, 144, 226, 0.05) 100%);
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.equipment-suggestion-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.equipment-suggestion-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.equipment-suggestion-text strong {
  color: #4a90e2;
}

/* Tier badge */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.tier-badge.level-1 {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.2) 0%, rgba(74, 222, 128, 0.05) 100%);
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: var(--success);
}

.tier-badge.level-2 {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2) 0%, rgba(251, 191, 36, 0.05) 100%);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--warning);
}

.tier-badge.level-3 {
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.2) 0%, rgba(230, 57, 70, 0.05) 100%);
  border: 1px solid rgba(230, 57, 70, 0.4);
  color: var(--primary);
}

/* Exercise card for review */
.exercise-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.exercise-card:last-child {
  margin-bottom: 0;
}

.exercise-image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-card);
}

.exercise-info {
  flex: 1;
}

.exercise-name {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.exercise-details {
  font-size: 0.875rem;
  color: var(--text-light);
}

.exercise-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 16px;
  }

  .form-section {
    padding: 24px 16px;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .welcome-content {
    padding: 32px 24px;
  }

  .welcome-logo {
    font-size: 22px;
  }

  .welcome-title {
    font-size: 26px;
  }

  .welcome-subtitle {
    font-size: 16px;
  }

  .welcome-features {
    padding: 0;
  }

  .exercise-card {
    flex-direction: column;
    text-align: center;
  }

  .exercise-image {
    width: 120px;
    height: 120px;
  }

  .exercise-actions {
    width: 100%;
    justify-content: center;
  }
}
