@layer components {
  /* -----------------------------------------------------------------
   * Sections on the select-items page (Available / Already returned /
   * Not eligible). Each has a small uppercase-ish heading with an
   * underline, an optional caption, and a list of item cards.
   * ----------------------------------------------------------------- */
  .item-section + .item-section {
    margin-top: var(--spacing-2xl);
  }

  .item-section__title {
    font-size: var(--text-normal);
    color: var(--color-text);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0;
    display: block;
    width: 100%;
  }

  .item-section__caption {
    color: var(--color-text-muted);
    font-size: var(--text-small);
    margin: 0 0 var(--spacing-md) 0;
  }

  .item-section__inline-link {
    color: var(--color-text);
    text-decoration: underline;
  }

  .item-section__list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  /* -----------------------------------------------------------------
   * Individual item card. Used in all three sections; the
   * `.item-card--ineligible` modifier dims the background for the
   * "Already returned" and "Not eligible for return" groups.
   * ----------------------------------------------------------------- */
  .item-card {
    background-color: white;
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: border-color 0.15s ease;
  }

  .item-card:has(.item-card__checkbox:checked) {
    border-color: var(--color-text);
  }

  .item-card--ineligible {
    background-color: var(--color-gray-50);
  }

  .item-card__main {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    cursor: pointer;
    font-weight: normal;
    margin: 0;
  }

  .item-card--ineligible .item-card__main {
    cursor: default;
  }

  .item-card__image {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
  }

  .item-card__image--placeholder {
    background-color: var(--color-gray-100);
  }

  .item-card__details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }

  .item-card__title {
    color: var(--color-text);
    font-size: var(--text-small);
    font-weight: 600;
  }

  .item-card__variant {
    color: var(--color-text-muted);
    font-size: var(--text-x-small);
  }

  .item-card__price {
    color: var(--color-text-muted);
    font-size: var(--text-x-small);
  }

  /* Filled-square checkbox matching the mockup. The native input is
   * restyled in place using `appearance: none` and a CSS-drawn
   * checkmark so the card retains a single, robust hit target. */
  .item-card__checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    border: 1.5px solid var(--color-gray-300);
    border-radius: var(--radius-sm);
    background-color: white;
    position: relative;
    transition:
      background-color 0.12s ease,
      border-color 0.12s ease;
    align-self: flex-start;
    margin-top: 2px;
  }

  .item-card__checkbox:hover {
    border-color: var(--color-gray-500);
  }

  .item-card__checkbox:checked {
    background-color: var(--color-text);
    border-color: var(--color-text);
  }

  .item-card__checkbox:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }

  .item-card__checkbox:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }

  /* "View return status →" footer inside an Already-returned card. */
  .item-card__footer {
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-md);
  }

  .item-card__status-link {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9375rem;
  }

  .item-card__status-link:hover {
    text-decoration: underline;
  }

  /* -----------------------------------------------------------------
   * Reason / sub-reason / customer-comment fields that reveal inside
   * the card when its checkbox is ticked. Sits flush within the card
   * body (no nested visual container, per the mockup).
   * ----------------------------------------------------------------- */
  .item-reasons-container {
    padding: var(--spacing-md);
    opacity: 0;
    transform: translateY(-6px);
    transition:
      opacity 0.2s ease,
      transform 0.2s ease;
  }

  .item-reasons-container.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .item-reasons-container.hidden {
    display: none;
  }

  .reason-field + .reason-field {
    margin-top: var(--spacing-md);
  }

  .reason-field.hidden {
    display: none;
  }

  .reason-field__label {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-xs);
  }

  .reason-field__select,
  .reason-field__textarea {
    width: 100%;
    padding: var(--spacing-sm);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    background-color: white;
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;
    font-family: inherit;
  }

  .reason-field__textarea {
    resize: vertical;
    min-height: 6rem;
  }

  .reason-field__textarea::placeholder {
    color: var(--color-gray-400);
  }

  .reason-field__select:focus,
  .reason-field__textarea:focus {
    outline: none;
    border-color: var(--color-text);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
  }

  .select-items-form__footer {
    margin-top: var(--spacing-2xl);
  }
}
