/* =============================
   CALCULATEUR — styles
============================= */

/* Nav inherited from quiz.css */
.calc-main {
  padding: 7rem 0 5rem;
  min-height: 100vh;
  background: var(--bg);
}

/* ---- HEADER ---- */
.calc-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.calc-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin: 1.5rem 0 1rem;
}

.calc-sub {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}

/* ---- API KEY ---- */
.api-key-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 1.5rem 2rem;
  margin-bottom: 2.5rem;
}

.api-key-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.api-key-label {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.api-key-icon {
  font-size: 1.2rem;
  line-height: 1.5;
  flex-shrink: 0;
}

.api-key-label strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.api-key-label p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.api-key-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg);
}

.api-key-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: monospace;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  width: 100%;
}

.api-key-field input::placeholder {
  color: var(--text-faint);
}

#api-key-toggle {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  cursor: pointer;
  line-height: 0;
  transition: color 0.2s;
}

#api-key-toggle:hover {
  color: var(--text);
}

.api-key-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.api-key-hint strong {
  color: var(--text);
}

/* ---- FORM LAYOUT ---- */
.calc-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---- FORM SECTIONS ---- */
.form-section {
  border: 1px solid var(--border);
  background: var(--surface);
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--accent);
  color: var(--accent-soft);
  font-size: 0.72rem;
  flex-shrink: 0;
  line-height: 1;
}

.section-sub {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0;
}

/* ---- FORM GRID (inside sections) ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 1.75rem;
}

.field-wide {
  grid-column: 1 / -1;
}

/* Field labels */
.form-field > label:first-child,
.form-field > label[for] {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Number inputs */
.form-field input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.form-field input[type="number"]::-webkit-inner-spin-button,
.form-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.form-field input[type="number"]:focus {
  border-color: var(--text-muted);
}

/* ---- RADIO PILLS (horizontal) ---- */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.radio-option {
  cursor: pointer;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.4rem;
  padding: 0 1.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}

.radio-option input:checked + span {
  border-color: var(--accent-soft);
  border-width: 1.5px;
  background: rgba(231, 76, 60, 0.1);
  color: var(--text);
  font-weight: 500;
}

.radio-option:hover span {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ---- RADIO COL (vertical list) ---- */
.radio-group-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.radio-group-col .radio-option {
  flex: none;
}

.radio-group-col .radio-option span {
  height: auto;
  min-height: 2.4rem;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  padding: 0.6rem 1rem;
}

/* ---- SYMPTOM / TOGGLE ROWS ---- */
.symptom-list {
  display: flex;
  flex-direction: column;
  padding: 0 1.75rem;
  border-top: 1px solid var(--border);
}

/* When symptom-list follows form-section-title directly (no form-grid between them) */
.form-section-title + .symptom-list {
  border-top: none;
}

.symptom-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.symptom-item:last-child {
  border-bottom: none;
  padding-bottom: 1.75rem;
}

.symptom-text {
  flex: 1;
  min-width: 0;
}

.symptom-text strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.symptom-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.symptom-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.toggle-option {
  cursor: pointer;
}

.toggle-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.2rem;
  padding: 0 0.9rem;
  min-width: 3.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}

.toggle-option input:checked + span {
  border-color: var(--accent-soft);
  border-width: 1.5px;
  background: rgba(231, 76, 60, 0.1);
  color: var(--text);
  font-weight: 500;
}

.toggle-option:hover span {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ---- IMC ROW ---- */
.imc-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
  padding: 1.5rem 1.75rem 1.75rem;
  border-top: 1px solid var(--border);
}

.imc-row .form-field > label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  font-weight: 400;
}

.imc-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 130px;
  height: 2.9rem; /* matches input height */
  gap: 0;
}

.imc-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  line-height: 1.2;
}

.imc-value {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.imc-category {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.imc-category.imc-low          { color: #3498db; }
.imc-category.imc-normal        { color: #27ae60; }
.imc-category.imc-overweight    { color: #e67e22; }
.imc-category.imc-obese         { color: var(--accent-soft); }
.imc-category.imc-obese-severe  { color: var(--accent-soft); }

/* ---- SUBMIT ---- */
.form-submit-area {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.form-error {
  font-size: 0.88rem;
  color: var(--accent-soft);
  padding: 0.75rem 1rem;
  border: 1px solid rgba(231, 76, 60, 0.3);
  background: rgba(231, 76, 60, 0.06);
  width: 100%;
}

.btn-calc {
  padding: 1rem 3rem;
  background: var(--accent);
  border: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  min-width: 260px;
}

.btn-calc:hover:not(:disabled) {
  background: var(--accent-soft);
}

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

/* Loading dots */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  margin-right: 0.5rem;
}

.loading-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  animation: dotPulse 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---- RESULTS ---- */
.calc-result {
  margin-top: 3rem;
  animation: fadeUp 0.4s ease both;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
  transition: border-left-color 0.4s;
}

.result-header:has(.risk-faible) { border-left-color: #27ae60; }
.result-header:has(.risk-modere) { border-left-color: #e67e22; }
.result-header:has(.risk-eleve)  { border-left-color: var(--accent-soft); }

.risk-badge {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.risk-label {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.risk-level {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  text-transform: capitalize;
  transition: color 0.4s;
}

.risk-level.risk-faible { color: #27ae60; }
.risk-level.risk-modere { color: #e67e22; }
.risk-level.risk-eleve  { color: var(--accent-soft); }

.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  align-self: flex-start;
}

.btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* Result content — rendered markdown */
.result-content {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.8;
  min-height: 4rem;
}

.result-content h2 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.result-content h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.result-content p {
  color: var(--text);
  margin-bottom: 1rem;
}

.result-content strong {
  color: var(--text);
  font-weight: 500;
}

.result-content ul {
  padding-left: 1.2rem;
  margin-bottom: 1rem;
}

.result-content li {
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.result-content li::marker {
  color: var(--accent-soft);
}

/* Streaming cursor */
.result-content .cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent-soft);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Disclaimer */
.result-disclaimer {
  margin-top: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
}

.result-disclaimer p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.result-disclaimer strong {
  color: var(--text);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
  .symptom-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .symptom-toggle {
    flex-wrap: wrap;
  }

  .form-grid {
    grid-template-columns: 1fr;
    padding: 1.25rem;
  }

  .symptom-list {
    padding: 0 1.25rem;
  }

  .form-section-title + .symptom-list {
    padding: 0 1.25rem;
  }

  .imc-row {
    grid-template-columns: 1fr 1fr;
    padding: 1.25rem;
  }

  .imc-display {
    grid-column: 1 / -1;
    height: auto;
    padding: 0.75rem;
    flex-direction: row;
    gap: 0.75rem;
    justify-content: flex-start;
  }

  .imc-value {
    font-size: 1.4rem;
  }

  .form-section-title {
    padding: 0.9rem 1.25rem;
    font-size: 0.82rem;
  }

  .section-sub {
    display: none;
  }

  .result-header {
    padding: 1.25rem;
  }

  .risk-level {
    font-size: 2.4rem;
  }

  .btn-calc {
    width: 100%;
    min-width: unset;
  }
}
