/* users#index: initials + name + email in one cell */
.user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-cell__name {
  font-weight: var(--weight-medium);
}

.push-actions { justify-content: flex-start; }

/* /users/:id/permissions: a card per group of permissions, two side by side on a computer, one on phones */
.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 64rem) {
  .permission-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The group's fieldset fills its card; its legend is the card's header (a legend only spans the card when floated) */
.permission-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;

  > legend {
    float: left;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: var(--space-4) var(--space-5);

    + * {
      clear: both;
    }
  }

  .form-hint {
    display: block;
  }
}

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

/* A long form's buttons, kept in reach at the foot of the window on a computer. On phones it stays at the end of the
   form: the menu's round button sits in that corner */
.save-bar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

@media (min-width: 48rem) {
  .save-bar {
    position: sticky;
    bottom: var(--space-4);
    z-index: var(--z-sticky);
  }
}

/* A user's page: what they can do, a group per line */
.permission-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;

  dt {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  dd {
    margin: var(--space-1) 0 0;
  }

  ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
  }

  /* Level with the first line */
  svg {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin-top: 0.125rem;
    color: var(--color-success);
  }
}

/* The profile's notifications: a row per kind, a switch per channel, the switches centred under their heading */
.notification-table {
  /* Each kind labels its row: a plain cell, not a column heading (no caps or tint, and it wraps) */
  tbody th[scope="row"] {
    padding: var(--space-3) var(--space-4);
    background: none;
    border-bottom: var(--border);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: var(--weight-regular);
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
  }

  tbody tr:last-child th[scope="row"] {
    border-bottom: 0;
  }

  .notification-table__channel {
    padding-inline: var(--space-2);
  }

  .notification-table__channel {
    width: 4.5rem;
    text-align: center;
  }

  .switch {
    justify-content: center;
  }
}

/* A clinic's prices: the procedure on the left, its price on the right */
.price-row {
  display: grid;
  grid-template-columns: 1fr 9rem;
  align-items: center;
  gap: var(--space-3);
}

/* The profile's picture: the current one beside the field to change it */
.avatar-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);

  /* The field beside the picture takes what's left, and shrinks on a phone */
  > .stack {
    flex: 1;
    min-width: 0;
  }

  .file-input {
    max-width: 100%;
  }
}

/* The picture is the button that changes it (a label for the hidden file field): a photo icon on hover,
   the focus ring when the field is reached with the keyboard. "Quitar la foto" under it */
.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.avatar-picker__button {
  position: relative;
  display: block;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.avatar-picker__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: rgb(15 23 42 / 0.45);
  color: var(--white);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);

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

.avatar-picker__button:hover .avatar-picker__overlay,
.avatar-picker:has(input:focus-visible) .avatar-picker__overlay {
  opacity: 1;
}

.avatar-picker:has(input:focus-visible) .avatar-picker__button {
  box-shadow: var(--focus-ring);
}

/* /profile: the install card across the page, then two columns (one on narrower screens) */
.profile-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

/* Hidden (already installed, or the browser can't): no gap left above the columns */
.profile-install > .install-card {
  margin-bottom: var(--space-4);
}

.profile-layout--single {
  grid-template-columns: minmax(0, 40rem);
}

@media (max-width: 64rem) {
  .profile-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
