/* Configurator ferestre · demo — mobile-first, un singur accent de culoare (din config.js) */

:root {
  --accent: #1F4E79;
  --accent-text: #ffffff;
  --bg: #ffffff;
  --bg-soft: #f4f5f7;
  --text: #16202a;
  --text-muted: #5b6672;
  --border: #d5dae0;
  --border-strong: #9aa4ae;
  --danger: #b42318;
  --warn-bg: #fff6e0;
  --warn-text: #7a4b00;
  --ok: #1a7f4b;
  --radius: 10px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sticky-h: 76px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(var(--sticky-h) + env(safe-area-inset-bottom, 0px) + 12px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; }
p { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Antet ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-logo {
  flex-shrink: 0; width: 64px; height: 34px; border: 1.5px dashed var(--border-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 8px; line-height: 1.15; color: var(--text-muted); padding: 2px;
}
.client-logo img { max-width: 100%; max-height: 100%; display: block; }
.client-logo.has-logo { border: 0; width: auto; max-width: 120px; }
.brand-text { min-width: 0; }
.brand-client { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-title { font-size: 17px; font-weight: 700; color: var(--accent); line-height: 1.15; }

.demo-banner {
  background: var(--warn-bg); color: var(--warn-text);
  font-size: 13px; text-align: center; padding: 6px 16px;
  border-bottom: 1px solid #f2dfa8;
}
.expired-banner {
  background: #fdecea; color: var(--danger); font-size: 14px; font-weight: 600;
  text-align: center; padding: 10px 16px; border-bottom: 1px solid #f5c2bd;
}

/* Teaser limbi (doar Export) */
.lang-teaser { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.chip {
  min-height: 32px; padding: 4px 10px; border-radius: 16px; border: 1px solid var(--border-strong);
  background: var(--bg); font-size: 13px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 4px;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.locked { color: var(--text-muted); font-weight: 500; }
.chip.locked .lock { font-size: 11px; }

/* Comutator tip de preț */
.segmented {
  display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden;
  background: var(--bg);
}
.segmented button {
  flex: 1; min-height: var(--tap); padding: 6px 8px; border: 0; background: transparent;
  font-size: 14px; font-weight: 550; color: var(--text); white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.segmented button .lock { font-size: 12px; margin-left: 3px; opacity: .8; }
.price-type-wrap { margin-top: 8px; }
.price-type-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-align: center; }

/* Dialog inline pentru cod */
.code-panel {
  margin-top: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft);
}
.code-panel[hidden] { display: none; }
.code-panel p { font-size: 14px; margin-bottom: 8px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.code-hint { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

/* ---------- Secțiuni ---------- */
main { padding: 0 16px; max-width: 720px; margin: 0 auto; }
section.step { padding: 20px 0 8px; border-bottom: 1px solid var(--border); }
section.step:last-of-type { border-bottom: 0; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 12px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.step-hint { font-size: 13px; color: var(--text-muted); margin: -6px 0 10px; }

/* Grilă tipuri */
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.type-cards { display: contents; }
@media (min-width: 480px) { .type-grid { grid-template-columns: repeat(3, 1fr); } }
.type-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 8px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--bg);
  text-align: center; min-height: var(--tap);
}
.type-card svg { width: 100%; height: auto; aspect-ratio: 1 / 1; display: block; }
.type-card .type-label { font-size: 13px; font-weight: 550; line-height: 1.25; }
.type-card[aria-pressed="true"] { border-color: var(--accent); background: #eef3f8; }
.type-card.type-more {
  grid-column: 1 / -1; min-height: 0; justify-content: center; gap: 2px; padding: 8px 12px; cursor: default;
  background: var(--bg-soft); border-style: dashed; color: var(--text-muted);
}
.type-card.type-more .type-more-title { font-size: 13px; font-weight: 600; }
.type-card.type-more .type-more-list { font-size: 11px; line-height: 1.35; }

/* Desen + dimensiuni */
.preview { margin: 0 auto 8px; max-width: 420px; }
.preview svg { width: 100%; height: auto; display: block; margin: 0 auto; }
/* Pe mobil desenul e limitat la 38vh ca desen + câmpuri + butoane ±100 să încapă pe un ecran de 360 × 740 */
@media (max-width: 767px) {
  .preview { scroll-margin-top: 4px; }
  .preview svg { max-height: 38vh; }
}
.dims-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 560px) { .dims-grid { grid-template-columns: 1fr 1fr; gap: 8px 12px; } }
.field { display: flex; flex-direction: column; gap: 2px; }
.dim-row { display: grid; grid-template-columns: 52px var(--tap) 1fr var(--tap); gap: 6px; align-items: center; }
.dim-row .dim-label { font-size: 14px; font-weight: 650; line-height: 1.1; }
.dim-row .dim-label small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.btn-step {
  width: var(--tap); height: var(--tap); border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg);
  font-size: 13px; font-weight: 700; color: var(--accent); padding: 0; font-variant-numeric: tabular-nums;
}
.btn-step:disabled { opacity: .35; cursor: not-allowed; }
.input-wrap { position: relative; min-width: 0; }
.input-wrap input {
  width: 100%; min-height: var(--tap); padding: 6px 30px 6px 8px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg);
  font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.input-wrap input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input-wrap input[aria-invalid="true"] { border-color: var(--danger); }
.input-wrap .unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; pointer-events: none; }
.field-msg { font-size: 12px; color: var(--text-muted); padding-left: 58px; }
.field-msg:empty { display: none; }
.field-msg.error { color: var(--danger); }
.field-msg.info { color: var(--accent); }
.warnings { display: flex; flex-direction: column; gap: 6px; }
.warnings:empty { display: none; }
.warning { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

.hinge-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 0; }
.hinge-row .label { font-size: 14px; font-weight: 550; }
.hinge-row .segmented { flex: 0 0 auto; width: 190px; }
.dims-hint { margin: 8px 0 0; }

/* Liste de opțiuni (sistem, geam, accesorii) */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap);
  padding: 10px 12px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--bg);
  text-align: left; width: 100%;
}
.option[aria-pressed="true"], .option.checked { border-color: var(--accent); background: #eef3f8; }
.option:disabled, .option[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.option .opt-main { flex: 1; min-width: 0; }
.option .opt-title { display: block; font-size: 15px; font-weight: 550; }
.option .opt-sub { display: block; font-size: 12px; color: var(--text-muted); }
.option .opt-sub:empty { display: none; }
.option .opt-price { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; text-align: right; }
.option .opt-price.included { font-weight: 500; color: var(--text-muted); }
.option .opt-price small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.radio-dot, .check-box {
  width: 22px; height: 22px; border: 2px solid var(--border-strong); flex-shrink: 0; position: relative; background: var(--bg);
}
.radio-dot { border-radius: 50%; }
.check-box { border-radius: 5px; }
.option[aria-pressed="true"] .radio-dot { border-color: var(--accent); }
.option[aria-pressed="true"] .radio-dot::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--accent); }
.option.checked .check-box { border-color: var(--accent); background: var(--accent); }
.option.checked .check-box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* Culori */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px 4px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 2px; border: 0; background: transparent; border-radius: 8px; min-height: var(--tap);
}
.swatch-dot {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px transparent;
  background-color: var(--sw, #fff);
}
.swatch[aria-pressed="true"] .swatch-dot { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.swatch.wood .swatch-dot { background-image: repeating-linear-gradient(180deg, rgba(0,0,0,.18) 0 1px, transparent 1px 4px); }
.swatch .swatch-label { font-size: 12px; line-height: 1.15; text-align: center; color: var(--text); }
.swatch:disabled { opacity: .35; cursor: not-allowed; }
.swatch:disabled .swatch-label { text-decoration: line-through; }
.section-note { font-size: 13px; color: var(--accent); margin-top: 8px; }

/* Cantitate */
.qty-row { display: flex; align-items: center; gap: 12px; }
.qty-btn {
  width: var(--tap); height: var(--tap); border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg);
  font-size: 22px; line-height: 1; font-weight: 500;
}
.qty-row input { width: 84px; min-height: var(--tap); text-align: center; font-size: 18px; border: 1px solid var(--border-strong); border-radius: 8px; }

/* Defalcare */
.breakdown { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.breakdown summary { padding: 12px; font-weight: 550; cursor: pointer; min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; list-style: none; }
.breakdown summary::-webkit-details-marker { display: none; }
.breakdown summary::after { content: "▾"; color: var(--text-muted); }
.breakdown[open] summary::after { content: "▴"; }
.breakdown table { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown td { padding: 7px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.breakdown td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown td .detail { display: block; font-size: 12px; color: var(--text-muted); }
.breakdown tr.total td { font-weight: 650; }
.breakdown.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { background: #eef3f8; } 100% { background: transparent; } }

/* Butoane */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; text-decoration: none;
}
.btn.secondary { background: var(--bg); color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text); font-weight: 500; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.pdf-duration { font-size: 14px; color: var(--ok); font-weight: 600; margin: -6px 0 10px; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn.secondary.busy::after { border-color: rgba(31,78,121,.3); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions-row .btn { flex: 1 1 140px; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions-grid .btn { padding-left: 8px; padding-right: 8px; font-size: 14px; }

/* Ofertă */
.quote-empty { font-size: 14px; color: var(--text-muted); padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; }
.quote-list { display: flex; flex-direction: column; gap: 8px; }
.quote-item { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.quote-item.editing { border-color: var(--accent); }
.quote-item svg { width: 72px; height: 72px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.quote-item .qi-title { font-weight: 600; font-size: 15px; }
.quote-item .qi-desc { font-size: 13px; color: var(--text-muted); }
.quote-item .qi-price { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; font-size: 14px; }
.quote-item .qi-price strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.quote-item .qi-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.quote-item .qi-actions .btn { flex: 1; }
.quote-totals { margin-top: 12px; border-top: 2px solid var(--text); padding-top: 8px; font-size: 15px; }
.quote-totals .row { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.quote-totals .row.grand { font-weight: 700; font-size: 18px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.quote-totals .muted { color: var(--text-muted); font-size: 13px; }

/* Bară sticky jos */
.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg); border-top: 1px solid var(--border-strong);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px;
}
.sticky-bar .sb-price { flex: 1; min-width: 0; }
.sticky-bar .sb-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-bar .sb-value { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sticky-bar .sb-value.invalid { font-size: 15px; color: var(--danger); font-weight: 600; white-space: normal; }
.sticky-bar .sb-value.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.12); color: var(--accent); } 100% { transform: scale(1); } }
.sticky-bar .btn { flex-shrink: 0; }

/* Dialoguri */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(100% - 24px, 460px); max-height: calc(100% - 24px);
  color: var(--text); background: var(--bg);
}
dialog::backdrop { background: rgba(20, 30, 40, .55); }
.dlg-body { padding: 18px 16px 16px; }
.dlg-title { font-size: 18px; margin-bottom: 4px; }
.dlg-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-grid input[type="text"], .form-grid input[type="tel"], .form-grid input[type="email"] {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 16px;
}
.form-grid input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; min-height: var(--tap); padding: 6px 0; }
.checkbox-row input { width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.dlg-actions { display: flex; gap: 8px; margin-top: 14px; }
.dlg-actions .btn { flex: 1; }
.confirm { text-align: center; padding: 8px 0; }
.confirm .ok-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--ok); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 10px; }
.confirm p { font-size: 15px; margin-bottom: 8px; }
.confirm .note { font-size: 13px; color: var(--text-muted); }
.pdf-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--sticky-h) + 12px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 14px; text-align: center;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* Subsol */
footer { padding: 24px 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

@media (min-width: 720px) {
  .topbar-row { max-width: 720px; margin: 0 auto; }
  .price-type-wrap { max-width: 720px; margin: 8px auto 0; }
}
