/* Quote screen (js/screens/quote.js): new and edit form, saved quotes, one quote.
   Tokens from app.css only. The map's own marks (corner dots, pins, lengths, the "can't show
   pictures" card) are drawn by map.css; this file places the map box, its tools and readout. */

/* ---------- Form: map box ---------- */

.quote-mapblock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.quote-map {
  height: clamp(300px, 50vh, 420px);
}

/* No pictures here (preview, offline, failed): map.js covers the box with its card, so the
   box only needs to fit that card; the typed feet right below are the next step. */
.quote-map[data-map-state="preview"],
.quote-map[data-map-state="offline"] {
  height: 222px;
}

.quote-map[data-map-state="error"] {
  height: 270px;
}

.quote-map[data-map-state="preview"] + .quote-howto,
.quote-map[data-map-state="offline"] + .quote-howto,
.quote-map[data-map-state="error"] + .quote-howto {
  display: none;
}

/* Feet readout, top left. Taps go through it to the map. */
.quote-readout {
  pointer-events: none;
  white-space: nowrap;
}

/* First-step hint, bottom left (above the credit line) until two corners are down */
.quote-maphint {
  position: absolute;
  left: 10px;
  bottom: 28px;
  z-index: 1000;
  max-width: calc(100% - 84px);
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-ink);
  box-shadow: var(--shadow-1);
  font: 600 14px/1.25 var(--font-body);
  pointer-events: none;
}

/* Tools in one row, top right: undo, clear, line or loop */
.quote-tools {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.quote-tools .icon-btn:disabled {
  opacity: 1;
  color: var(--line-strong);
}

.quote-tools .quote-shape {
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-1);
}

.quote-tools .quote-shape .seg__opt {
  flex: none;
  min-height: 36px;
  padding: 0 11px;
  color: var(--ink-2);
}

.quote-tools .quote-shape .seg__opt[aria-checked="true"] {
  background: var(--btn);
  color: var(--btn-ink);
  box-shadow: none;
}

.quote-howto {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0 2px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.4;
}

.quote-howto .icon {
  margin-top: 1px;
  color: var(--accent-ink);
}

/* ---------- Form: fence length and months ---------- */

.quote-measure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.quote-panels {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.quote-panels .icon {
  color: var(--accent-ink);
}

.quote-usemap {
  align-self: flex-start;
  max-width: 100%;
}

/* ---------- Form: price options (Claude suggests three rents) ---------- */

.popts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popts__intro,
.popts__note,
.popts__assumed {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-2);
}

.popts__assumed strong {
  color: var(--ink);
}

.popts__get {
  align-self: flex-start;
}

.popts__status:empty {
  display: none;
}

.popts__status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.popts__thinking,
.popts__error,
.popts__stale {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

.popts__thinking .icon {
  color: var(--accent-ink);
  margin-top: 2px;
}

.popts__error {
  color: var(--bad);
}

.popts__error .icon,
.popts__stale .icon {
  flex: none;
  margin-top: 2px;
}

.popts__stale {
  color: var(--warn);
  font-size: 14px;
}

.popts__tiers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popts__tiers:empty,
.popts__foot:empty {
  display: none;
}

.popts__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popts .linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 44px;
}

.popts-tier {
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.popts-tier.is-open {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.popts-tier__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    'name total chev'
    'sub sub chev';
  align-items: baseline;
  column-gap: 10px;
  row-gap: 2px;
  width: 100%;
  min-height: 60px;
  margin: 0;
  padding: 12px 12px 12px 16px;
  border: 0;
  border-radius: var(--radius-card);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.popts-tier__head:focus-visible {
  outline-offset: -3px;
}

@media (hover: hover) {
  .popts-tier__head:hover {
    background: var(--surface-2);
  }
}

.popts-tier__name {
  grid-area: name;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 17px;
  font-weight: 700;
}

.popts-tier__on {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 12px;
  font-weight: 600;
}

.popts-tier__total {
  grid-area: total;
  font: 600 24px/1.1 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.popts-tier__sub {
  grid-area: sub;
  font-size: 14px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.popts-tier__chev {
  grid-area: chev;
  align-self: center;
  color: var(--ink-2);
}

.popts-tier__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 16px;
}

.popts-tier__lines {
  border-top: 1px solid var(--line);
}

.popts-tier__lines .kv__v {
  flex: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.popts-tier__sum .kv__k,
.popts-tier__sum .kv__v {
  color: var(--ink);
  font-weight: 700;
}

.popts-tier__why,
.popts-tier__floor {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.popts-tier__floor {
  color: var(--warn);
  font-size: 14px;
}

/* ---------- Form: prices for this quote ---------- */

.quote-prices__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  margin: 0;
  padding: 12px 14px 12px 16px;
  border: 0;
  border-radius: var(--radius-card);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.quote-prices.is-open .quote-prices__toggle {
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.quote-prices__toggle:focus-visible {
  outline-offset: -3px;
}

@media (hover: hover) {
  .quote-prices__toggle:hover {
    background: var(--surface-2);
  }
}

.quote-prices__sum {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quote-prices__text {
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.quote-prices__note {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--accent-ink);
}

.quote-prices__act {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.quote-prices.is-open .quote-prices__act {
  background: var(--btn);
  box-shadow: none;
  color: var(--btn-ink);
}

.quote-prices__fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.quote-prices__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

/* ---------- Form: customer, notes ---------- */

.quote-optional {
  font-size: 13px;
  line-height: 1.3;
  color: var(--ink-2);
}

.quote-customer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px 12px;
  align-items: start;
}

@media (min-width: 560px) {
  .quote-customer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Total (form and detail) ---------- */

.quote-line__label {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.quote-line__detail {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-2);
}

/* Amounts keep their full width; a long item name wraps instead */
.quote-total .kv__v {
  flex: none;
  white-space: nowrap;
}

.quote-total__extra {
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.quote-total__extra strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.quote-total__wait {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--ink-2);
  font: 600 22px/1.2 var(--font-display);
  letter-spacing: 0.01em;
}

.quote-total__wait .icon {
  color: var(--accent-ink);
}

.quote-startover {
  display: flex;
  justify-content: center;
  margin-top: -6px;
}

.quote-startover .btn {
  color: var(--ink-2);
}

/* ---------- Sticky bar: running total and Save ---------- */

.quote-sticky {
  align-items: center;
  gap: 14px;
}

.quote-sticky__total {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding-left: 2px;
}

.quote-sticky__label {
  font: 600 12px/1.2 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.quote-sticky__value {
  font: 700 26px/1.05 var(--font-display);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

/* ---------- App bar: Saved (count) ---------- */

.quote-saved.btn {
  gap: 6px;
  padding: 0 10px 0 12px;
}

.quote-saved__count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-ink);
  font: 700 12px/22px var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ---------- Saved quotes list ---------- */

.quote-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quote-chips--stack {
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.chip.quote-chip-sample {
  background: transparent;
  box-shadow: none;
  border: 1px dashed var(--line-strong);
  color: var(--ink-2);
}

.chip.quote-chip-sample::before {
  display: none;
}

/* ---------- Quote detail ---------- */

.quote-detail__part {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.quote-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: -4px;
}

.quote-status__date {
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
}

.quote-send {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quote-send .btn {
  padding: 0 12px;
}

/* Sent / job rows: icon, two lines of text, one button */
.quote-row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
}

.quote-row-card__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
}

.quote-row-card.is-done .quote-row-card__icon {
  background: var(--ok-bg);
  color: var(--ok);
}

.quote-row-card__text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.quote-row-card__text strong {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.quote-row-card__text span {
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.quote-row-card > .btn {
  flex: none;
}

.quote-makejob {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quote-hint {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.quote-makejob .quote-hint {
  text-align: center;
}

.quote-passed {
  color: var(--warn);
}

.quote-tel {
  color: var(--accent-ink);
  text-decoration: none;
}

.quote-tel:hover {
  text-decoration: underline;
}

.quote-none {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.45;
}

.quote-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quote-notes__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.quote-end {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.quote-end .btn {
  padding: 0 12px;
}

/* Small map of the fence: looking only. The cover takes the taps; the credit line stays usable. */
.quote-detail-map {
  height: 230px;
}

.quote-detail-map__cover {
  position: absolute;
  inset: 0;
  z-index: 999;
}

.quote-detail-map .leaflet-control-zoom {
  display: none;
}

/* When map.js has to show its "can't show pictures" card, the whole section steps aside. */
.quote-detail-mapsec:has(.map-overlay) {
  display: none;
}

/* ---------- Small and wide screens ---------- */

/* Very narrow phones: the app bar keeps the title; Saved shows as its icon and count */
@media (max-width: 359px) {
  .quote-saved .btn__label {
    display: none;
  }
}

@media (min-width: 680px) {
  .quote-map {
    height: clamp(340px, 52vh, 460px);
  }

  .quote-detail-map {
    height: 280px;
  }

  .quote-chips--stack {
    flex-direction: row-reverse;
    align-items: center;
    gap: 6px;
  }
}
