/* Baseline styling for the core form block.
 *
 * A block that ships without any styling renders as labels and inputs stacked
 * flat against the left edge of the viewport — technically correct markup that
 * nobody would put on a customer-facing page. So the plugin carries enough CSS
 * to be presentable on any site out of the box.
 *
 * It stays deliberately quiet about identity: colours, fonts and radii come
 * from custom properties that default to `inherit` or neutral values, so the
 * form takes on the surrounding page rather than imposing a look. Every
 * selector is a single class, so a theme overrides by naming the same class
 * without fighting specificity. This file is loaded only on pages that
 * actually contain a form block.
 */

.bf-form {
  --bf-form-max-width: 46rem;
  --bf-form-gap: 1.15rem;
  --bf-form-radius: 0.5rem;
  --bf-form-border: 1px solid currentColor;
  --bf-form-border-opacity: 0.25;
  --bf-form-control-padding: 0.6rem 0.75rem;
  --bf-form-accent: currentColor;
  --bf-form-muted-opacity: 0.7;

  box-sizing: border-box;
  width: 100%;
  max-width: var(--bf-form-max-width);
  margin-inline: auto;
  padding: clamp(1rem, 4vw, 2.5rem) 1rem;
}

.bf-form *,
.bf-form *::before,
.bf-form *::after {
  box-sizing: inherit;
}

.bf-form__title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  line-height: 1.25;
}

.bf-form__intro {
  margin: 0 0 1.5rem;
  opacity: var(--bf-form-muted-opacity);
  line-height: 1.6;
}

.bf-form__closed {
  padding: 1rem;
  border: var(--bf-form-border);
  border-radius: var(--bf-form-radius);
  opacity: var(--bf-form-muted-opacity);
}

/* The trap is the honeypot: off-screen rather than display:none, because some
   bots skip fields they can tell are hidden. */
.bf-form__trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.bf-form__message {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: var(--bf-form-border);
  border-radius: var(--bf-form-radius);
}

.bf-form__fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bf-form-gap);
}

.bf-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 100%;
  min-width: 0;
}

/* Two half fields share a row on anything wider than a phone, and fall back to
   full rows below that — a name and a phone number side by side are unusable at
   360px. */
.bf-form__field.is-half {
  flex: 1 1 100%;
}

@media (min-width: 40rem) {
  .bf-form__field.is-half {
    flex: 1 1 calc(50% - (var(--bf-form-gap) / 2));
  }
}

.bf-form__field--hidden {
  display: none;
}

.bf-form__label {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
}

.bf-form__required {
  color: var(--bf-form-accent);
}

.bf-form__control {
  width: 100%;
  padding: var(--bf-form-control-padding);
  border: var(--bf-form-border);
  border-radius: var(--bf-form-radius);
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.4;
}

.bf-form__control:focus-visible {
  outline: 2px solid var(--bf-form-accent);
  outline-offset: 1px;
}

textarea.bf-form__control {
  resize: vertical;
  min-height: 6.5rem;
}

.bf-form__help {
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: var(--bf-form-muted-opacity);
}

.bf-form__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding-top: 0.15rem;
}

.bf-form__choice,
.bf-form__consent {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  line-height: 1.45;
  cursor: pointer;
}

.bf-form__choice input,
.bf-form__consent input {
  margin-top: 0.2rem;
  accent-color: var(--bf-form-accent);
  flex: 0 0 auto;
}

.bf-form__submit {
  margin-top: 1.5rem;
  padding: 0.7rem 1.6rem;
  border: var(--bf-form-border);
  border-radius: var(--bf-form-radius);
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.bf-form__submit:hover {
  opacity: 0.85;
}

/* Inline layout: labels sit beside their control, for a short form dropped into
   a narrow column. */
.bf-form--inline .bf-form__fields {
  gap: 0.75rem;
}

.bf-form--inline .bf-form__field {
  flex: 1 1 12rem;
}

.bf-form--inline .bf-form__submit {
  margin-top: 0;
}

/* Set by the block's own script after a redirect back from the submit. Colour
   is kept to the border and a tint so the message reads on a light or a dark
   page without the block deciding what those look like. */
.bf-form__message.is-success {
  border-color: #16a34a;
  background: color-mix(in srgb, #16a34a 12%, transparent);
}

.bf-form__message.is-error {
  border-color: #dc2626;
  background: color-mix(in srgb, #dc2626 12%, transparent);
}

/* Label beside the control. Below the breakpoint it falls back to a stacked
   label: at 360px an inline label leaves the input too narrow to read what has
   been typed into it. */
@media (min-width: 40rem) {
  .bf-form__field.is-inline {
    display: grid;
    /* The label takes a share of the field rather than a fixed width: a fixed
       column that looks right across a full row leaves a half-width field with
       an input too narrow to read what was typed into it. */
    grid-template-columns: minmax(4rem, 32%) minmax(0, 1fr);
    align-items: baseline;
    column-gap: 0.9rem;
    row-gap: 0.25rem;
  }

  /* Placed explicitly rather than left to auto-flow: the label and its control
     belong on the same line, and auto-placement pushed the control onto a row
     of its own as soon as the field carried anything else (a help line). */
  .bf-form__field.is-inline > .bf-form__label {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }

  .bf-form__field.is-inline > .bf-form__control,
  .bf-form__field.is-inline > .bf-form__choices,
  .bf-form__field.is-inline > .bf-form__consent {
    grid-column: 2;
    grid-row: 1;
  }

  .bf-form__field.is-inline > .bf-form__help {
    grid-column: 2;
    grid-row: 2;
  }
}

/* A half-width field only has room for an inline label once the row itself is
   wide, so below that it goes back to a label above the control. */
@media (max-width: 64rem) {
  .bf-form__field.is-half.is-inline {
    display: flex;
  }
}

/* A spam trap holds no answer and takes no space in the layout. It is moved
   off-screen rather than hidden with display:none, because a bot that reads the
   stylesheet skips anything it can tell is invisible; the input itself carries
   autocomplete=off so a browser never fills it in for a real visitor. */
.bf-form__field--honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* A refused field says so where the answer is, not only in a box at the top of
   the form that scrolls out of view. */
.bf-form__error {
  font-size: 0.82rem;
  line-height: 1.4;
  color: #dc2626;
}

.bf-form__field.has-error .bf-form__control {
  border-color: #dc2626;
}

.bf-form__field.has-error .bf-form__label {
  color: #dc2626;
}

/* While the submission is in flight the button says so rather than looking
   ready for another press. */
.bf-form__submit.is-sending,
.bf-form__submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Mỗi bước là một fieldset — chọn thẻ này vì nó nhóm các control lại với nhau
   cho trình đọc màn hình, nhưng viền và padding mặc định của nó thì phải gỡ. */
.bf-form__step {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bf-form__steps-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
}

.bf-form__step-count {
  font-size: 0.85rem;
  opacity: 0.75;
}

/* Nút lùi đứng trước, nút tiến đứng cuối, kể cả khi một trong hai bị ẩn. */
.bf-form__step-back { margin-right: auto; }
.bf-form__step-next { margin-left: auto; }

/* Số tiền phải trả là thứ người điền cần thấy rõ nhất trên form thu tiền. */
.bf-form__price {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Trang thanh toán: số tiền là thứ phải đọc được ngay, phần còn lại là hướng
   dẫn để làm theo. */
.bf-pay { display: grid; gap: 1rem; }
.bf-pay__amount { font-size: 1.8rem; font-weight: 700; }
.bf-pay__label { margin: 0 0 .4rem; font-weight: 600; }
.bf-pay__method-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.bf-pay__method {
  padding: .6rem 1rem;
  border: 1px solid currentColor;
  border-radius: .5rem;
  background: transparent;
  cursor: pointer;
}
.bf-pay__go { display: inline-block; padding: .7rem 1.2rem; border-radius: .5rem; background: currentColor; }
.bf-pay__qr { display: block; width: 260px; max-width: 100%; margin-bottom: .8rem; }
.bf-pay__details { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.bf-pay__details dt { opacity: .7; }
.bf-pay__details dd { margin: 0; font-weight: 600; }
.bf-pay__state { opacity: .8; }
