/*
 * Prices design preview — layout for the lists on top of the quote screen's
 * own styles (css/styles.css). Type uses Web Awesome tokens only; colour
 * uses the Quotology brand tokens from styles.css.
 */

/*
 * Autosave toast — same idea as Cursor’s “Thanks for your feedback” pill:
 * floating, centred, brief, then fades away. Quotology navy instead of IDE chrome.
 */
.save-footer {
  position: fixed;
  inset-inline: 0;
  /* Sit above the pinned tab bar. */
  bottom: calc(var(--prices-tab-bar-height, 3.25rem) + env(safe-area-inset-bottom, 0px) + var(--space));
  z-index: 30;
  display: grid;
  justify-items: center;
  padding-inline: var(--space);
  pointer-events: none;
}

/*
 * Live reload — one ease only (fade in). Leave is an instant cover so we never
 * play fade-out → hold → fade-in (reads as two eases with a gap).
 */
html.qe-live-reload-pending body,
html.qe-live-reload-out body {
  opacity: 0;
  pointer-events: none;
}

html.qe-live-reload-in body {
  animation: qe-reload-in 480ms ease both;
}

@keyframes qe-reload-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.saved {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--qo-navy);
  font-size: var(--wa-font-size-s);
  font-weight: var(--wa-font-weight-action);
  line-height: var(--wa-line-height-normal);
  box-shadow: 0 0.5rem 1.5rem rgb(0 42 78 / 14%);
}

.saved.is-enter {
  animation: saved-in 480ms var(--motion-reveal-ease) both;
}

.saved.is-leaving {
  animation: saved-out 360ms var(--motion-reveal-ease) both;
}

.saved .icon {
  inline-size: var(--wa-font-size-s);
  block-size: var(--wa-font-size-s);
  color: var(--qo-navy);
}

.saved[hidden] {
  display: none;
}

.price-tabs .field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
}

.price-tabs section:not(.result) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
}

.price-tabs section[hidden] {
  display: none;
}

.section-title {
  margin: 0;
  font-size: var(--wa-font-size-m);
  font-weight: var(--wa-font-weight-heading);
  line-height: var(--wa-line-height-condensed);
  color: var(--color-ink);
}

.hint {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--wa-font-size-m);
  line-height: var(--wa-line-height-normal);
  white-space: pre-line;
}

.hint[hidden] {
  display: none;
}

/* Space between the adjustment copy and the £/m² rows. */
.price-tabs wa-accordion-item .hint {
  padding-block-end: var(--wa-space-m);
}

.lines {
  display: grid;
  gap: var(--wa-space-l);
  margin: 0;
  padding: 0;
  list-style: none;
}

.line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0;
  row-gap: var(--space-xs);
}

.line--name-only {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

/*
 * Mobile first: field name above, £ control fills the page column.
 * Same habit as Rate and Minimum charge — no side-by-side squeeze.
 */
.line--price-only {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.line--price-only .line__label,
.line--price-only .line__price {
  grid-column: 1;
  grid-row: auto;
}

.line [data-action='remove'] {
  grid-column: 3;
  grid-row: 1;
}

.line--name-only [data-action='remove'] {
  grid-column: 3;
}

.line__label {
  color: var(--color-ink);
  font-size: var(--wa-font-size-l);
  font-weight: var(--wa-font-weight-semibold);
  line-height: var(--wa-line-height-condensed);
}

.line.is-dragging {
  opacity: 0.6;
}

.line.is-drop-target {
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--color-ring);
}

.line.is-added {
  border-radius: var(--radius);
  animation: row-added 900ms var(--motion-reveal-ease) both;
}

.line.is-removing {
  pointer-events: none;
  animation: row-removing 220ms ease-in both;
}

.add-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-2xs);
}

.add-line[hidden] {
  display: none;
}

.add-line--end-slot {
  display: block;
}

.add-line--end-slot .name-input {
  display: block;
  inline-size: 100%;
}

.add-line--end-slot .icon-button {
  margin-inline-end: var(--space-2xs);
}

.name-input {
  display: block;
  inline-size: 100%;
}

.name-input.is-saved,
.price-input.is-saved {
  animation: saved-flash 700ms ease-out both;
}

/* Full-width: leave WA’s default --wa-form-control-padding-inline (1em) alone. */
.price-input {
  display: block;
  box-sizing: border-box;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
}

.price-input .field__unit {
  white-space: nowrap;
}

.price-input::part(input) {
  min-inline-size: 0;
  text-align: center;
}

/* Quote form collapses empty start slots for Length/Width/Area — keep £ visible here. */
.price-input::part(start) {
  display: flex;
  flex: 0 0 auto;
}

.price-input::part(end) {
  display: flex;
  flex: 0 0 auto;
}

.icon {
  inline-size: var(--wa-font-size-l);
  block-size: var(--wa-font-size-l);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button[data-action='drag'] {
  cursor: grab;
  touch-action: none;
}

.icon-button:focus-visible {
  outline: 3px solid var(--color-ring);
  outline-offset: -2px;
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  justify-self: start;
  min-block-size: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: var(--wa-font-size-s);
  font-weight: var(--wa-font-weight-action);
  line-height: var(--wa-line-height-normal);
  cursor: pointer;
}

.text-button[hidden] {
  display: none;
}

.text-button--inline {
  color: var(--color-accent);
  text-decoration: underline;
}

.text-button:focus-visible {
  outline: 3px solid var(--color-ring);
  outline-offset: 2px;
}

.text-button:disabled {
  opacity: 0.35;
  cursor: default;
}

@keyframes saved-in {
  from {
    opacity: 0;
    transform: translateY(0.35rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes saved-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(0.2rem);
  }
}

@keyframes saved-flash {
  from {
    box-shadow: 0 0 0 3px var(--qo-cyan);
    background-color: var(--qo-cyan-100);
  }

  to {
    box-shadow: 0 0 0 0 transparent;
    background-color: transparent;
  }
}

@keyframes row-added {
  from {
    opacity: 0;
    transform: translateY(calc(-1 * var(--motion-reveal-shift)));
    background-color: var(--qo-cyan-100);
  }

  40% {
    opacity: 1;
    transform: translateY(0);
    background-color: var(--qo-cyan-100);
  }

  to {
    background-color: transparent;
  }
}

@keyframes row-removing {
  to {
    opacity: 0;
    transform: translateX(1.5rem) scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  .saved.is-enter,
  .saved.is-leaving,
  .line.is-added,
  .line.is-removing,
  .name-input.is-saved,
  .price-input.is-saved,
  html.qe-live-reload-in body {
    animation: none;
  }

  html.qe-live-reload-pending body,
  html.qe-live-reload-out body {
    opacity: 1;
    pointer-events: auto;
  }
}

.field[hidden] {
  display: none;
}

.field-label {
  color: var(--color-ink);
  /* Match Job type / Surface / accordion labels and size="l" price inputs. */
  font-size: var(--wa-font-size-l);
  font-weight: var(--wa-font-weight-semibold);
  line-height: var(--wa-line-height-condensed);
}

/* Page column for tabs, fields and accordion copy; nav/accordion chrome stays full bleed. */
.price-tabs {
  --prices-page-column: min(40rem, calc(100% - (2 * var(--space))));
  --prices-page-gutter: max(var(--space), calc((100% - 40rem) / 2));
  /* In-app navbar: icon + label stack. */
  --prices-tab-bar-height: 4rem;
  /* Hide WA’s underline track — active state is colour, not a top rule. */
  --safe-track-width: 0px;
  --track-color: transparent;
  --indicator-color: transparent;
  display: block;
  width: 100%;
}

.price-tabs::part(nav) {
  box-sizing: border-box;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 25;
  width: 100%;
  min-block-size: var(--prices-tab-bar-height);
  /* Full-bleed chrome; inset the tab list to the page column (WA flex:1 ignores width). */
  padding-inline: var(--prices-page-gutter);
  padding-block-start: var(--space-xs);
  padding-block-end: calc(var(--space-xs) + env(safe-area-inset-bottom, 0px));
  border-block-start: 1px solid var(--color-border);
  border-block-end: none;
  background: #fff;
  box-shadow: 0 -0.35rem 1.25rem rgb(0 42 78 / 10%);
}

.price-tabs::part(tabs) {
  display: flex;
  width: 100%;
  border: none;
}

.price-tabs wa-tab {
  flex: 1 1 0;
  min-inline-size: 0;
  display: block;
  color: var(--color-muted);
  border: none;
  margin: 0;
}

.price-tabs wa-tab[active] {
  color: var(--qo-navy);
  border: none;
  margin: 0;
}

.price-tabs wa-tab::part(base) {
  display: flex;
  box-sizing: border-box;
  inline-size: 100%;
  min-block-size: 2.75rem;
  justify-content: center;
  align-items: center;
  padding: var(--space-2xs) var(--space-2xs);
  font-size: var(--wa-font-size-s);
  font-weight: var(--wa-font-weight-semibold);
  line-height: var(--wa-line-height-condensed);
  color: inherit;
  white-space: normal;
}

.price-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-inline-size: 0;
}

.price-tab__icon {
  inline-size: var(--wa-font-size-l);
  block-size: var(--wa-font-size-l);
  flex-shrink: 0;
}

.price-tab__label {
  display: block;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.price-tabs::part(body) {
  width: 100%;
  margin: 0;
  padding: 0;
  /* Keep scrolled content clear of the pinned tab bar. */
  padding-block-end: calc(
    var(--prices-tab-bar-height) + env(safe-area-inset-bottom, 0px) + var(--space)
  );
}

.price-tabs wa-tab-panel::part(base) {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  padding-block: var(--space);
  padding-inline: 0;
}

.price-tabs wa-tab-panel > * {
  box-sizing: border-box;
  width: var(--prices-page-column);
  max-inline-size: 100%;
  margin-inline: auto;
}

.tab-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs);
}

.tab-stack[hidden] {
  display: none;
}

/*
 * Conditions / Extras list accordion only — do not style .result__calculation
 * (View calculation must keep the quote-screen result__* rules in styles.css).
 */
.price-tabs #prices-lists {
  min-inline-size: 0;
  border-block: 1px solid var(--color-border);
}

.price-tabs #prices-lists[hidden] {
  display: none;
}

.price-tabs #prices-lists wa-accordion-item {
  --spacing: 0;
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
  /* Clear the sticky header when an expand scrolls the item into view. */
  scroll-margin-top: calc(
    var(--header-logo-height, 40px) + var(--space-md) + var(--space-sm)
  );
}

.price-tabs #prices-lists wa-accordion-item:not(:first-child) {
  border-top-color: var(--color-border);
}

/* Same size and weight as Job type / Surface wa-select labels (L + form label). */
.price-tabs #prices-lists wa-accordion-item::part(button) {
  box-sizing: border-box;
  padding-block: calc(var(--space) + var(--space-md));
  padding-inline: 0;
  font-size: var(--wa-font-size-l);
  /* Same as WA select labels (--wa-form-control-label-font-weight → semibold). */
  font-weight: var(--wa-font-weight-semibold);
  line-height: var(--wa-line-height-condensed);
  color: var(--color-ink);
}

.price-tabs #prices-lists wa-accordion-item::part(content) {
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
  /*
   * WA accordion panel uses overflow:hidden (for expand animation). Inset by the
   * focus ring so full-width price fields are not clipped at the sides on focus.
   */
  padding-inline: calc(var(--wa-focus-ring-width) + var(--wa-focus-ring-offset));
  padding-block-end: var(--wa-space-l);
}

.price-tabs #prices-lists wa-accordion-item::part(label) {
  font: inherit;
  color: inherit;
}

.price-tabs #prices-lists wa-accordion-item::part(icon) {
  font-size: var(--wa-font-size-l);
  color: var(--color-ink);
}

.price-tabs #prices-lists wa-accordion-item .lines,
.price-tabs #prices-lists wa-accordion-item .line {
  min-inline-size: 0;
  max-inline-size: 100%;
}

.price-tabs #prices-lists wa-accordion-item .line__price {
  min-inline-size: 0;
  max-inline-size: 100%;
}

.price-input.is-incomplete {
  --wa-form-control-background-color: var(--color-advisory-soft);
  --wa-form-control-border-color: var(--color-advisory);
}

.text-button[hidden] {
  display: none;
}
