/* ============================================================
   PERGOSA, configurateur de pergola bioclimatique
   Réutilise les variables de style.css
   ============================================================ */

.cfg-section { background: linear-gradient(180deg, #eaf5fc 0, var(--gray-50) 360px); }

.cfg-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

/* ---------- Aperçu ---------- */
.cfg-preview {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cfg-stage {
  background: #e8f4fb;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(14,95,160,.08), 0 12px 32px rgba(14,95,160,.14);
  overflow: hidden;
}
#cfgSvg { display: block; width: 100%; height: auto; aspect-ratio: 5 / 3.4; max-height: 62vh; }
.cfg-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
.cfg-stage-note { font-size: .74rem; color: var(--text-light); }

.cfg-chip {
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--green);
  background: var(--white);
  color: var(--green-dark);
  transition: all var(--transition);
}
.cfg-chip:hover, .cfg-chip.is-on { background: var(--green); color: var(--white); }
.cfg-chip:focus-visible { outline: 3px solid var(--green-light); outline-offset: 2px; }

.cfg-recap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.cfg-recap-main { font-weight: 700; color: var(--green-dark); font-size: 1.05rem; margin-bottom: 8px; }
.cfg-recap-list { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.cfg-recap-list li {
  font-size: .8rem;
  background: var(--green-bg);
  color: var(--green-dark);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Étapes ---------- */
.cfg-steps { counter-reset: cfgstep; display: flex; flex-direction: column; gap: 20px; }
.cfg-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 22px 22px 20px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.cfg-step legend {
  display: flex;
  align-items: center;
  gap: 12px;
  float: left;
  width: 100%;
  margin-bottom: 16px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.cfg-step legend + * { clear: both; }
.cfg-num {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-light), var(--green-dark));
  color: var(--white);
  font-size: .9rem;
  box-shadow: 0 2px 6px rgba(14,95,160,.3);
  display: inline-flex; align-items: center; justify-content: center;
}
.cfg-num::before { counter-increment: cfgstep; content: counter(cfgstep); }

.cfg-hint { font-size: .82rem; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }
.cfg-hint-top { margin: 0 0 14px; }
.cfg-hint.is-warn { color: var(--accent-dark); font-weight: 600; }
.cfg-field-label { font-size: .82rem; font-weight: 600; margin: 4px 0 8px; }
.cfg-field-label:not(:first-of-type) { margin-top: 18px; }

/* Cartes d'option (radio / checkbox masqués) */
.cfg-grid { display: grid; gap: 12px; }
.cfg-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cfg-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.cfg-opt { display: block; position: relative; cursor: pointer; }
.cfg-opt input, .cfg-sw input, .cfg-seg input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.cfg-opt-body {
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  height: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  transition: all var(--transition);
}
.cfg-opt-body strong { font-size: .95rem; }
.cfg-opt-body small { font-size: .78rem; color: var(--text-muted); line-height: 1.45; }
.cfg-opt:hover .cfg-opt-body { border-color: var(--green-light); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cfg-opt-body::after {
  content: "";
  position: absolute; top: 10px; right: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  opacity: 0; transform: scale(.6);
  transition: all var(--transition);
}
.cfg-opt input:checked + .cfg-opt-body::after { opacity: 1; transform: scale(1); }
.cfg-ico {
  width: 56px; height: 35px; margin-bottom: 6px;
  color: var(--green);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.cfg-ico .soft { fill: var(--green-bg); }
.cfg-opt input:checked + .cfg-opt-body .cfg-ico { color: var(--green-dark); }
.cfg-opt input:checked + .cfg-opt-body {
  border-color: var(--green);
  background: var(--green-bg);
  box-shadow: 0 0 0 3px rgba(30,141,205,.15);
}
.cfg-opt input:focus-visible + .cfg-opt-body { outline: 3px solid var(--green-light); outline-offset: 2px; }

/* Curseurs */
.cfg-slider { margin-bottom: 14px; }
.cfg-slider > label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.cfg-slider-row { display: flex; align-items: center; gap: 10px; }
.cfg-slider-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--green); height: 28px; }
.cfg-slider-row output {
  flex: none; min-width: 74px; text-align: right;
  font-weight: 700; color: var(--green-dark); font-variant-numeric: tabular-nums;
}
.cfg-step-btn {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 1.2rem; line-height: 1; color: var(--green-dark);
  transition: all var(--transition);
}
.cfg-step-btn:hover { border-color: var(--green); background: var(--green-bg); }
.cfg-step-btn:focus-visible { outline: 3px solid var(--green-light); outline-offset: 2px; }
.cfg-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Pastilles de couleur */
.cfg-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.cfg-sw { position: relative; cursor: pointer; display: block; }
.cfg-sw-dot {
  display: block;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 1.5px var(--border), inset 0 -6px 10px rgba(0,0,0,.14);
  transition: all var(--transition);
}
.cfg-sw:hover .cfg-sw-dot { transform: scale(1.08); }
.cfg-sw input:checked + .cfg-sw-dot { box-shadow: 0 0 0 3px var(--green), inset 0 -6px 10px rgba(0,0,0,.14); }
.cfg-sw input:focus-visible + .cfg-sw-dot { outline: 3px solid var(--green-light); outline-offset: 3px; }
.cfg-sw-same {
  display: flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 700; line-height: 1.05; text-align: center; color: var(--text-muted);
  background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 5px, #e2e8f0 5px, #e2e8f0 10px);
}
.cfg-sw-name { margin-top: 8px; font-size: .8rem; color: var(--text-muted); min-height: 1.2em; }

/* Côtés */
.cfg-sides { display: flex; flex-direction: column; gap: 12px; }
.cfg-side-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; }
.cfg-side-name { font-size: .88rem; font-weight: 600; }
.cfg-seg-group { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cfg-seg { position: relative; display: block; cursor: pointer; }
.cfg-seg span {
  display: block; text-align: center;
  font-size: .8rem; font-weight: 600;
  padding: 9px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  transition: all var(--transition);
}
.cfg-seg:hover span { border-color: var(--green-light); }
.cfg-seg input:checked + span { border-color: var(--green); background: var(--green-bg); color: var(--green-dark); }
.cfg-seg input:focus-visible + span { outline: 3px solid var(--green-light); outline-offset: 2px; }

/* Formulaire */
.cfg-step-form { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30,141,205,.1), var(--shadow); }
.cfg-legal { font-size: .76rem; color: var(--text-light); margin: 4px 0 16px; }
.cfg-legal a { text-decoration: underline; }
.cfg-submit { width: 100%; justify-content: center; box-shadow: 0 8px 22px rgba(30,141,205,.35); }
.cfg-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cfg-error { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: #fef2f2; color: #991b1b; font-size: .88rem; }
.cfg-noscript { padding: 16px; background: #fffbeb; border-radius: var(--radius-sm); font-size: .9rem; }

/* ---------- Mobile ---------- */
@media (max-width: 980px) {
  .cfg-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .cfg-preview {
    top: var(--header-h);
    z-index: 20;
    gap: 8px;
    margin: 0 -24px;
    padding: 8px 24px 10px;
    background: rgba(248,250,252,.96);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
  }
  #cfgSvg { max-height: 22vh; aspect-ratio: auto; height: 22vh; }
  .cfg-stage-bar { padding: 6px 10px; }
  .cfg-chip { padding: 5px 12px; font-size: .78rem; }
  .cfg-stage-note { display: none; }
  .cfg-recap { padding: 6px 12px; }
  .cfg-recap-main { font-size: .8rem; margin-bottom: 0; }
  .cfg-recap-list { display: none; }
}
@media (max-width: 560px) {
  .cfg-grid-2, .cfg-grid-3 { grid-template-columns: 1fr; }
  .cfg-opt-body { padding-right: 42px; }
  .cfg-step { padding: 18px 16px; }
  .cfg-side-row { grid-template-columns: 1fr; gap: 6px; }
  .cfg-slider-row output { min-width: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  .cfg-opt-body, .cfg-sw-dot, .cfg-seg span, .cfg-chip, .cfg-step-btn { transition: none; }
}
