/* Gift voucher list and field on the cart drawer, the cart page and the checkout (SHOP-RULES 9.3): the applied vouchers with
   what they pay and what is left, then the saved ones with their balance. Hand-written, native nesting only.
   All text >= 14px, contrast >= 4.5:1 with the storefront tokens. */

@layer components {
  .voucher-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .voucher-panel__applied,
  .voucher-panel__saved {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .voucher-panel__voucher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
  }

  .voucher-panel__row {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .voucher-panel__heading {
    margin: 0;
    font-size: var(--text-md);
    font-weight: 600;
  }

  .voucher-panel__remove-form,
  .voucher-panel__use-form {
    margin: 0;
  }

  .voucher-panel__remove,
  .voucher-panel__use,
  .voucher-panel__submit {
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-4);
    font: inherit;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;

    &:hover:not(:disabled) {
      border-color: var(--color-primary);
    }

    &:disabled {
      cursor: progress;
      opacity: 0.6;
    }
  }

  .voucher-panel__form {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .voucher-panel__label {
    font-weight: 500;
  }

  .voucher-panel__field {
    display: flex;
    gap: var(--space-2);
  }

  .voucher-panel__input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.75rem;
    text-transform: uppercase;

    &[aria-invalid="true"] {
      border-color: var(--color-error-text);
    }
  }

  .voucher-panel__error {
    margin: 0;
    color: var(--color-error-text);
  }
}

/* Noria look: the code field is an underline, the button beside it a thin outlined pill. */
@layer components {
  .voucher-panel__label {
    font-size: var(--noria-text-form-label);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .voucher-panel__submit {
    min-height: 2.75rem;
    padding: 0.5rem 1.25rem;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--noria-brown);
    background: var(--noria-gold);
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;

    &:hover { color: var(--noria-brown); background: #c29b6c; }
    &:disabled { color: var(--noria-ink-muted); background: var(--noria-sand-deep); cursor: not-allowed; }
  }
}
