/* ---------- Cats: list rows (cats/_cat), thumbnails, the history timeline ---------- */

.cat-list {
  padding: 0;
  list-style: none;
}

.cat-row + .cat-row {
  border-top: var(--border);
}

/* A row with its own button beside the link (an adopter's page) */
.cat-row--with-action {
  display: flex;
  align-items: center;
}

.cat-row--with-action .cat-row__link { flex: 1; min-width: 0; }

.cat-row__action {
  flex-shrink: 0;
  padding-right: var(--space-4);
}

.cat-row__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: inherit;
  text-decoration: none;

  &:hover {
    background: var(--color-surface-hover);
  }
}

.cat-row__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.cat-row__name {
  font-weight: var(--weight-medium);
}

.cat-row__meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-row__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
}

.cat-thumb {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.cat-thumb--empty {
  display: grid;
  place-items: center;
  background: var(--color-primary-subtle);
  color: var(--color-primary-text);

  svg {
    width: 55%;
  }
}

.cat-thumb--lg {
  width: 4.5rem;
  height: 4.5rem;
}

.cat-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* The cat's history: newest first, a line down the left */
.timeline {
  padding: var(--space-2) var(--space-4);
  list-style: none;
}

.timeline__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-3) var(--space-4);
  border-left: 2px solid var(--color-border);
  position: relative;

  &::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 1.15rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
  }
}

.timeline__body {
  flex: 1;
  min-width: 0;
}

.event-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.event-form__title {
  font-size: var(--text-md);
}

/* What was done in a treatment: the place's procedures, each ticked with its cost on the right, the total below
   (treatments_controller.js). A box that scrolls when the list is long, like .check-list */
fieldset.treatment-list {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);

  legend {
    padding: 0 var(--space-1);
  }
}

.treatment-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.25rem;
  padding: var(--space-1) 0;

  &:not(:last-of-type) {
    border-bottom: 1px solid var(--color-border);
  }
}

.treatment-choice__name {
  display: flex;
  flex: 1 1 12rem;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.treatment-choice__other {
  flex: 1 1 12rem;
}

/* Only a ticked row shows its cost (and, for "Otra", the name to type): an unticked row is one line, also on phones */
.treatment-choice__cost {
  flex: 0 0 8rem;
}

.treatment-choice:not(.treatment-choice--picked) :is(.treatment-choice__cost, .treatment-choice__other) {
  display: none;
}

.treatment-list__total {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.filters__select {
  flex: 0 1 14rem;

  /* On a phone they fill what they have: half the row when two fit, else all of it */
  @media (max-width: 48rem) {
    flex-grow: 1;
  }
}

@media (max-width: 40rem) {
  .cat-row__badges {
    display: none;
  }
}

/* A note in a cat's history: an outlined dot and the text in a soft box, so observations stand
   apart from things that were done (vaccines, treatments…) */
.timeline__item--note::before {
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
}

.timeline__note {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  font-size: var(--text-sm);

  p + p {
    margin-top: var(--space-1);
  }
}

/* A history entry's cost and its files (invoice, adoption document) */
.event-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);

  a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
  }

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

/* "Ver todo el historial (12)" above a history showing only its last entries (shared/_history_toggle) */
.history-toggle {
  padding: var(--space-3) var(--space-4) 0;
  font-size: var(--text-sm);
}

/* The adoption contract's card: how many in the registry of adopters the cat fits */
.adoption-fits {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.adoption-fits svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--color-primary-text);
}

/* A cat's posts on Instagram or Facebook: on its page (cats/_social_posts) and, as cards, on its public one */
.social-post-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.social-post-link__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-post-link__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  color: #fff;

  svg {
    width: 1.15rem;
    height: 1.15rem;
  }
}

/* The brands' own colours, white on them in light and dark */
.social-post-link__icon--instagram { background: linear-gradient(45deg, #f09433, #dc2743 50%, #bc1888); }
.social-post-link__icon--facebook { background: #1877f2; }

.social-post-form {
  display: flex;
  gap: var(--space-2);

  .input { flex: 1; min-width: 0; }
}

.public-social-posts {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.public-social-post {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: inherit;
  text-decoration: none;
}

.public-social-post:hover { text-decoration: none; border-color: var(--color-border-strong); }

.public-social-post__title {
  display: block;
  font-weight: var(--weight-medium);
}

.public-social-post__hint {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* A new cat from an aviso (cats/_form): the aviso's photos to copy, each ticked in its corner; an unticked one fades */
.report-photo-picks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 0;
  list-style: none;
}

.report-photo-pick {
  position: relative;
  display: block;
  cursor: pointer;
}

.report-photo-pick__image {
  width: 6rem;
  height: 6rem;
  object-fit: cover;
  border: var(--border);
  border-radius: var(--radius-md);
  transition: opacity var(--duration-fast) var(--ease-out);
}

.report-photo-pick__box {
  position: absolute;
  top: var(--space-1);
  left: var(--space-1);
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--color-primary);

  &:not(:checked) + .report-photo-pick__image {
    opacity: 0.4;
  }
}
