/* ==========================================================================
   Firm Pill — sharp, scannable firm card used in the firm directory list.
   Layout: colored status spine + header (name / status) + a three-column
   grid of facts and contact rows.
   ========================================================================== */
.firm-pill {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-base), box-shadow var(--transition-base),
    transform var(--transition-fast);
}

.firm-pill:hover {
  transform: translateY(-2px);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}

/* A firm needing a service plan renewal, tinted to match an overdue complaint's
   row (see .table-row--warning). The pill already carries a status spine on its
   left edge, so the flag is the tint plus the border rather than a second bar. */
.firm-pill--warning {
  background-color: rgba(245, 158, 11, 0.07);
  border-color: var(--color-warning);
}

.firm-pill--warning:hover {
  background-color: rgba(245, 158, 11, 0.13);
  border-color: var(--color-warning);
}

.firm-pill:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--color-primary-green);
}

/* == status spine == */
.firm-pill__spine {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--color-border-strong);
}

.firm-pill__spine--green {
  background-color: var(--color-primary-green);
}

.firm-pill__spine--red {
  background-color: var(--color-danger);
}

.firm-pill__body {
  padding: var(--space-5) var(--space-6) var(--space-5) calc(var(--space-6) + 4px);
}

/* == header == */
.firm-pill__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.firm-pill__name {
  margin: 0;
  font-size: var(--font-size-xlarge);
  font-family: var(--font-family-bold);
  font-weight: 600;
  color: var(--color-primary-dark);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* == status pill (solid tinted chip, no dot — matches directory design) == */
.firm-pill__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-medium);
  font-family: var(--font-family-bold);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.firm-pill__status--green {
  background-color: rgba(93, 207, 162, 0.32);
  color: var(--color-primary-dark);
}

.firm-pill__status--red {
  background-color: rgba(245, 69, 92, 0.26);
  color: var(--color-primary-dark);
}

.firm-pill__status--gray {
  background-color: #e6e9ee;
  color: var(--color-secondary-dark);
}

/* == three-column body grid == */
.firm-pill__grid {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr 1fr;
  gap: var(--space-5) var(--space-6);
  align-items: start;
}

/* == facts (Authorisation / FCA Number) == */
.firm-pill__facts {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
}

.firm-pill__fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.firm-pill__label {
  font-size: var(--font-size-small);
  font-family: var(--font-family-bold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  color: var(--color-text-muted);
}

.firm-pill__value {
  margin: 0;
  font-size: var(--font-size-medium);
  font-family: var(--font-family-bold);
  font-weight: 600;
  color: var(--color-primary-dark);
  overflow-wrap: anywhere;
}

/* == contact rows == */
.firm-pill__contacts {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.firm-pill__contact {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.firm-pill__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background-color: var(--tint-navy-06);
  color: var(--color-primary-dark);
  transition: background-color var(--transition-base), color var(--transition-base);
}

.firm-pill:hover .firm-pill__icon {
  background-color: var(--tint-green-16);
  color: var(--color-primary-dark);
}

.firm-pill__icon-svg {
  width: 16px;
  height: 16px;
}

.firm-pill__contact-text {
  min-width: 0;
  font-size: var(--font-size-medium);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.firm-pill__contact-text--link {
  color: var(--color-primary-green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* == responsive == */
@media (max-width: 992px) {
  .firm-pill__grid {
    grid-template-columns: 1fr 1fr;
  }

  .firm-pill__facts {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-5);
  }
}

@media (max-width: 640px) {
  .firm-pill__grid {
    grid-template-columns: 1fr;
  }
}

/* == the row a pill sits in ==
   The card itself is one big link, so the select box and the row's own action
   cannot live inside it — a checkbox nested in an anchor is a click on the
   anchor. They are laid over the card's own padding instead, which keeps the
   card full width and reading as one thing rather than as a middle column with
   controls bolted either side. See firms/index/_index_list. */
.firm-row {
  position: relative;
  transition: transform var(--transition-fast);
}

/* Room in the card for the two of them. */
.firm-row .firm-pill__body {
  padding-left: calc(var(--space-6) + 30px);
  padding-right: calc(var(--space-6) + 28px);
}

.firm-row--deleted .firm-pill__body {
  padding-right: calc(var(--space-6) + 190px);
}

/* The hover state moves up to the row, so the box and the button ride with the
   card instead of the card sliding out from under them — and so it holds while
   the pointer is over either of those rather than over the link. */
.firm-row:hover {
  transform: translateY(-2px);
}

.firm-row:hover .firm-pill {
  transform: none;
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}

.firm-row__select {
  position: absolute;
  top: 50%;
  left: calc(var(--space-5) + 4px);
  transform: translateY(-50%);
}

.firm-row__actions {
  position: absolute;
  top: 50%;
  right: var(--space-5);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Deleting a firm is the heaviest thing this page can do and the least often
   wanted, so the button is quiet rather than hidden — it goes red under the
   pointer and picks up when the row does. Quiet rather than hidden because a
   control revealed on hover is one a keyboard, a touchscreen and a screen
   reader all have to work around; the earlier version faded to opacity 0, which
   even Selenium reports as not displayed. */
.firm-row__delete {
  color: var(--color-text-faint);
  transition: color var(--transition-base), background-color var(--transition-base);
}

.firm-row:hover .firm-row__delete {
  color: var(--color-danger);
}

.firm-row__delete:hover,
.firm-row__delete:focus-visible {
  color: var(--color-danger);
  background-color: var(--tint-danger-10);
}

.firm-row__deleted {
  margin: 0;
  text-align: right;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  line-height: 1.4;
  white-space: nowrap;
}

.firm-row__deleted-until {
  color: var(--color-text-faint);
}

/* The directory scrolls inside itself, so the bulk bar and its tabs have to keep
   their own height while the list takes the rest. */
.firm-directory-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
