/*
 * Styles for the four free document generators: quotation and invoice, in English (quotation-
 * generator.html, invoice-generator.html) and Bahasa Melayu (contoh-sebut-harga.html,
 * contoh-invois.html).
 *
 * Loaded AFTER site.css, which supplies the fonts, the colour tokens and the shared .container /
 * .nav / .brand / .btn / .footer rules. Nothing here redefines a token; everything below is either
 * the two-column editor or the A4 sheet itself.
 *
 * The sheet is drawn at its true A4 pixel size (794 x 1123 at 96dpi) and shrunk to fit with a
 * transform, so what is on screen is exactly what prints. generator.js sets --sheet-scale.
 */

/* ---------------------------------------------------------------- page chrome */

.gen-hero {
  padding: 34px 0 30px;
  background:
    radial-gradient(760px 420px at 84% 0%, rgba(37, 99, 235, .13), transparent 60%),
    linear-gradient(180deg, #fff, var(--bg));
  border-bottom: 1px solid var(--line);
}
.gen-hero .container { max-width: 900px; text-align: center; }
.gen-hero .crumb {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none;
}
.gen-hero .crumb:hover { color: var(--blue); }
.gen-hero h1 { margin: 14px 0 0; font-size: clamp(28px, 5vw, 42px); }
.gen-hero .sub { margin: 12px auto 0; max-width: 620px; color: var(--muted); font-size: 17px; }
/* Two URLs, one tool. The pages stay separate so each can rank for its own search, but the
   visitor sees a single switch and their details follow them across. */
.doc-switch {
  display: inline-flex; margin-top: 20px; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm);
}
.doc-switch a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 22px;
  border-radius: 999px; color: var(--muted);
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
}
.doc-switch a:hover { color: var(--ink); }
.doc-switch a[aria-current="page"] { background: var(--blue); color: #fff; }

/* EN / BM, in the header. Same shape as the home page's language control, but links rather than
   buttons: each language is its own page so that each can be found in its own language. */
.lang-switch { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--bg); }
.lang-switch a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 40px; padding: 0 10px; border-radius: 999px;
  color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.lang-switch a:hover { color: var(--ink); }
.lang-switch a[aria-current="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.gen-hero .points {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px;
  margin: 20px 0 0; padding: 0; list-style: none;
}
.gen-hero .points li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: 13.5px; font-weight: 600;
}
.gen-hero .points .icon { width: 15px; height: 15px; color: var(--teal-ink); }

/* ---------------------------------------------------------------- layout */

.gen-main { padding: 28px 0 8px; }
.gen-grid {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px;
  align-items: start;
}
/* The sheet is drawn at a fixed 794px and shrunk with a transform. Without these, a grid item's
   default min-width:auto sizes the track to that 794px and the whole page scrolls sideways. */
.gen-grid > * { min-width: 0; }
@media (min-width: 1000px) {
  .gen-grid { grid-template-columns: 372px minmax(0, 1fr); gap: 30px; }
  .editor { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
}

/* ---------------------------------------------------------------- the form */

.editor {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px;
  /* Room for the sticky action bar that sits at the bottom of the scrolling panel. */
  scrollbar-width: thin;
}
.editor h2 {
  margin: 22px 0 10px; font-family: var(--font-body);
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted);
}
.editor h2:first-child { margin-top: 0; }

.field { margin-bottom: 11px; }
.field > label,
.sub-label {
  display: block; margin-bottom: 4px;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.field .opt { font-weight: 500; opacity: .75; }

.editor input,
.editor textarea,
.editor select {
  width: 100%; min-height: 42px; padding: 9px 11px;
  font: inherit; font-size: 14.5px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.editor input::placeholder, .editor textarea::placeholder { color: #9aa8bf; }
.editor input:focus, .editor textarea:focus, .editor select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.editor textarea { min-height: 62px; line-height: 1.5; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Line items */
.line {
  position: relative; margin-bottom: 10px; padding: 13px 13px 9px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
}
.line .line-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.line .line-grid input, .line .line-grid select { min-height: 40px; font-size: 14px; }
.line .kill {
  position: absolute; top: 9px; right: 9px;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: #93a1b8; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.line .kill:hover { background: #fde8e8; color: #c62828; }
.line .kill .icon { width: 16px; height: 16px; }
.line .desc { padding-right: 34px; }

.btn-add {
  width: 100%; min-height: 44px; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: #fff; color: var(--blue-deep);
  border: 1px dashed #b9c9ea; border-radius: 12px;
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn-add:hover { background: var(--blue-soft); border-color: var(--blue); }
.btn-add .icon { width: 17px; height: 17px; }

/* Checkbox row */
.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; margin-bottom: 11px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.check input[type="checkbox"] {
  width: 19px; height: 19px; min-height: 0; flex: none; margin-top: 1px;
  accent-color: var(--blue); cursor: pointer;
}
.check label { margin: 0; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.check .why { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }

/* Action bar */
.editor-actions {
  position: sticky; bottom: -20px; z-index: 2;
  margin: 18px -20px -20px; padding: 14px 20px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), #fff 42%);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}
.editor-actions .btn { width: 100%; }
.editor-actions .hint { margin-top: 9px; color: var(--muted); font-size: 12.5px; text-align: center; }
.editor-actions .reset {
  display: block; margin: 8px auto 0; padding: 4px;
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer;
}
.editor-actions .reset:hover { color: var(--ink); }

/* ---------------------------------------------------------------- the A4 sheet */

.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.stage-head .label {
  color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.stage-head .swap { color: var(--blue); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.stage-head .swap:hover { text-decoration: underline; }

.sheet-stage { --sheet-scale: 1; overflow: hidden; }
.sheet {
  width: 794px; min-height: 1123px; padding: 46px 48px;
  background: #fff; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(11, 27, 63, .08), 0 18px 44px -16px rgba(11, 27, 63, .26);
  transform: scale(var(--sheet-scale)); transform-origin: top left;
  font-size: 11pt; line-height: 1.55; color: #1c2b4a;
}

.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; }
.sheet-co { font-family: var(--font-head); font-size: 15.5pt; font-weight: 700; color: var(--ink); }
.sheet-kind {
  font-family: var(--font-head); font-size: 25pt; font-weight: 800; letter-spacing: -.02em;
  color: var(--blue-deep); white-space: nowrap;
}
.sheet-line { max-width: 62ch; font-size: 9.5pt; color: #5b6b85; }
.rule { height: 3px; margin: 15px 0 22px; border-radius: 2px; background: linear-gradient(90deg, var(--blue-deep), var(--blue)); }

.sheet-parties { display: flex; justify-content: space-between; gap: 26px; margin-bottom: 22px; }
.party-tag {
  margin-bottom: 4px; color: var(--blue-deep);
  font-size: 8.5pt; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
}
.party-name { margin-bottom: 2px; font-size: 11.5pt; font-weight: 700; color: var(--ink); }
.sheet-meta { flex: none; text-align: right; white-space: nowrap; }
.sheet-meta dt {
  color: #5b6b85; font-size: 8.5pt; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.sheet-meta dd { margin: 0 0 8px; font-size: 10.5pt; font-weight: 700; color: var(--ink); }
.sheet-meta dd:last-child { margin-bottom: 0; }

.sheet table { width: 100%; border-collapse: collapse; }
.sheet th {
  padding: 10px 11px; text-align: left;
  background: linear-gradient(90deg, var(--blue-deep), var(--blue)); color: #fff;
  font-size: 8.5pt; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet th:first-child { border-radius: 4px 0 0 4px; }
.sheet th:last-child { border-radius: 0 4px 4px 0; }
.sheet td { padding: 10px 11px; font-size: 10pt; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet .num { text-align: right; }
.sheet .desc-cell { font-weight: 600; color: var(--ink); word-break: break-word; }

.sheet-sums { width: 300px; margin: 16px 0 0 auto; }
.sum-row { display: flex; justify-content: space-between; gap: 16px; padding: 5px 13px; font-size: 10pt; }
.sum-band {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  margin-top: 7px; padding: 12px 14px; border-radius: 5px;
  background: linear-gradient(90deg, var(--blue-deep), var(--blue)); color: #fff;
  font-size: 12pt; font-weight: 800; line-height: 1.2;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
/* Malay labels run longer than English ones ("BAKI PERLU DIBAYAR"). Let the label wrap if it must,
   but never the amount — a total split across two lines is unreadable. */
.sum-band span:last-child { white-space: nowrap; }

.sheet-foot { margin-top: 30px; display: flex; gap: 30px; align-items: flex-start; }
.foot-left { flex: 1; min-width: 0; }
.sheet-foot h4 { margin: 0 0 5px; font-family: var(--font-body); font-size: 10pt; font-weight: 700; color: var(--ink); }
.sheet-foot p { font-size: 9.5pt; color: #5b6b85; white-space: pre-line; }
.pay-box {
  flex: none; width: 260px; padding: 13px 15px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pay-box dl { margin: 0; font-size: 9.5pt; }
.pay-box dt { color: #5b6b85; }
.pay-box dd { margin: 0 0 6px; font-weight: 700; color: var(--ink); }
.pay-box dd:last-child { margin-bottom: 0; }
/* Sits in the left column beside the payment box, not underneath it — a tall payment box used to
   push this one line onto a second sheet of paper. */
.sheet-thanks {
  margin-top: 26px;
  font-size: 9.5pt; font-weight: 700; letter-spacing: .04em; color: var(--blue-deep);
}

/* ---------------------------------------------------------------- copy below the tool */

.gen-cta {
  margin: 44px auto 0; max-width: 780px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px 24px;
  padding: 26px 28px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--blue-deep), var(--blue)); color: #fff;
  box-shadow: var(--shadow-lg);
}
.gen-cta .cta-mark { width: 44px; height: 45px; flex: none; color: #fff; opacity: .92; }
.gen-cta .cta-text { flex: 1 1 260px; }
.gen-cta h2 { margin: 0 0 6px; color: #fff; font-size: 21px; }
.gen-cta p { color: rgba(255, 255, 255, .86); font-size: 15px; }
.gen-cta .btn { flex: none; background: #fff; color: var(--blue-deep); box-shadow: none; }
.gen-cta .btn:hover { background: #eef3ff; }

.gen-seo { padding: 20px 0 72px; }
.gen-seo .container { max-width: 760px; }
.gen-seo h2 { margin: 40px 0 12px; font-size: clamp(22px, 3vw, 28px); }
.gen-seo h3 { margin: 28px 0 8px; font-size: 18px; }
.gen-seo p { margin-bottom: 12px; color: var(--text); }
.gen-seo ul { margin: 10px 0 14px; padding-left: 22px; color: var(--text); }
.gen-seo li { margin-bottom: 6px; }
.gen-seo .tools {
  display: grid; gap: 12px; margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.gen-seo .tools a {
  display: block; padding: 16px 18px; border-radius: 16px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.gen-seo .tools a:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.gen-seo .tools strong { display: block; color: var(--ink); font-family: var(--font-head); font-size: 16px; }
.gen-seo .tools span { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- print: the sheet alone */

@page { size: A4; margin: 0; }

@media print {
  html, body { background: #fff; }
  .nav, .footer, .gen-hero, .gen-seo, .gen-cta, .editor, .stage-head, .skip, .noprint {
    display: none !important;
  }
  .gen-main { padding: 0; }
  .gen-main .container { max-width: none; padding: 0; }
  .gen-grid { display: block; gap: 0; }
  .sheet-stage { overflow: visible; height: auto !important; }
  .sheet {
    width: auto; min-height: auto; padding: 13mm 13mm 9mm;
    border-radius: 0; box-shadow: none;
    transform: none !important;
  }
  /* Tighter on paper than on screen: a typical job then lands on one sheet instead of spilling a
     single closing line onto a second one. */
  .sheet-foot { margin-top: 24px; }
  .sheet-thanks { margin-top: 18px; }
  /* Never let a total, a payment box or a line item be sliced across two sheets of paper. */
  .sheet tr, .sheet-sums, .sum-band, .pay-box { break-inside: avoid; }
  .sheet thead { display: table-header-group; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- store links

   These four pages used to send everyone to the home page to hunt for a download
   badge: two hops from the moment someone actually wanted the app, and each hop
   loses most of them. The badges now point at the stores directly.

   .dl-cta is the second half of that — it sits hidden inside the editor actions
   and generator.js reveals it when the print dialog opens, so the ask arrives
   after the tool has delivered a PDF rather than before. */

.store-badges { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.store-badges a { display: block; line-height: 0; border-radius: 9px; transition: transform .18s ease, opacity .18s ease; }
.store-badges a:hover { transform: translateY(-1px); opacity: .9; }
.store-badges img { display: block; height: 44px; width: auto; }

.dl-cta { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dl-cta[hidden] { display: none; }
.dl-cta p { margin: 0 0 11px; color: var(--muted); font-size: 13px; line-height: 1.55; text-align: center; }
.dl-cta p strong { color: var(--ink); }
.dl-cta .store-badges { justify-content: center; }
.dl-cta .store-badges img { height: 40px; }

/* The bottom block is on the blue gradient, where a plain badge sits fine but a
   wrapped one looks broken — keep the pair together and let the text column give
   way first. */
.gen-cta .store-badges { flex: none; flex-wrap: nowrap; }

@media (max-width: 560px) {
  .store-badges img { height: 38px; }
  .dl-cta .store-badges img { height: 36px; }
}
