/* Manage dialogs (gear/event_templates/_dialog, gear/rules/_dialog, gear/tags/_dialog) */
/* ----------------------------------------------------------------------------------- */
/*
  A .calendar-sheet like the Templates dialog: a bottom sheet on a phone, a centred
  dialog wider up. Their screens (application/_manage_sheet) pin their header and scroll
  their body under it - the frame and the screen are flex columns down to the body, which
  is the one thing that scrolls. A list is narrower than an editor that holds a table or
  the rule form's category grid (.manage-sheet__frame--wide).
*/
dialog.pg-modal.manage-sheet .modal-content > turbo-frame {
  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* An editor's Cancel/Save footer is the event dialog's, less its quarter-rem bleed past
   the body's sides and bottom: the frame above clips anything outside it, which cut the
   buttons off. The body's own quarter-rem side padding keeps them in line without it. */
dialog.pg-modal.manage-sheet .modal-footer.calendar-form__footer {
  margin: 0;
}

.manage-sheet__frame {
  flex: 1 1 auto;

  display: flex;
  flex-direction: column;
  min-height: 0;
}

dialog.pg-modal .modal-body.manage-sheet__body {
  flex: 1 1 auto;
  min-height: 0;

  /* Room under the last thing on a screen, so it doesn't sit on the footer's rule */
  padding: 0.75rem 0.25rem 1rem;

  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (width >=768px) {
  dialog.pg-modal.manage-sheet {
    width: 40rem;
  }

  dialog.pg-modal.manage-sheet:has(.manage-sheet__frame--wide) {
    width: 72rem;
  }
}

/* A list: the Templates dialog's rows (calendar-templates.css), with details and facts
   under each one's name */
.manage-list {
  display: flex;
  flex-direction: column;
  row-gap: 0.375rem;

  margin: 0;
}

.manage-list__row {
  display: flex;
  align-items: center;
  column-gap: 0.125rem;

  padding-right: 0.25rem;

  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-sm);
  background-color: var(--bs-body-bg);
}

.manage-list__main {
  flex: 1 1 auto;

  display: flex;
  flex-direction: column;
  row-gap: 0.125rem;
  min-width: 0;

  padding: 0.5rem 0.625rem;

  color: inherit;
  text-decoration: none;

  &:focus-visible {
    background-color: var(--bs-tertiary-bg);
  }
}

/* Edit and delete as the Templates dialog draws them (calendar-templates.css): borderless,
   with a tinted ground under the icon on hover */
.manage-list__row .calendar-form__tool {
  background: none;
  border: none;
}

.manage-list__row .calendar-form__tool:not(:disabled):hover {
  background-color: var(--bs-tertiary-bg);
}

.manage-list__row .calendar-form__tool--danger:not(:disabled):hover {
  background-color: rgba(var(--bs-danger-rgb), 0.12);
}

.manage-list__name {
  font-weight: 700;
}

/* A template's name, behind the disc of its colour */
.manage-list__name--with-colour {
  display: flex;
  align-items: center;
  column-gap: 0.5rem;
}

/* A form laid out like the event dialog's (calendar-form__body): the Templates dialog's
   title/colour/location/ruleset fields */
.manage-sheet__form {
  display: flex;
  flex-direction: column;
  row-gap: 0.875rem;
}

/* A location's suggestions, or the colour palette, hang below their field without
   adding to the body's height - on a short form the body's scroll clip cut them off
   flat at its bottom edge. Let them spill past it while one is open, as the event
   dialog does (calendar-form.css). */
dialog.pg-modal .modal-body.manage-sheet__body:has(.manage-sheet__form .pg-menu--open) {
  overflow: visible;
}

.manage-list__detail {
  color: var(--bs-secondary-color);

  font-size: 0.8125rem;
}

.manage-list__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.375rem;

  margin-top: 0.25rem;
}

.manage-list__count {
  color: var(--bs-secondary-color);

  font-size: 0.75rem;
  font-weight: 600;
}

.manage-list__empty {
  margin: 0.5rem 0 0;

  font-size: 0.8125rem;
}
