/* ============================================================
   Wood Desiign — Configurateur v2 (charte : #39FF14 sur noir)
   ============================================================ */
:root {
  --green: #39FF14;
  --ink: #0B0B0B;
  --panel: #131313;
  --panel-2: #1B1B1B;
  --line: rgba(255, 255, 255, 0.09);
  --txt: #F5F1EA;
  --muted: #9A958C;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--ink);
  color: var(--txt);
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; }

#appWrap { display: flex; height: 100%; }

/* ---------- viewer ---------- */
#viewer { position: relative; flex: 1; min-width: 0; }
#scene3d { width: 100%; height: 100%; display: block; }
#loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 10px; background: var(--ink); color: var(--green); font-weight: 600; z-index: 5;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.spin {
  width: 18px; height: 18px; border: 2px solid rgba(57,255,20,0.25); border-top-color: var(--green);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.view-tools {
  position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 4;
}
.view-tools button {
  width: 40px; height: 40px; border-radius: 10px; font-size: 17px;
  background: rgba(19,19,19,0.85); border: 1px solid var(--line); backdrop-filter: blur(6px);
  transition: border-color 0.2s, transform 0.2s;
}
.view-tools button:hover { transform: scale(1.06); }
.view-tools button.active { border-color: var(--green); box-shadow: 0 0 12px rgba(57,255,20,0.25); }
.viewer-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  font-size: 11px; color: var(--muted); background: rgba(11,11,11,0.7); padding: 4px 12px;
  border-radius: 999px; white-space: nowrap; z-index: 4;
}

/* ---------- panneau ---------- */
#panel {
  width: 400px; max-width: 46vw; background: var(--panel);
  border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
#panelGrip { display: none; }
#panelInner { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* stepper */
.stepper {
  display: flex; gap: 2px; padding: 10px 10px 0; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.step {
  flex: 1; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px 9px; border-bottom: 2px solid transparent; color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.step-n {
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line);
}
.step-l { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.step.active { color: var(--green); border-bottom-color: var(--green); }
.step.active .step-n { background: var(--green); color: #000; border-color: var(--green); }
.step.done { color: var(--txt); }
.step.done .step-n { border-color: var(--green); color: var(--green); }

/* messages */
.messages { padding: 8px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.msg {
  font-size: 11.5px; line-height: 1.45; padding: 7px 10px; border-radius: 8px;
  border: 1px solid rgba(255,193,7,0.35); background: rgba(255,193,7,0.08); color: #FFD97A;
}
.msg.info { border-color: rgba(57,255,20,0.3); background: rgba(57,255,20,0.06); color: #B9F5AD; }

/* contenu */
.panel-content { flex: 1; overflow-y: auto; padding: 12px 14px 20px; }
.sec-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--green); margin: 16px 0 8px;
}
.sec-title:first-child { margin-top: 4px; }
.sub-label { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 6px 0; }
.note b { color: var(--txt); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2);
  font-size: 12.5px; font-weight: 600; display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; transition: border-color 0.15s, background 0.15s; text-align: left;
}
.chips.small .chip { padding: 6px 10px; font-size: 11.5px; flex-direction: row; align-items: center; gap: 6px; }
.chip small { font-size: 10px; font-weight: 500; color: var(--muted); }
.chip:hover { border-color: rgba(57,255,20,0.4); }
.chip.active { border-color: var(--green); background: rgba(57,255,20,0.1); }
.chip.active small { color: #B9F5AD; }
.chip.disabled { opacity: 0.4; cursor: not-allowed; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,0.2); }

/* toggles */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 2px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.toggle-label { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.toggle-label small { font-size: 10.5px; color: var(--muted); }
.switch {
  position: relative; width: 38px; height: 21px; border-radius: 999px; flex-shrink: 0;
  background: rgba(255,255,255,0.15); transition: background 0.2s;
}
.switch .knob {
  position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: left 0.2s;
}
.switch.on { background: var(--green); }
.switch.on .knob { left: 19px; }

/* sliders */
.slider-row { padding: 7px 2px; }
.slider-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.slider-head b { color: var(--green); }
input[type=range] { width: 100%; accent-color: var(--green); }

/* swatches décors */
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch {
  display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 10px;
  border: 2px solid transparent; background: var(--panel-2); transition: border-color 0.15s, transform 0.15s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { border-color: var(--green); box-shadow: 0 0 14px rgba(57,255,20,0.2); }
.sw-img { display: block; width: 100%; aspect-ratio: 1; border-radius: 6px; background: #333; }
.sw-name { font-size: 10.5px; font-weight: 600; line-height: 1.25; text-align: left; }
.sw-code { font-size: 9px; color: var(--muted); text-align: left; }

/* onglets matériaux */
.mat-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 6px; margin-bottom: 4px;
  position: sticky; top: -12px; background: var(--panel); z-index: 2; padding-top: 4px;
}
.mat-tab {
  padding: 7px 12px; font-size: 12px; font-weight: 700; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap;
}
.mat-tab.active { background: var(--green); color: #000; border-color: var(--green); }

/* mode libre */
.free-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 8px;
  border: 1px solid var(--line); margin-bottom: 6px; font-size: 12.5px;
}
.free-item.selected { border-color: var(--green); }
.free-item span:first-child { flex: 1; }
.mini {
  font-size: 10.5px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.mini.danger { color: #FF7A7A; border-color: rgba(255,122,122,0.3); }

/* devis */
.quote-box {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12.5px;
  display: flex; flex-direction: column; gap: 6px; background: var(--panel-2);
}
.quote-budget span { color: var(--green); font-weight: 800; font-size: 15px; }
.quote-list {
  list-style: none; margin: 10px 0; max-height: 180px; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 11.5px;
  display: flex; flex-direction: column; gap: 4px; color: #CFCABF;
}
.quote-list li::before { content: '✓ '; color: var(--green); }
.quote-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; position: relative; }
.quote-form input, .quote-form textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--txt); font-size: 13px;
}
.quote-form input:focus, .quote-form textarea:focus { outline: none; border-color: var(--green); }
.form-status { font-size: 12px; color: var(--green); min-height: 16px; }

/* boutons */
.btn {
  padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 13px;
  transition: transform 0.15s, background 0.15s;
}
.btn:hover { transform: scale(1.02); }
.btn.primary { background: var(--green); color: #000; }
.btn.ghost { border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--green); }
.btn.danger-ghost { border: 1px solid rgba(255,122,122,0.25); color: #FF9A9A; font-size: 11.5px; padding: 8px 12px; }
.btn.wide { width: 100%; margin: 6px 0; }
.panel-nav { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.panel-nav .primary { flex: 1; }

/* budget sticky */
.budget-bar { border-top: 1px solid var(--line); background: var(--panel-2); padding: 10px 14px; }
.budget-head { display: flex; align-items: center; justify-content: space-between; }
.budget-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.budget-val { font-size: 17px; font-weight: 800; color: var(--green); }
.budget-toggle { font-size: 11.5px; color: var(--muted); }
.budget-toggle:hover { color: var(--txt); }
.budget-detail {
  list-style: none; max-height: 140px; overflow: auto; margin-top: 8px;
  font-size: 11px; color: #CFCABF; display: flex; flex-direction: column; gap: 3px;
}
.budget-detail li::before { content: '· '; color: var(--green); }
.budget-note { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ---------- mobile : bottom sheet ---------- */
@media (max-width: 860px) {
  #appWrap { flex-direction: column; }
  #viewer { flex: 1; min-height: 0; }
  #panel {
    width: 100%; max-width: none; height: 46vh; border-left: 0; border-top: 1px solid var(--line);
    transition: height 0.3s ease; position: relative;
  }
  #panel.expanded { height: 82vh; }
  #panelGrip {
    display: block; width: 100%; padding: 8px 0 2px; cursor: pointer;
  }
  #panelGrip span {
    display: block; width: 44px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,0.25); margin: 0 auto;
  }
  .swatches { grid-template-columns: repeat(3, 1fr); }
  .view-tools { flex-direction: row; top: auto; bottom: 34px; }
  .viewer-hint { display: none; }
  .step-l { font-size: 9px; }
}

/* ---------- Mes configurations + lien de partage ---------- */
.saves-block { margin-top: 14px; display: grid; gap: 10px; }
.saves-list { border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 4px 10px 8px; }
.saves-list summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; padding: 6px 0; color: #9BE870; }
.save-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid rgba(255,255,255,0.07); }
.save-info { min-width: 0; }
.save-info b { display: block; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-info small { color: rgba(255,255,255,0.5); font-size: 0.7rem; }
.save-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* ---------- etoile jaune "toutes options" ---------- */
.chip .star-flag { color: #FFD700; }
.note.note-star { color: #FFD700; }
