/* ============================================================
   Ultrarays Quote Builder — internal portal
   Light, focused, modern. Solar accent (gold) on a calm canvas.
   ============================================================ */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --line:      #e6e8ec;
  --line-soft: #eef0f3;
  --text:      #111418;
  --muted:     #6b7280;
  --accent:    #f5a623;          /* gold */
  --accent-d:  #d18909;
  --accent-soft: #fff3df;
  --primary:   #0f172a;          /* near-black */
  --danger:    #dc2626;
  --good:      #059669;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 24px rgba(15, 23, 42, 0.08);
  --radius:    12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ Layout ============ */
.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 12px;
}
.brand-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #f5a623, #f7931e);
  color: #fff; font-size: 22px;
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(245, 166, 35, 0.35);
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub  { font-size: 12px; color: var(--muted); }

.steps {
  display: flex; flex-direction: column; gap: 4px;
}
.step {
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: all 0.12s;
}
.step span {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--line-soft);
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.step:hover { background: var(--line-soft); color: var(--text); }
.step.is-active { background: var(--accent-soft); color: var(--accent-d); }
.step.is-active span { background: var(--accent); color: #fff; }
.step.is-done span::before { content: "✓"; }
.step.is-done span { color: #fff; background: var(--good); }
.step.is-done { color: var(--text); }

.sidebar-foot {
  margin-top: auto;
  font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ============ Content ============ */
.content {
  padding: 32px 40px 60px;
  max-width: 1100px;
}
.page-head h1 {
  font-size: 24px; margin: 0 0 6px; font-weight: 700;
}
.page-head p { margin: 0 0 22px; color: var(--muted); }

/* ============ Sections (single-page layout) ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  scroll-margin-top: 16px;     /* sidebar TOC scroll-to lands nicely */
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 16px;
}
.panel-head .panel-num {
  width: 26px; height: 26px;
  background: var(--accent-soft); color: var(--accent-d);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.panel-head h2 {
  font-size: 16px; font-weight: 600; margin: 0;
}
.panel-head .panel-status {
  margin-left: auto; font-size: 12px; color: var(--muted);
}
.panel-head .panel-status.is-done { color: var(--good); font-weight: 600; }
.panel-foot {
  display: flex; justify-content: flex-end; align-items: center;
  margin-top: 18px; gap: 12px;
}
.footer-actions { display: flex; gap: 10px; }

/* Section-disabled state when upstream prerequisites aren't met */
.panel.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  filter: grayscale(0.2);
}

/* ============ Form fields ============ */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field span {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.field input, .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit; color: var(--text);
  background: var(--surface);
  transition: border 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}
.field .readout {
  padding: 10px 12px; border: 1px dashed var(--line);
  border-radius: 8px;
  font-weight: 600; color: var(--accent-d);
  background: var(--accent-soft);
}

/* ============ Cards ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.cards--small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.card {
  text-align: left;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.12s;
  font: inherit;
  color: var(--text);
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}
.card-icon { font-size: 22px; margin-bottom: 8px; }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ============ Buttons ============ */
.btn {
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.btn:hover { background: var(--line-soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn--primary:hover { background: #1f2937; border-color: #1f2937; }
.btn--primary:disabled { background: var(--primary); }
.btn--xl { padding: 12px 28px; font-weight: 600; }

/* ============ Package list ============ */
.package-list {
  display: grid; gap: 12px;
}
.pkg {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.12s;
}
.pkg:hover { border-color: var(--accent); }
.pkg.is-selected {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}
.pkg-title { font-weight: 600; }
.pkg-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pkg-price {
  text-align: right; font-weight: 700; font-size: 16px; color: var(--accent-d);
  white-space: nowrap;
}
.pkg-price small { font-size: 10px; color: var(--muted); display: block; font-weight: 500; }

/* ============ Review ============ */
.review-grid {
  display: grid; gap: 8px;
  grid-template-columns: 1fr 1fr;
}
.review-row {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex; justify-content: space-between; gap: 16px;
}
.review-row b { font-weight: 600; }
.review-row.review-row--full { grid-column: span 2; }

/* ============ Misc ============ */
.muted { color: var(--muted); margin: 0 0 14px; font-size: 13px; }

/* Markup / over-quotation box on the Review step */
.markup-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}
.markup-box .field span {
  color: var(--accent-d);
}
.markup-preview {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
  display: grid; gap: 4px;
}
.markup-preview b { color: var(--accent-d); }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px; border-radius: 10px;
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow-md);
  font-weight: 500;
  z-index: 100;
}
.toast.toast--err { background: var(--danger); }
.toast.toast--ok { background: var(--good); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 14px; }
  .steps { flex-direction: row; flex-wrap: wrap; }
  .step { padding: 8px 12px; }
  .content { padding: 20px; }
  .grid--2 { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .review-row.review-row--full { grid-column: span 1; }
}

/* ============ Quote history (login, right panel, modal) ============ */
.shell { grid-template-columns: 280px 1fr 340px; }

.quotes-panel {
  background: var(--surface); border-left: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.qp-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.qp-user { font-size: 13px; font-weight: 600; }
.qp-user small { display: block; color: var(--muted); font-weight: 400; }
.qp-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--line-soft); }
.btn--sm { padding: 5px 12px; font-size: 12px; }

.qp-section { padding: 12px 16px; display: flex; flex-direction: column; min-height: 0; }
.qp-section.qp-history { border-top: 1px solid var(--line); flex: 1; overflow: auto; }
.qp-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.qp-search { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit; }
.qp-search:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.qload-more { font-size: 13px; padding: 10px; margin-top: 4px; }
.quote-list { overflow: auto; max-height: 42vh; display: flex; flex-direction: column; gap: 8px; }

.qcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.qcard.editing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.qcard-name { font-weight: 600; font-size: 14px; }
.qcard-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.qcard-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.qcard-kw { font-weight: 600; font-size: 13px; }
.qcard-edit { border: 0; background: var(--primary); color: #fff; padding: 5px 12px; border-radius: 7px; font-size: 12px; cursor: pointer; }
.qcard-edit[disabled] { background: var(--line); color: var(--muted); cursor: not-allowed; }

.hitem { font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.hitem:last-child { border: 0; }
.hitem b { font-weight: 600; }
.hitem .ht { color: var(--muted); }
.h-empty, .q-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

.editing-banner { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent-d); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.editing-banner button { border: 0; background: transparent; color: var(--accent-d); text-decoration: underline; cursor: pointer; font: inherit; }

/* custom PDF-text banner + badge */
.custom-banner { background: #fff8e1; border: 1px solid #c47f0a; color: #8a5a06; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.custom-banner[hidden], .editing-banner[hidden] { display: none; }
.custom-banner button { border: 0; background: transparent; color: #8a5a06; text-decoration: underline; cursor: pointer; font: inherit; }
.qcard-custom { font-size: 10.5px; font-weight: 700; color: #8a5a06; background: #fff8e1; border: 1px solid #c47f0a; border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.pt-row { margin-bottom: 12px; }
.pt-row > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.pt-row textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: inherit; resize: none; overflow: hidden; min-height: 38px; }
.pt-row.pt-changed textarea { border-color: #c47f0a; background: #fff8e1; }
.pt-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
/* Doubled class = higher specificity than the base .modal-card rule below,
   which would otherwise win on source order and clamp these back to 440px. */
.modal-card.modal-card--wide { width: 640px; }
.modal-card.modal-card--admin { width: 680px; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-card .field { margin-bottom: 14px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-back { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal-card { position: relative; background: var(--surface); border-radius: 14px; width: 440px; max-width: 92vw; max-height: 88vh; overflow: auto; box-shadow: var(--shadow-md); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.urow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar, .quotes-panel { position: static; height: auto; }
  .quotes-panel { border-left: 0; border-top: 1px solid var(--line); }
  .quote-list { max-height: none; }
}

/* ============ Mobile UX — tabbed single view + bottom nav ============ */
.mnav { display: none; }
@media (max-width: 1024px) {
  body { font-size: 15px; }
  .shell { display: block; }
  .sidebar { display: none; }                 /* desktop step-nav not needed on phone */

  .quotes-panel { position: static; height: auto; border-left: 0; border-top: 0; }
  .content { padding-bottom: 84px; }
  .quotes-panel { padding-bottom: 84px; }
  .quote-list { max-height: none; }
  .grid.grid--2 { grid-template-columns: 1fr; }   /* one field per row */
  .span-2 { grid-column: auto; }  /* span-2 would force an implicit 2nd track in the 1-col grid */
  .field input, .field select { font-size: 16px; }/* no focus-zoom */
  .modal-card, .modal-card--wide, .modal-card--admin { width: auto; max-width: 96vw; max-height: 92vh; }

  /* tabbed: only the active view shows */
  body.view-form  .quotes-panel { display: none; }
  body.view-saved .content      { display: none; }
  /* Saved tab: fixed viewport-height panel; the quote LIST and the activity
     feed each scroll inside their own area — no more scrolling past 300
     quotes to reach Recent activity. */
  body.view-saved .quotes-panel { display: flex; flex-direction: column; height: calc(100vh - 60px); overflow: hidden; padding-bottom: 0; }
  body.view-saved .qp-section { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  body.view-saved .quote-list { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
  body.view-saved .qp-section.qp-history { flex: 0 0 auto; max-height: 30vh; overflow-y: auto; padding-bottom: 12px; }

  .page-head { padding-top: 6px; }

  .mnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 60px; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mnav-item {
    flex: 1; border: 0; background: transparent; cursor: pointer; font: inherit;
    color: var(--muted); font-size: 12px; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  }
  .mnav-item span { font-size: 12px; }
  .mnav-item.is-active { color: var(--accent-d); }

  /* Action buttons: 2-up grid, Generate PDF full-width & last — no more
     zooming out to find them. */
  .panel-foot { justify-content: stretch; }
  .footer-actions { flex-wrap: wrap; width: 100%; }
  .footer-actions .btn { flex: 1 1 calc(50% - 5px); min-height: 48px; padding: 12px 8px; font-size: 15px; white-space: nowrap; }
  .footer-actions .btn--primary { flex: 1 1 100%; order: 10; min-height: 52px; font-size: 17px; }
}

/* clickable quote cards open a read-only detail view */
.qcard { cursor: pointer; }
.qcard:hover { border-color: var(--accent); }
.qcard-go { color: var(--accent-d); font-size: 12px; font-weight: 600; }

/* read-only mode: form filled from a saved quote you can't edit */
body.viewing .content input,
body.viewing .content select,
body.viewing .content textarea { pointer-events: none; background: var(--line-soft); }
body.viewing .content .card,
body.viewing .content .pkg,
body.viewing .content [data-kwchoice],
body.viewing .content [data-bill] { pointer-events: none; }
body.viewing #generateBtn,
 body.viewing #saveBtn,
 body.viewing #pdfTextBtn,
body.viewing #resetBtn { display: none; }

/* view-mode action buttons must stay clickable even if the review panel is in
   its disabled state (pointer-events inherits, so override explicitly) */
body.viewing #viewDownloadBtn,
body.viewing #viewNewBtn,
body.viewing #viewDocxBtn { pointer-events: auto; }

/* version history list (shown when a saved quote is open) */
.version-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.version-list[hidden] { display: none; }
.vh-h { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.vh-item { display: block; width: 100%; text-align: left; border: 0; background: var(--line-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text); }
.vh-item:hover { background: var(--accent-soft); }

/* employee toggle: add the extra-meter-charge note to the PDF */
.meter-note-toggle { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; font-size: 13px; cursor: pointer; }
.meter-note-toggle input { width: 18px; height: 18px; flex-shrink: 0; }

/* admin-only delete on quote cards */
.qcard-del { border: 0; background: transparent; cursor: pointer; font-size: 14px; padding: 2px 6px; margin-right: 6px; border-radius: 6px; }
.qcard-del:hover { background: rgba(220,38,38,.12); }
