@layer components {
  .search-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
  }

  .search-bar {
    padding: 12px var(--content-padding);
    flex-shrink: 0;
  }

  .search-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);

    svg {
      color: var(--color-muted);
      flex-shrink: 0;
      width: 16px;
      height: 16px;
    }
  }

  .search-bar-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: var(--text-base);
    color: var(--color-text);
    outline: none;

    &::placeholder {
      color: var(--color-muted);
    }
  }

  .search-bar-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    color: var(--color-muted);
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Shared list item styles */
  .search-result-item,
  .search-recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px var(--content-padding);
    text-decoration: none;
    color: var(--color-text);

    &:active {
      background: var(--color-bg-secondary);
    }

    svg {
      width: 16px;
      height: 16px;
      color: var(--color-muted);
      flex-shrink: 0;
    }
  }

  /* Results */
  .search-results,
  .search-recent-content {
    padding-top: 0;
  }

  .search-section {
    margin-bottom: 1.5rem;
  }

  .search-section-list,
  .search-recent-list {
    display: flex;
    flex-direction: column;
  }

  .search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-caption);
    font-weight: var(--font-weight-semibold);
    color: white;
    flex-shrink: 0;
  }

  .search-result-content {
    flex: 1;
    min-width: 0;
  }

  .search-result-title {
    font-size: var(--text-base);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .search-result-subtitle {
    font-size: var(--text-caption);
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Empty state */
  .search-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-muted);

    svg {
      width: 48px;
      height: 48px;
      margin-bottom: 1rem;
    }

    h3 {
      font-size: var(--text-base);
      font-weight: var(--font-weight-semibold);
      color: var(--color-text);
      margin-bottom: 0.25rem;
    }

    p {
      font-size: var(--text-caption);
    }
  }

  /* Buscar opened from Pagamentos a receber: a way back to the list, and its filter as a chip in
     the field. */
  .search-header--filtered {
    justify-content: flex-start;
    gap: 4px;
  }

  .search-back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--back-tap-size);
    height: var(--back-tap-size);
    margin-left: calc(-1 * var(--back-ink-inset));
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-muted);
    cursor: pointer;

    svg {
      width: var(--back-icon-size);
      height: var(--back-icon-size);
    }
  }

  .search-filter {
    display: inline-flex;
    align-items: center;
    flex: none;
    padding-left: 10px;
    border-radius: var(--radius-pill);
    background: var(--color-brand-wash);
    color: var(--color-primary);
    font-size: var(--text-label);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
  }

  .search-filter-remove {
    display: flex;
    align-items: center;
    padding: 4px 8px 4px 4px;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;

    .search-bar-wrapper & svg {
      color: inherit;
      width: 14px;
      height: 14px;
    }
  }

  /* A filtered result: the Pagamentos a receber row, with Recebido beside it. The wrapper takes
     over the row's divider, since each row is now its wrapper's only child. */
  .search-receivable {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: var(--row-padding);
    border-top: 1px solid var(--color-border);

    &:first-child {
      border-top: none;
    }

    .agenda-schedule-item {
      flex: 1;
      min-width: 0;
      border-top: none;
      padding-bottom: 12px;
    }
  }

  .search-receivable-settle {
    flex: none;
    min-height: 48px;
    padding-inline: 14px;
  }

  /* The amount never gives way: the services shorten instead. */
  .search-receivable-services-line {
    display: flex;
    gap: 6px;
    min-width: 0;

    .agenda-schedule-item-services {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }
  }

  .search-receivable-amount {
    flex: none;
    color: var(--color-text);
    font-size: var(--text-caption);
    font-variant-numeric: tabular-nums;
  }

  .search-receivable-name-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;

    .agenda-schedule-item-name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }
  }

  .search-phone-match {
    flex: none;
    color: var(--color-muted);
    font-size: var(--text-caption);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;

    mark {
      background: var(--color-brand-wash);
      color: var(--color-text);
      border-radius: 3px;
    }
  }
}
