/* Order-form styles. Colours, fonts and shapes are tokens; a brand theme
   (themes/<brand>.css, loaded after this file) overrides them to match that brand's website.
   The defaults below are the SC-order look. */
:root {
  --of-font: Arial, sans-serif;
  --of-heading-font: var(--of-font);
  --of-heading-weight: 700;

  --of-page-bg: #f9f9f9;
  --of-surface: #fff;
  --of-text: #222;
  --of-muted: #888;
  --of-heading: #5F6C7B;
  --of-border: #c0eef2;
  --of-divider: #f0f4f8;

  --of-header-bg: #d6dde4;
  --of-header-text: #333;
  --of-header-border: transparent;
  --of-logo-height: 48px;

  --of-accent: #35CEDE;          /* checkboxes, underlines, focus — decorative, not text */
  --of-selected-bg: #e4f9fb;
  --of-hover-bg: #f0f8ff;
  --of-toggle-on: #0f172a;      /* selected toggle segment */
  --of-toggle-text: #334155;
  --of-toggle-border: #e2e8f0;

  --of-section-bg: #5F6C7B;
  --of-section-hover: #4e5a68;
  --of-section-text: #fff;
  --of-section-weight: 600;

  --of-price: #5F6C7B;
  --of-included: #2a9d3c;
  --of-note: #5F6C7B;
  --of-note-bg: #f3f7fa;
  --of-od-order-bg: var(--of-note-bg);   /* Order Details: tint behind the Order Info section */
  --of-warn: #9a6700;

  --of-btn-bg: #5F6C7B;
  --of-btn-text: #fff;
  --of-btn-hover: #4e5a68;
  --of-btn-soft-bg: #e0e4e8;
  --of-btn-soft-text: #333;
  --of-btn-soft-border: #c8cdd2;
  --of-btn-radius: 4px;

  --of-radius: 6px;
  --of-ok: #2a9d3c;
  --of-error: #c0392b;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--of-page-bg);
  font-family: var(--of-font);
  font-size: 14px;
  margin: 0;
  padding: 0 0 72px;
  color: var(--of-text);
  max-width: none;
}

h1, h2, h3 { font-family: var(--of-heading-font); }

/* ── Header ── */
header {
  background: var(--of-header-bg);
  color: var(--of-header-text);
  border-bottom: 1px solid var(--of-header-border);
  padding: 18px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
#header-main { min-width: 0; }
header h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: var(--of-heading-weight);
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--of-header-text);
}
header h1 img { height: var(--of-logo-height); width: auto; display: block; flex-shrink: 0; }
#header-subtitle { margin: 0; font-size: .85rem; color: var(--of-muted); }
#of-viewer { font-size: .8rem; color: var(--of-muted); }

/* ── Layout ── */
#app { display: flex; min-height: calc(100vh - 80px); }
#configurator { flex: 1 1 0; min-width: 0; max-width: 760px; padding: 20px 24px 60px; }
#of-loading { color: var(--of-muted); font-style: italic; padding: 20px 4px; }
#summary-panel {
  width: 330px;
  min-width: 260px;
  flex-shrink: 0;
  background: var(--of-surface);
  border-left: 1px solid var(--of-border);
  padding: 16px 16px 80px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* ── Controls (price list + options) ── */
#controls {
  background: var(--of-surface);
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
  padding: 8px 10px;
  margin-bottom: 14px;
}
#controls-bar { display: flex; align-items: center; gap: 8px; }
.ctrl-label { font-size: .78rem; font-weight: 600; color: var(--of-heading); white-space: nowrap; }
#tier-select {
  font-size: .88rem;
  padding: 4px 8px;
  margin: 0;
  border: 1px solid var(--of-border);
  border-radius: 4px;
  color: var(--of-text);
  background: var(--of-surface);
}
#controls-expand-btn {
  margin: 0 0 0 auto;
  background: none;
  border: 1px solid var(--of-border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--of-heading);
}
#controls-expand-btn:hover { background: var(--of-hover-bg); }
#controls-expanded {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--of-border);
  flex-direction: column;
  gap: 12px;
}
.ctrl-section-title {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--of-heading);
  margin-bottom: 4px;
}
.ctrl-check { display: flex; align-items: center; gap: 6px; font-size: .82rem; margin: 3px 0; cursor: pointer; }
.ctrl-check input { margin: 0; accent-color: var(--of-accent); }
.ctrl-buttons { display: flex; gap: 6px; margin-top: 6px; }
.ctrl-buttons .btn-primary { flex: 1; }
.status-text { display: block; margin-top: 5px; font-size: .73rem; color: var(--of-muted); }
.status-text.is-error { color: var(--of-error); }
.status-text.is-ok { color: var(--of-ok); }

/* ── Section cards ── */
.section-card {
  background: var(--of-surface);
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--of-section-bg);
  color: var(--of-section-text);
  padding: 9px 14px;
  cursor: pointer;
  user-select: none;
}
.section-header:hover { background: var(--of-section-hover); }
.section-header h2 {
  margin: 0;
  flex: 1;
  font-size: 1rem;
  font-weight: var(--of-section-weight);
  color: var(--of-section-text);
}
.section-header .arrow { font-size: .75rem; min-width: 14px; transition: transform .2s; }
.section-header .arrow.open { transform: rotate(90deg); }
.section-header .sel-count { font-size: .75rem; opacity: .85; white-space: nowrap; }
.section-header .change-hint { font-size: .68rem; opacity: .65; white-space: nowrap; }
.section-header .badge {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 7px;
  opacity: .8;
  white-space: nowrap;
}
/* Pick-one section shown as a dropdown */
.select-row { padding: 8px 14px 4px; }
.of-select {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  font-family: inherit;
  font-size: .95rem;
  color: var(--of-text);
  background-color: var(--of-surface);
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
  cursor: pointer;
}
.of-select:focus { outline: 2px solid var(--of-accent); outline-offset: 1px; }
.select-detail { display: flex; align-items: center; gap: 10px; padding: 4px 14px 8px; }

/* Note-only section: a heading over the cards that follow it */
.section-heading { margin: 22px 2px 10px; padding-bottom: 6px; border-bottom: 2px solid var(--of-accent); }
.section-heading h2 { margin: 0; font-size: 1.2rem; font-weight: var(--of-heading-weight); color: var(--of-heading); }
.section-heading-note { margin-top: 2px; font-size: .8rem; color: var(--of-muted); }

/* Segmented toggle: equal-width options on one line, one selected (same look as /usermeasurement) */
.seg {
  display: grid;
  grid-template-columns: repeat(var(--seg-count, 2), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--of-surface);
  border: 1px solid var(--of-toggle-border);
  border-radius: 8px;
}
.seg-opt {
  position: relative;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  color: var(--of-toggle-text);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.seg-opt:hover { background: var(--of-hover-bg); }
.seg-opt.on { background: var(--of-toggle-on); border-color: var(--of-toggle-on); color: #fff; }
.seg-opt input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg-opt:focus-within { outline: 2px solid var(--of-accent); outline-offset: 1px; }

/* Model: the toggle alone on one line, above the sections */
.model-line { margin-bottom: 12px; }
.model-line .seg-opt { padding: 8px; font-size: .92rem; }

/* A pick-one shown as a toggle: section name and toggle on one line */
.toggle-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--of-section-bg);
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
}
.toggle-line h2 { flex: none; margin: 0; font-size: 1rem; font-weight: var(--of-section-weight); color: var(--of-section-text); }
.toggle-line .seg { flex: 1; }
.toggle-line.required-missing { border: 2px solid #ffc107; }
@media (max-width: 560px) {
  .toggle-line { flex-direction: column; align-items: stretch; }
}

.section-body { display: none; padding: 6px 0; }
.section-body.open { display: block; }

.section-note {
  margin: 4px 14px 6px;
  padding: 5px 8px;
  font-size: .78rem;
  line-height: 1.35;
  color: var(--of-note);
  background: var(--of-note-bg);
  border-left: 3px solid var(--of-accent);
  border-radius: 3px;
}

/* Collapsed to the current choice: only the selected row shows. */
.section-card.sel-collapsed .item-row:not(.selected),
.section-card.sel-collapsed .section-note { display: none; }
.section-card.sel-collapsed .item-row.selected { border-bottom: none; }

.section-card.required-missing { border: 2px solid #ffc107; box-shadow: 0 0 0 3px rgba(255,193,7,.25); }
.section-card.required-missing .section-header { background: #b8860b; color: #fff; }
.section-card.required-missing .section-header h2 { color: #fff; }

/* ── Item rows ── */
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 7px 14px;
  border-bottom: 1px solid var(--of-divider);
  cursor: pointer;
  transition: background .1s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--of-hover-bg); }
.item-row.selected { background: var(--of-selected-bg); }
.item-row input[type=radio],
.item-row input[type=checkbox] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--of-accent);
  cursor: pointer;
}
.item-label { flex: 1; line-height: 1.3; color: var(--of-text); }
.item-pn { display: block; font-size: .72rem; color: var(--of-muted); }
.item-note { display: block; margin-top: 2px; font-size: .74rem; color: var(--of-note); }
.item-note.warn { color: var(--of-warn); }
.item-price { min-width: 72px; text-align: right; white-space: nowrap; font-size: .9rem; font-weight: 600; color: var(--of-price); }
.item-price.included { font-size: .8rem; font-weight: normal; color: var(--of-included); }

.item-row.blocked { cursor: not-allowed; background: transparent; }
.item-row.blocked .item-label,
.item-row.blocked .item-price { color: #a0a0a0; }
.item-row.blocked .item-note.warn { color: var(--of-warn); }
.item-row.blocked input { cursor: not-allowed; }
.item-row.locked { cursor: default; }
.item-row.locked input { cursor: pointer; }
/* Base unchecked: everything but the model and the base is unavailable until it's checked again. */
#sections.form-empty .section-card:not([data-mode="locked"]),
#sections.form-empty .toggle-line,
#sections.form-empty .section-heading { opacity: .45; pointer-events: none; }

/* ── Image preview ── */
#image-preview {
  position: relative;
  height: 220px;
  margin-bottom: 14px;
  background: var(--of-surface);
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview-img { width: 100%; height: 100%; object-fit: contain; display: block; }
#preview-placeholder { color: var(--of-muted); font-size: .8rem; line-height: 1.5; text-align: center; pointer-events: none; }
#preview-label {
  display: none;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 8px;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: .72rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Summary ── */
#summary-panel h3 {
  margin: 0 0 10px;
  padding-bottom: 6px;
  font-size: 1.05rem;
  font-weight: var(--of-heading-weight);
  color: var(--of-heading);
  border-bottom: 2px solid var(--of-accent);
}
#summary-model { margin: -4px 0 8px; font-size: .8rem; font-weight: 600; color: var(--of-heading); }
#empty-msg { margin: 10px 0; font-size: .85rem; font-style: italic; color: var(--of-muted); }
#summary-scroll {
  min-height: calc(6 * 36px);
  max-height: calc(14 * 36px);
  overflow-y: auto;
  border: 1px solid var(--of-border);
  border-radius: 4px;
}
#summary-table { width: 100%; margin: 0; border-collapse: collapse; font-size: .75rem; }
#summary-table tr { background: none; }
#summary-table td { padding: 4px 6px; border-bottom: 1px solid var(--of-divider); vertical-align: top; background: none; }
#summary-table tr:hover td { background: var(--of-hover-bg); }
.sum-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.sum-pn, .sum-price { font-size: .74rem; font-weight: 600; color: var(--of-heading); white-space: nowrap; }
.sum-desc {
  font-size: .72rem;
  line-height: 1.25;
  color: var(--of-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#summary-total-table { width: 100%; margin: 0; border-collapse: collapse; font-size: .85rem; }
#summary-total-table td { padding: 8px 4px 5px; background: none; }
#total-row td { font-weight: bold; color: var(--of-heading); border-top: 2px solid var(--of-heading); }
#total-row td:last-child { text-align: right; white-space: nowrap; }

/* ── Buttons ── */
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-row-send { margin-top: 8px; }
.btn {
  margin: 0;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--of-btn-radius);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--of-btn-bg); color: var(--of-btn-text); }
.btn-primary:hover { background: var(--of-btn-hover); }
.btn-ghost, .btn-export {
  background: var(--of-btn-soft-bg);
  color: var(--of-btn-soft-text);
  border-color: var(--of-btn-soft-border);
}
.btn-ghost:hover, .btn-export:hover { filter: brightness(.95); }
.btn-export { flex: 1; text-align: center; }
.btn-excel { color: #1D6F42; }
.btn-clear { color: var(--of-error); }
.btn-small { padding: 4px 12px; font-size: .8rem; }
.btn-send-ami { flex: 1; padding: 10px 14px; letter-spacing: .3px; }

.of-msg { margin-top: 8px; padding: 8px 10px; border-radius: 4px; font-size: .78rem; line-height: 1.5; }
.of-msg.warn { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.of-msg.ok { background: #e8f8ee; color: #1a5c2e; border: 1px solid #a3d9b4; }
.of-msg ul { margin: 4px 0 4px 16px; padding: 0; }

#validation-msg {
  display: none;
  margin-top: 10px;
  padding: 8px 10px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  font-size: .8rem;
  line-height: 1.5;
  color: #856404;
}
#validation-list { margin: 4px 0 0 16px; padding: 0; }

/* ── Order details bar + modal ── */
#order-details-bar {
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid var(--of-border);
  border-radius: var(--of-radius);
  background: var(--of-page-bg);
  cursor: pointer;
}
#order-details-bar:hover { background: var(--of-hover-bg); }
.od-bar-title { margin-bottom: 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--of-heading); }
.od-edit-hint { margin-left: 4px; opacity: .5; }
.od-bar-fields { display: flex; flex-wrap: wrap; gap: 14px; }
.od-bar-field { font-size: .8rem; color: var(--of-text); }
.od-bar-label { font-size: .72rem; color: var(--of-muted); }

.of-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.35); }
.of-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  width: min(440px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--of-surface);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.od-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--of-border);
  font-family: var(--of-heading-font);
  font-size: 1rem;
  font-weight: 700;
  color: var(--of-heading);
}
.od-popup-header button { margin: 0; padding: 0 4px; background: none; border: none; font-size: 1.1rem; color: var(--of-muted); }
.of-popup-small { width: min(380px, 92vw); }
.conflict-msg { margin: 0; font-size: .88rem; color: var(--of-text); }
#conflict-error { min-height: 1em; font-size: .78rem; color: var(--of-error); }
.btn-overwrite { color: var(--of-error); }
.od-popup-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.od-popup-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--of-border); }
.od-field { display: flex; flex-direction: column; gap: 3px; margin: 0; font-size: .82rem; }
.od-field span { font-size: .73rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--of-heading); }
.od-field input, .od-field textarea {
  width: 100%;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--of-border);
  border-radius: 4px;
  background: var(--of-surface);
  color: var(--of-text);
  font-family: inherit;
  font-size: .85rem;
  resize: vertical;
}
.od-field input:focus, .od-field textarea:focus { outline: none; border-color: var(--of-accent); }
.od-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.od-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--of-border);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--of-heading);
}
.od-volatile-hint { font-size: .66rem; font-weight: normal; text-transform: none; letter-spacing: 0; }
.od-volatile-hint { color: #b9770e; }
.od-same { margin-left: 4px; font-size: .7rem; font-weight: normal; text-transform: none; letter-spacing: 0; color: var(--of-muted); cursor: pointer; }
.od-same input { margin: 0 3px 0 0; accent-color: var(--of-accent); }
/* Customer / Dealer / Distributor tabs */
.od-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-top: 4px;
  border-bottom: 1px solid var(--of-border);
}
.od-tab {
  margin: 0 0 -1px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--of-radius) var(--of-radius) 0 0;
  background: none;
  color: var(--of-muted);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
}
.od-tab:hover { color: var(--of-heading); background: var(--of-hover-bg); }
.od-tab.is-active {
  color: var(--of-heading);
  background: var(--of-surface);
  border-color: var(--of-border);
  box-shadow: inset 0 2px 0 var(--of-accent);
}
/* A distributor's Customer tab: greyed out at the right, still selectable. */
.od-tab-muted { margin-left: auto; opacity: .55; font-weight: 600; }
.od-tab-muted:hover, .od-tab-muted.is-active { opacity: .9; }
.od-ship-same { margin: 2px 0 0; font-size: .78rem; color: var(--of-text); }
/* Role-based layout hides tabs, fields and headings with [hidden]; several of
   these elements are flex containers, which would otherwise override it. */
#order-details-modal [hidden] { display: none !important; }
/* Order Info (this order only) gets a light tint to set it apart from the saved profile below. */
.od-section { display: flex; flex-direction: column; gap: 10px; }
.od-section-order {
  margin: -4px -6px 0;
  padding: 4px 10px 12px;
  border-radius: var(--of-radius);
  background: var(--of-od-order-bg);
}

/* ── Configs + PO footer ── */
#config-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  padding: 6px 16px;
  background: var(--of-surface);
  border-top: 1px solid var(--of-border);
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
#config-footer-inner {
  display: grid;
  grid-template-columns: 64px 150px 64px 1fr 54px 32px 70px 70px 1fr;
  gap: 4px 8px;
  align-items: center;
  max-width: 1100px;
}
.footer-row-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--of-heading); }
#config-footer input[type=text],
#config-footer select {
  width: 100%;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--of-border);
  border-radius: 4px;
  font-size: .82rem;
}
#config-footer button {
  width: 100%;
  margin: 0;
  padding: 4px 8px;
  background: var(--of-btn-soft-bg);
  color: var(--of-btn-soft-text);
  border: 1px solid var(--of-btn-soft-border);
  border-radius: var(--of-btn-radius);
  font-size: .8rem;
  white-space: nowrap;
}
#config-footer button:hover { filter: brightness(.95); }
#config-footer .config-delete-btn { color: var(--of-error); font-weight: bold; }
#config-status, #po-status { font-size: .72rem; color: var(--of-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#config-status.is-ok, #po-status.is-ok { color: var(--of-ok); }
#config-status.is-error, #po-status.is-error { color: var(--of-error); }

/* ── Toast ── */
#of-toast {
  position: fixed;
  left: 16px;
  bottom: 84px;
  z-index: 300;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  background: #333;
  color: #fff;
  font-size: .82rem;
  line-height: 1.4;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#of-toast.show { opacity: 1; transform: none; }

/* ── Narrow screens ── */
@media (max-width: 820px) {
  header { padding: 14px 16px; }
  #app { flex-direction: column; }
  #configurator { max-width: 100%; padding: 16px 16px 20px; }
  #summary-panel { width: 100%; height: auto; position: static; border-left: none; border-top: 1px solid var(--of-border); }
  #config-footer { position: static; }
  #config-footer-inner { grid-template-columns: 1fr 1fr; }
  body { padding-bottom: 0; }
}
