/* ============================================================
   AdaptUP - Fiche aide technique
   Fichier : adaptup.css
   ============================================================ */

/* Les couleurs, rayons et ombres sont dans static/css/jetons.css,
   chargee avant cette feuille. Ne pas redefinir de valeur ici. */

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

body {
  font-family: 'Sora', sans-serif;
  background: var(--color-bg);
  padding: 32px;
  color: var(--color-ink);
}

/* ============================================================
   CARD PRINCIPALE
   ============================================================ */
.card {
  max-width: 900px;
  margin: auto;
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 30px;
  box-shadow: var(--shadow-card);
}

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

.title {
  font-size: 24px;
  font-weight: 600;
}

.btn-reset {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: var(--color-muted);
  padding: 4px 8px;
  border-radius: 8px;
  transition: all .15s;
  white-space: nowrap;
}
.btn-reset svg { flex-shrink: 0; width: 13px; height: 13px; }
.btn-reset:hover {
  color: var(--color-ink);
  background: var(--color-line);
}

.content {
  display: flex;
  gap: 60px;
  flex-wrap: wrap;
}

/* ============================================================
   IMAGE + TITRE DU MODELE (titre centre au dessus de la photo)
   ============================================================ */
.image {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.image .model-title {
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 28px;
  color: var(--color-ink);
  margin: 0;
  text-align: center;
  line-height: 1.2;
  width: 100%;
}
.image img {
  width: 100%;
  border-radius: 58px;
}

/* ============================================================
   FORM HEADER (bouton reset aligne a droite, au dessus des
   entetes Valeur/Plage)
   ============================================================ */
.form-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 4px;
  min-height: 28px;
}

/* Formulaire cotes */
.form { flex: 1; min-width: 260px; }

/* En-tete colonnes */
.dim-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-line);
}
.dim-header-spacer       { width: 28px; flex-shrink: 0; }
.dim-header-label        { flex: 1; font-size: 11px; color: #CCC; }
.dim-header-input        { width: 76px; text-align: center; font-size: 11px; color: var(--color-hint); }
.dim-header-reset-spacer { width: 21px; flex-shrink: 0; margin-left: 2px; }
.dim-header-range        { width: 64px; text-align: right; font-size: 11px; color: var(--color-hint); }

/* Lignes de cotes */
.dimension {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .2s;
}
.dimension.modified .dot          { background: var(--color-violet); }
.dimension.modified input         { border-color: var(--color-violet); background: var(--color-violet-lt); }

.dimension label { flex: 1; font-size: 14px; }

.dimension input {
  width: 76px;
  padding: 8px;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--color-border);
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border .15s;
  background: #ffffff; 
}

.dimension select {
  width: 76px;
  padding: 8px;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--color-border);
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border .15s;
  background: #ffffff;
  color: var(--color-ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23BBB'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

.dimension select:focus {
  border-color: var(--color-green);
}

.dimension input:hover {
  border-color: #bbb; /* réaction subtile au survol */
}

.dimension input:focus { border-color: var(--color-green); }

.dimension input.cote-text,
.dimension select.cote-list {
  width: 76px;
  height: 28px;
  box-sizing: border-box;
  padding: 2px 6px;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  background: #ffffff;
  color: var(--color-ink);
  appearance: none;
  -webkit-appearance: none;
}

/* F1 (review n6, lot d aout) : le chevron n appartient qu aux listes
   deroulantes. Il figurait dans le bloc ci-dessus, partage avec les
   champs texte, qui heritaient donc d une fleche sans menu.
   Ce correctif vivait dans la copie inline de fitUP ; il remonte ici,
   a la place exacte des regles d origine, pour que l ordre de cascade
   soit preserve quand fitUP cesse de recopier ce fichier. */
.dimension select.cote-list {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23BBB'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

.dimension input.cote-text {
  min-width: 76px;
  width: auto;
  max-width: 220px;
}

.dimension input.cote-text:focus,
.dimension select.cote-list:focus {
  outline: none;
  border-color: var(--color-green);
}

.dimension.modified input.cote-text,
.dimension.modified select.cote-list {
  border-color: var(--color-violet);
  background-color: var(--color-violet-lt);
}

/* Champ cote hors plage : flash rouge le temps du clamp */
.dimension input.out-of-range {
  border-color: var(--color-red) !important;
  background: var(--color-red-lt);
  transition: background 0.3s, border-color 0.3s;
}

.range {
  font-size: 11px;
  color: var(--color-muted);
  width: 64px;
  text-align: right;
}

/* Boutons principaux */
.actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  padding: 13px 18px;
  border-radius: var(--radius-pill);
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  transition: opacity .15s;
}
.btn.primary   { background: var(--color-green); color: white; }
.btn.primary:hover { opacity: .9; }
.btn.secondary { background: white; border: 1.5px solid var(--color-border); color: var(--color-ink); }
.btn.secondary:hover { background: var(--color-bg); }

/* ============================================================
   PAVE 2 : VISUALISEUR STL
   Pavé centré entre pavé 1 (cotes) et pavé 3 (options).
   Caché tant que l'utilisateur n'a pas cliqué Visualiser.
   ============================================================ */
.viewer-wrap {
  max-width: 900px;
  margin: 16px auto 0;
  display: none;
}
.viewer-wrap.active { display: block; }

.viewer-card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.viewer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.viewer-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-green-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.viewer-title { font-size: 16px; font-weight: 600; }
.viewer-status {
  font-size: 11px;
  color: var(--color-sub);
}

/* Outils de mesure dans le header (poussent le status a droite) */
.viewer-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-measure,
.btn-measure-clear {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-sub);
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  transition: all .15s;
}
.btn-measure svg,
.btn-measure-clear svg {
  width: 12px;
  height: 12px;
}
.btn-measure:hover,
.btn-measure-clear:hover {
  color: var(--color-ink);
  border-color: var(--color-ink);
}
.btn-measure.active {
  background: var(--color-red);
  border-color: var(--color-red);
  color: white;
  font-weight: 600;
}
.btn-measure-clear { color: var(--color-red); border-color: var(--color-red); }
.btn-measure-clear:hover { background: var(--color-red-lt); color: var(--color-red); }

/* Labels overlay HTML projetes en 2D depuis les positions 3D */
.bbox-label,
.measure-label {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 5;
  font-variant-numeric: tabular-nums;
}
.bbox-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-green);
  color: var(--color-green);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.measure-label {
  background: var(--color-red);
  color: white;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  font-size: 12px;
}

/* Bandeau d'avertissement quand les cotes ont change apres viz */
.stale-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  background: var(--color-orange-lt);
  border: 1px solid var(--color-orange);
  color: #8a5a00;
}
.stale-banner.show { display: flex; }
.stale-banner svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--color-orange); }

/* Corps du pavé : canvas a gauche, boutons empilés a droite */
.viewer-body {
  display: flex;
  gap: 20px;
  align-items: stretch;
}
.viewer-canvas {
  flex: 1;
  height: 420px;
  min-width: 280px;
  border-radius: 16px;
  background: transparent;
  position: relative;
  overflow: hidden;
}
.viewer-actions {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.viewer-actions .btn { width: 100%; }

.viewer-hint {
  margin-top: 12px;
  font-size: 11px;
  color: var(--color-muted);
}

/* Etat désactivé (cotes modifiées, en attente de re-visualisation) */
.btn:disabled,
.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mobile : les boutons passent en dessous du canvas */
@media (max-width: 700px) {
  .viewer-body { flex-direction: column; }
  .viewer-actions {
    width: 100%;
    flex-direction: row;
  }
  .viewer-canvas { height: 320px; }
}

/* ============================================================
   PAVE 4 : VISUALISEUR GCODE
   Reutilise .viewer-wrap / .viewer-card / .viewer-body
   Ajoute : panneau d'infos d'impression + slider de couches
   ============================================================ */

/* Panneau lateral elargi pour accueillir les infos d'impression */
.viewer-actions.viewer-actions-wide { width: 280px; }

/* Carte d'infos gcode (temps, filament, couches, etc.) */
.gcode-info {
  background: var(--color-bg);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gcode-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.gcode-info-label {
  color: var(--color-sub);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 10px;
}
.gcode-info-val {
  color: var(--color-ink);
  font-weight: 600;
  font-size: 13px;
  text-align: right;
}
.gcode-info-val.muted { color: var(--color-muted); font-weight: 400; }

/* Slider VERTICAL des couches, place sur le cote du canvas */
.gcode-layer-slider-vertical {
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  background: var(--color-bg);
  border-radius: 14px;
  flex-shrink: 0;
}
.gcode-layer-slider-vertical .layer-cap {
  font-size: 10px;
  color: var(--color-sub);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gcode-layer-slider-vertical .layer-num {
  font-size: 12px;
  color: var(--color-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.gcode-layer-slider-vertical .layer-num.muted {
  color: var(--color-muted);
  font-weight: 400;
}
.gcode-layer-slider-vertical input[type="range"] {
  flex: 1;
  /* Orientation verticale : utilise les deux methodes pour
     compatibilite Chrome/Firefox/Safari. */
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  min-height: 220px;
  background: var(--color-green-soft);
  border-radius: 3px;
  outline: none;
}
.gcode-layer-slider-vertical input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-green);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.gcode-layer-slider-vertical input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-green);
  cursor: pointer;
  border: 2px solid white;
}

/* Legende des types de mouvements (couleurs gcode) */
.gcode-legend {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--color-bg);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}
.gcode-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--color-ink);
  font-weight: 500;
}
.gcode-legend .swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

@media (max-width: 700px) {
  .viewer-actions.viewer-actions-wide { width: 100%; }
  .gcode-layer-slider-vertical {
    width: 100%;
    flex-direction: row;
    padding: 8px 14px;
  }
  .gcode-layer-slider-vertical input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: horizontal-tb;
    direction: ltr;
    height: 6px;
    min-height: 0;
    width: auto;
    flex: 1;
  }
}

/* ============================================================
   PANNEAU OPTIONS D'IMPRESSION
   ============================================================ */
.options-wrap {
  max-width: 900px;
  margin: 16px auto 0;
  display: none;
}
.options-wrap.active { display: block; }

.options-card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.options-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.options-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-green-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.options-title { font-size: 16px; font-weight: 600; }

.options-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.option-group { flex: 1; min-width: 150px; }

.opt-label {
  font-size: 11px;
  color: var(--color-sub);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

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

.pill {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border);
  font-size: 13px;
  cursor: pointer;
  background: white;
  color: var(--color-ink);
  font-family: 'Sora', sans-serif;
  transition: all .15s;
}
.pill:hover             { border-color: var(--color-green); color: var(--color-green); }
.pill.active            { background: var(--color-green); border-color: var(--color-green); color: white; font-weight: 600; }

/* Toggle options avancees */
.advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: var(--color-sub);
  padding: 0;
  transition: color .15s;
}
.advanced-toggle:hover      { color: var(--color-ink); }
.advanced-toggle svg        { width: 13px; height: 13px; transition: transform .25s; }
.advanced-toggle.open svg   { transform: rotate(180deg); }
.advanced-toggle.open       { color: var(--color-ink); }

.advanced-section               { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-line); }
.advanced-section.active        { display: block; }

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

/* Champs avances */
.adv-field .adv-field-label {
  font-size: 11px;
  color: var(--color-sub);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
  transition: color .2s;
}
.adv-field .adv-field-sub {
  font-size: 10px;
  color: var(--color-hint);
  margin-bottom: 6px;
  line-height: 1.3;
}
.adv-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--color-border);
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  outline: none;
  text-align: center;
  transition: border .15s, background .15s;
  color: var(--color-ink);
  background: white;
}
.adv-input:focus { border-color: var(--color-green); }

/* Etat modifie - violet */
.adv-field.modified .adv-field-label { color: var(--color-violet); }
.adv-field.modified .adv-input       { border-color: var(--color-violet); background: var(--color-violet-lt); }
.adv-field.modified .toggle-val      { color: var(--color-violet); }

/* Toggles */
.adv-toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; }

.toggle-switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  transition: .2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}
.toggle-switch input:checked + .toggle-track                     { background: var(--color-green); }
.toggle-switch input:checked + .toggle-track::before             { transform: translateX(16px); }
.adv-field.modified .toggle-switch input:checked + .toggle-track     { background: var(--color-violet); }
.adv-field.modified .toggle-switch input:not(:checked) + .toggle-track { background: #C9BAFF; }
.toggle-val { font-size: 13px; color: var(--color-sub); }

/* Type de support */
.support-type-row           { display: none; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.support-type-row.visible   { display: flex; }

.support-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border);
  font-size: 12px;
  cursor: pointer;
  background: white;
  color: var(--color-ink);
  font-family: 'Sora', sans-serif;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.support-pill:hover { border-color: var(--color-green); color: var(--color-green); }
.support-pill.active { background: var(--color-green); border-color: var(--color-green); color: white; font-weight: 600; }
.support-pill svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Footer options */
.options-footer {
  border-top: 1.5px solid var(--color-line);
  padding-top: 20px;
  margin-top: 16px;
}
.btn-generate {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-pill);
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  background: var(--color-ink);
  color: white;
  transition: opacity .15s;
}
.btn-generate:hover { opacity: .85; }

/* Valeur par defaut : affichee en grise */
.dimension input.is-default {
    color: var(--color-ink);
}

/* ============================================================
   OVERLAY DE CHARGEMENT (spinner)
   ============================================================ */
.au-overlay {
  position: fixed;
  inset: 0;
  background: rgba(25, 23, 22, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.au-overlay.active {
  display: flex;
}

.au-overlay-card {
  background: var(--color-bg);
  border-radius: 16px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  font-family: 'Sora', sans-serif;
  color: var(--color-ink);
  box-shadow: var(--shadow-overlay);
  min-width: 260px;
}

.au-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid var(--color-green-soft);
  border-top-color: var(--color-green);
  animation: au-spin 0.9s linear infinite;
}
@keyframes au-spin {
  to { transform: rotate(360deg); }
}

.au-overlay-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--color-ink);
  margin: 0;
}
.au-overlay-sub {
  font-weight: 300;
  font-size: 13px;
  color: var(--color-sub);
  margin: 0;
  text-align: center;
  max-width: 240px;
  line-height: 1.4;
}
