/* Quote builder — operator-facing. Its own light "worksheet" theme (a deliberate design
   choice per CLAUDE.md §4): calm, legible, confident business software a tradesperson uses
   on a phone in a van. Self-contained tokens so the tool deploys independently. */

:root {
  --paper: #F3F1EC;      /* warm neutral background */
  --surface: #FFFFFF;
  --ink: #1C2024;
  --muted: #5A626B;
  --dim: #8A929B;
  --line: #E3E0D8;
  --accent: #3B3F8F;     /* one confident deep-indigo accent */
  --accent-ink: #FFFFFF;
  --ok: #1F7A33;
  --bad: #C0392B;
  --radius: 12px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.5; -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, legend, .pill { font-family: var(--mono); }

/* App header — light browser-window device */
.appbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; display: block; background: #D8D4CB; }
.dots i:nth-child(1) { background: #E0736B; } .dots i:nth-child(2) { background: #E6B44C; } .dots i:nth-child(3) { background: #5FB36A; }
.pill { flex: 1; max-width: 30rem; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px 16px; font-size: 0.8rem; color: var(--muted); }

/* Layout */
.layout { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; display: grid; grid-template-columns: 1fr; gap: 24px; }
.intro h1 { font-size: 1.7rem; margin: 0 0 6px; }
.intro p { color: var(--muted); margin: 0 0 20px; }

/* Mobile edit/preview toggle */
.mobile-toggle { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.mobile-toggle button { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 999px; font: inherit; font-family: var(--mono); color: var(--muted); cursor: pointer; }
.mobile-toggle button.active { background: var(--accent); color: var(--accent-ink); }

/* Form */
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; margin: 0 0 18px; }
legend { padding: 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 0.85rem; color: var(--ink); font-weight: 600; }
.field em { color: var(--dim); font-style: normal; font-weight: 400; }
.field input, .field select, .field textarea { font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; }
.field.narrow { max-width: 180px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.field.colour input[type="color"] { height: 44px; padding: 4px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.logo-note { font-size: 0.8rem; color: var(--muted); margin: 4px 0 0; }
.logo-note.bad { color: var(--bad); }

/* Money inputs get a £ marker */
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.money input { padding-left: 24px; }

/* Line items */
.line-item { display: grid; grid-template-columns: 1fr 70px 100px 34px; gap: 8px; align-items: end; margin-bottom: 10px; }
.line-item .field { margin: 0; }
.line-item .field > span { font-size: 0.72rem; color: var(--dim); font-weight: 500; }
.line-item.head-hidden .field > span { display: none; }
.remove-line { height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; color: var(--bad); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.remove-line:hover { border-color: var(--bad); }
.btn-line { border: 1px dashed var(--line); background: transparent; color: var(--accent); border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; margin-top: 4px; }
.btn-line:hover { border-color: var(--accent); }

.btn-submit { width: 100%; background: var(--accent); color: var(--accent-ink); border: none; border-radius: var(--radius); padding: 15px; font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.btn-submit:hover { filter: brightness(1.08); }
.btn-submit:disabled { opacity: 0.6; cursor: progress; }
.form-error { color: var(--bad); background: #FBEBE9; border: 1px solid #F2C9C4; border-radius: 9px; padding: 12px 14px; margin: 0 0 14px; }

/* Success */
.success { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 22px; margin-top: 20px; }
.success h2 { font-size: 1.2rem; margin: 0 0 6px; }
.success > p { color: var(--muted); margin: 0 0 16px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; font-family: var(--mono); padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.link-row button { padding: 12px 18px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.copied { color: var(--ok); font-size: 0.85rem; margin: 8px 0 0; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.btn-share { flex: 1 1 auto; text-align: center; text-decoration: none; padding: 12px 16px; border: 1px solid var(--line); border-radius: 9px; color: var(--accent); font-weight: 600; }
.btn-share:hover { border-color: var(--accent); }
.btn-again { background: transparent; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; }

/* Preview pane */
.pane-preview { display: none; }
.preview-frame { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.preview-chrome { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #ECEAE3; border-bottom: 1px solid var(--line); }
.preview-chrome .pill { font-size: 0.72rem; }
#previewIframe { width: 100%; height: 640px; border: 0; display: block; background: #F4F5F7; }
.preview-note { text-align: center; color: var(--dim); font-size: 0.8rem; margin: 10px 0 0; }

/* --- Desktop: two columns, both visible, preview sticky ------------------ */
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 430px; align-items: start; }
  .mobile-toggle { display: none; }
  .pane-form { grid-column: 1; }
  .pane-preview { grid-column: 2; display: block; position: sticky; top: 20px; }
  #previewIframe { height: 720px; }
}

/* --- Mobile: toggle controls which pane shows --------------------------- */
@media (max-width: 899px) {
  .layout.show-preview .pane-form { display: none; }
  .layout.show-preview .pane-preview { display: block; }
  .layout.show-preview .mobile-toggle { display: flex; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
