/* estimates.css — see components.css for the shared system; this file is owned by one module. */

/* ---- The desk (estimate-edit) ------------------------------------------- */
.estdesk { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-4); align-items: start; }
.estdesk__main { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.estdesk__side { min-width: 0; align-self: stretch; }
.estdesk__side .card__body { min-width: 0; }
.estdesk__sticky { position: sticky; top: var(--s-4); }
@media (max-width: 960px) {
  .estdesk { grid-template-columns: minmax(0, 1fr); }
  .estdesk__sticky { position: static; }
}

/* Customer row: the picker and the « new customer » button side by side. */
.estcustrow { display: flex; gap: var(--s-2); align-items: stretch; min-width: 0; }
.estcustrow .estcombo { flex: 1 1 auto; min-width: 0; }
.estcustrow .btn { flex: none; white-space: nowrap; }
@media (max-width: 480px) { .estcustrow { flex-wrap: wrap; } .estcustrow .btn { width: 100%; } }

/* The searchable picker: an input with a menu under it. */
.estcombo { position: relative; min-width: 0; }
.estcombo__icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: grid; }
.estcombo .input { padding-left: 32px; width: 100%; }
.estcombo__menu {
  position: fixed; z-index: var(--z-modal);
  max-height: 320px; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 4px;
}
.estcombo__item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer;
}
.estcombo__item:hover, .estcombo__item.is-active { background: var(--accent-soft); }
.estcombo__body { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
.estcombo__title { font-weight: var(--fw-semi); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estcombo__meta { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estcombo__side { flex: none; text-align: right; font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; line-height: 1.3; }

/* Lines: a grid per line so the phone layout can stack the numbers. */
.estlines { display: flex; flex-direction: column; }
.estlines__empty { padding: var(--s-4); }
.estline {
  display: grid; align-items: center; gap: var(--s-2) var(--s-3);
  grid-template-columns: 44px minmax(0, 1fr) 84px 108px 108px 32px;
  grid-template-areas: "n desc qty price amt x";
  padding: 8px var(--s-4); border-bottom: 1px solid var(--border-subtle);
}
.estline:has(.estline__cost) { grid-template-columns: 44px minmax(0, 1fr) 84px 108px 100px 108px 32px; grid-template-areas: "n desc qty price cost amt x"; }
.estline--head { padding-top: 10px; padding-bottom: 6px; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.estline--head > div { text-align: right; display: block; } .estline--head > .estline__desc { text-align: left; }
.estline__n { grid-area: n; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.estline__kind { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.estline[data-kind="part"] .estline__kind { background: var(--success-soft); color: var(--success-ink); }
.estline[data-kind="sublet"] .estline__kind, .estline[data-kind="other"] .estline__kind { background: var(--warning-soft); color: var(--warning-ink); }
.estline__desc { grid-area: desc; min-width: 0; display: grid; gap: 2px; }
.estline__desc .input { width: 100%; }
.estline__sub { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 2px; }
.estline__qty { grid-area: qty; } .estline__price { grid-area: price; } .estline__cost { grid-area: cost; }
.estline__qty .input, .estline__price .input, .estline__cost .input { width: 100%; text-align: right; }
.estline__lbl { display: none; font-size: var(--fs-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.estline__amt { grid-area: amt; text-align: right; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.estline__amt b { font-weight: var(--fw-semi); white-space: nowrap; }
.estline__amt small { font-size: var(--fs-2xs); }
.estline__x { grid-area: x; text-align: right; }
.estline .input--sm { height: 30px; }
@media (max-width: 700px) {
  .estline, .estline:has(.estline__cost) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 32px;
    grid-template-areas: "n desc desc x" "qty price price price" "amt amt amt amt";
    gap: var(--s-2);
  }
  .estline:has(.estline__cost) { grid-template-areas: "n desc desc x" "qty price cost cost" "amt amt amt amt"; }
  .estline--head { display: none; }
  .estline__lbl { display: block; }
  .estline__amt { flex-direction: row; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
  .estline__amt .estline__lbl { margin: 0 auto 0 0; }
}

/* The add bar under the lines. */
.estadd { padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid var(--border); background: var(--surface-2); display: grid; gap: var(--s-2); }
.estadd .segmented { justify-self: start; max-width: 100%; overflow-x: auto; }
.estadd__row { display: flex; gap: var(--s-2); align-items: stretch; min-width: 0; }
.estadd__row .estcombo { flex: 1 1 auto; min-width: 0; }
.estadd__qty { flex: none; display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.estadd__qty .input { width: 76px; text-align: right; }
@media (max-width: 560px) {
  .estadd__row { flex-wrap: wrap; }
  .estadd__row .estcombo { flex-basis: 100%; }
  .estadd__row .btn { flex: 1 1 auto; }
}

/* Totals panel — shared by the desk and the detail page. */
.esttotals { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; font-variant-numeric: tabular-nums; }
.esttotals > div:not(.esttotals__int) { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); min-width: 0; }
.esttotals > div > span { color: var(--ink-3); font-size: var(--fs-sm); min-width: 0; }
.esttotals > div > span em { font-style: normal; font-size: var(--fs-2xs); color: var(--muted); margin-left: 3px; }
.esttotals > div > b { font-weight: var(--fw-semi); white-space: nowrap; }
.esttotals__sub { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.esttotals__total { margin-top: 4px; padding: 10px 12px; border-radius: var(--r-md); background: var(--ink); color: var(--surface); }
.esttotals__total > span { color: inherit !important; opacity: .8; font-weight: 600; }
.esttotals__total > b { font-size: var(--fs-xl); letter-spacing: -.01em; }
[data-theme="dark"] .esttotals__total { background: var(--accent); color: #fff; }
.esttotals__int { margin-top: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); border: 1px dashed var(--border-strong); background: var(--surface-2); display: grid; gap: 4px; }
.esttotals__int > div { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); }
.esttotals__int > div > span { color: var(--muted); }
.esttotals__int small { font-size: var(--fs-2xs); color: var(--muted); }
.esttotals__disc { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.esttotals__discin { display: flex; gap: 6px; }
.esttotals__discin .input { width: 96px; text-align: right; }
.esttotals__discin .select { width: 60px; min-width: 0; }

/* ---- Detail page ---------------------------------------------------------- */
.estdetail__lbl { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* ---- The printed « Soumission » ------------------------------------------ */
.estdoc__meta { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) auto; gap: .3in; }
.estdoc__meta .invdoc__billto { min-width: 0; }
.estdoc__meta .invdoc__facts { min-width: 1.9in; }
@media (max-width: 640px) { .estdoc__meta { grid-template-columns: minmax(0, 1fr); gap: .15in; } }
.estdoc .invdoc__stamp { top: .32in; right: 2.35in; font-size: 17pt; padding: 3px 14px; }
.estdoc__title { margin: .05in 0 .1in; font-size: 13pt; font-weight: 750; letter-spacing: -.01em; color: #111827; }
.estdoc__sec { margin-top: .12in; break-inside: avoid; }
.estdoc__sectitle { font-size: 8pt; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6b7280; padding-bottom: 3px; border-bottom: 2px solid #111827; }
.estdoc__table { width: 100%; margin-left: 0; }
.estdoc__exempt { font-style: normal; font-size: 7.5pt; color: #6b7280; }
.estdoc__terms { font-size: 8.5pt; color: #4b5563; }
.estdoc .invdoc__bottom { margin-top: .2in; }
.estdoc__sign { margin-top: .22in; padding: .12in .2in; border: 1px solid #d1d5db; border-radius: 8px; break-inside: avoid; }
.estdoc__signtitle { font-size: 8pt; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6b7280; }
.estdoc__signtext { margin: 4px 0 .2in; font-size: 9pt; color: #374151; }
.estdoc__signgrid { display: grid; grid-template-columns: 1.4fr 1.6fr 1fr; gap: .3in; }
.estdoc__signgrid > div { border-top: 1px solid #111827; padding-top: 4px; font-size: 8pt; color: #6b7280; min-height: .45in; display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; }
.estdoc__signgrid b { color: #111827; font-size: 10pt; }
@media (max-width: 640px) { .estdoc__signgrid { grid-template-columns: 1fr; gap: .2in; } }
@media print {
  .estdoc .invdoc__stamp { top: .05in; right: 2.3in; }
}

/* ---- The soumission's header: the logo large, the number loud ---- */
.estdoc__hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35in; align-items: center; padding-bottom: .18in; }
.estdoc__brand { display: flex; gap: .2in; align-items: center; min-width: 0; }
.estdoc__logo { width: 2.1in; max-height: 1.45in; object-fit: contain; flex: none; }
.estdoc__coblock { min-width: 0; }
.estdoc__idblock { text-align: right; display: grid; justify-items: end; gap: 4px; }
.estdoc__word { font-size: 26pt; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; line-height: 1; color: var(--accent); }
.estdoc__no { font-size: 15pt; font-weight: 800; font-family: var(--font-mono); letter-spacing: .02em; }
.estdoc__total-chip { display: inline-flex; align-items: baseline; gap: 8px; padding: 4px 12px; border-radius: 999px; background: #111827; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.estdoc__total-chip span { font-size: 7.5pt; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.estdoc__total-chip b { font-size: 12pt; }
.estdoc__hero .invdoc__bars { width: 1.6in; }
.estdoc__band { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2in; margin: 0 -.65in .1in; padding: 6px .65in; background: #111827; color: #fff; font-size: 8pt; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.estdoc__sign.has-qr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3in; align-items: center; }
.estdoc__qr { display: flex; gap: .14in; align-items: center; text-decoration: none; color: inherit; max-width: 2.9in; }
.estdoc__qrcode { width: 1.05in; height: 1.05in; flex: none; padding: 5px; background: #fff; border-radius: 8px; }
.estdoc__qrcode svg { width: 100%; height: 100%; display: block; }
.estdoc__qrtext b { display: block; font-size: 10pt; }
.estdoc__qrtext span { display: block; font-size: 8pt; color: #6b7280; margin-top: 2px; }
@media (max-width: 640px) { .estdoc__hero, .estdoc__sign.has-qr { grid-template-columns: 1fr; } .estdoc__idblock { justify-items: start; text-align: left; } .estdoc__logo { width: 1.6in; } }
@media print { .estdoc__band { margin-inline: -.5in; padding-inline: .5in; } }
