/* ============================================
   Sondage — Le sens du travail (Générations X/Y)
   Mobile-first, professional design
   ============================================ */

:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-bg: #EEF2FF;
  --bg: #F9FAFB;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-focus: #4F46E5;
  --error: #EF4444;
  --error-bg: #FEF2F2;
  --success: #10B981;
  --success-bg: #ECFDF5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --transition: 0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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;
}

/* ---- Progress Bar ---- */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 0.8rem;
  color: var(--text-light);
  white-space: nowrap;
  min-width: 100px;
  text-align: right;
}

/* ---- Main Container ---- */
.survey-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 20px 40px;
}

/* ---- Screens / Sections ---- */
.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

/* ---- Cards ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 24px;
}

.card-intro {
  text-align: center;
  padding: 48px 32px;
}

/* ---- Typography ---- */
.survey-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.3;
}

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

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

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

/* ---- Question Block ---- */
.question-block {
  margin-bottom: 32px;
}

.question-block:last-child {
  margin-bottom: 0;
}

.question-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: block;
}

.question-label .required {
  color: var(--error);
  margin-left: 2px;
}

.question-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ---- Radio Buttons ---- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.radio-option:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.radio-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition);
}

.radio-option input[type="radio"]:checked {
  border-color: var(--primary);
}

.radio-option input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.radio-option .option-text {
  font-size: 0.9rem;
  color: var(--text);
}

/* ---- Checkboxes ---- */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.checkbox-option:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.checkbox-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

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

.checkbox-option.disabled:hover {
  border-color: var(--border);
  background: transparent;
}

.checkbox-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition);
  margin-top: 1px;
}

.checkbox-option input[type="checkbox"]:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.checkbox-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-option .option-text {
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
}

/* ---- Multi-select with count ---- */
.multi-select-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
}

.multi-select-info .count {
  font-weight: 600;
  color: var(--primary);
}

/* ---- Text Inputs ---- */
.text-input,
.textarea-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--card);
  transition: border-color var(--transition);
  outline: none;
}

.text-input:focus,
.textarea-input:focus {
  border-color: var(--border-focus);
}

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

.textarea-input {
  resize: vertical;
  min-height: 100px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.char-count.warning {
  color: var(--error);
}

.conditional-field {
  margin-top: 12px;
  padding: 12px 16px;
  background: #F3F4F6;
  border-radius: var(--radius-sm);
  display: none;
}

.conditional-field.visible {
  display: block;
}

.conditional-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* ---- Affirmations (Q15) ---- */
.affirmation-item {
  margin-bottom: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all var(--transition);
}

.affirmation-item.checked {
  border-color: var(--primary);
}

.affirmation-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.affirmation-header:hover {
  background: var(--primary-bg);
}

.affirmation-body {
  padding: 0 16px 14px;
  display: none;
}

.affirmation-item.checked .affirmation-body {
  display: block;
}

.affirmation-body label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* ---- Ranking Component ---- */
.ranking-container {
  margin-top: 16px;
  display: none;
}

.ranking-container.visible {
  display: block;
}

.ranking-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.ranking-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
  touch-action: none;
}

.ranking-item:active {
  cursor: grabbing;
}

.ranking-item.dragging {
  opacity: 0.5;
  border-style: dashed;
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.ranking-item.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.rank-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.drag-handle {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
}

.ranking-item .item-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
}

.ranking-item .item-label input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}

.ranking-item .item-label input::placeholder {
  color: var(--text-muted);
}

.arrow-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.arrow-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.arrow-btn:hover:not(:disabled) {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

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

.arrow-btn svg {
  width: 14px;
  height: 14px;
}

/* ---- Navigation Buttons ---- */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  gap: 12px;
}

.btn {
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-primary:hover {
  background: #4338CA;
  border-color: #4338CA;
}

.btn-primary:disabled {
  background: var(--text-muted);
  border-color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-light);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #F3F4F6;
  border-color: #D1D5DB;
}

.btn-start {
  padding: 14px 40px;
  font-size: 1.05rem;
}

.btn-submit {
  width: 100%;
  justify-content: center;
  padding: 14px;
}

/* ---- Validation Errors ---- */
.field-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 6px;
  display: none;
}

.field-error.visible {
  display: block;
}

.question-block.has-error .radio-option,
.question-block.has-error .checkbox-option {
  border-color: #FCA5A5;
}

.question-block.has-error .text-input,
.question-block.has-error .textarea-input {
  border-color: var(--error);
}

/* ---- Intro & End Screens ---- */
.intro-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.intro-details {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.intro-detail {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.intro-detail svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.end-checkmark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.end-checkmark svg {
  width: 32px;
  height: 32px;
  color: var(--success);
}

/* ---- Loading Spinner ---- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Exclusion Screen ---- */
.exclusion-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .survey-container {
    padding: 70px 12px 24px;
  }

  .card {
    padding: 20px 16px;
    border-radius: var(--radius-sm);
  }

  .card-intro {
    padding: 32px 16px;
  }

  .survey-title {
    font-size: 1.35rem;
  }

  .nav-buttons {
    flex-direction: column-reverse;
  }

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

  .progress-container {
    padding: 10px 12px;
  }

  .intro-details {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
}

/* ---- Utility ---- */
.hidden {
  display: none !important;
}

.mt-12 {
  margin-top: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

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

/* ---- Feedback Section ---- */
.feedback-toggle {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}

.feedback-toggle:hover {
  color: #4338CA;
  text-decoration: underline;
}

.feedback-toggle.hidden {
  display: none;
}

.feedback-section {
  margin-top: 20px;
  display: none;
  text-align: left;
}

.feedback-section.visible {
  display: block;
}

.feedback-section .textarea-input {
  margin-bottom: 12px;
}

.btn-feedback {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

.feedback-confirm {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--success);
  display: none;
}

.feedback-confirm.visible {
  display: block;
}
