/* ============================================
   EDIT MODALS
   Every edit screen except the user's own settings opens into the layout's
   #modal overlay rather than on a page of its own. They all sit on
   .task-form-card and reuse the header/body/footer above; what follows is only
   what those shared parts don't already cover.
   ============================================ */

/* The overlay frame is 520px, which suits a name-and-a-colour form. Forms that
   carry a second column of content — the section icon grid, a post's body, a
   category's full settings — tag their card .modal-wide and get room for it.
   Stated on the frame rather than the card because the frame is what actually
   constrains the width; the card only fills it. */
#modal:has(> .modal-wide),
#modal:has(> * > .modal-wide) {
  max-width: 760px;
}

/* A sidebar form's place held while it loads (loadFormIntoModal in application.js). */
.modal-form-loading { display: grid; place-items: center; min-height: 220px; color: var(--text-3); font-size: var(--fs-18); }

/* Visible counterpart to .task-form-label, which is deliberately screen-reader
   only. Fields whose purpose a placeholder can't carry — a colour swatch row,
   an icon grid, a group of checkboxes — need a caption that stays put, and
   three edit screens had each invented their own. */
.form-section-label {
  display: block;
  font-size: var(--fs-11);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 6px;
}

.form-section-hint {
  margin-top: 6px;
  font-size: var(--fs-11);
  color: var(--text-3);
}

/* Destructive action in a form footer, first in every edit form's footer. Sized to
   match .task-form-submit so the two ends of the footer line up; a red outline at
   rest so it reads as delete at a glance, filling on hover. Rendered as a link carrying
   data-turbo-method, never a button_to: the footer is inside the edit form and a
   nested <form> is invalid HTML. See shared/_modal_delete_button. */
.task-form-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--danger);
  font-size: var(--fs-14);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--dur-fast), background var(--dur-fast),
              color var(--dur-fast);
}

.task-form-danger:hover {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* A wider footer button that says what it does, for the screens where deleting
   is a real decision rather than a stray click (a journal entry, a post). */
.task-form-danger.is-labelled {
  width: auto;
  gap: 6px;
  padding: 8px 14px;
  font-size: var(--fs-13);
}

/* Secondary link in a footer — "View entry", "Open post" — the way out of the
   modal that isn't saving and isn't deleting. */
.task-form-footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-3);
  font-size: var(--fs-13);
  text-decoration: none;
  transition: color var(--dur-fast), background var(--dur-fast);
}

.task-form-footer-link:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
}

/* Error summary inside a modal body. Was five hand-rolled copies, one per form,
   two of them still in Bootstrap's light-theme red on a dark card. */
.task-form-errors {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #fca5a5;
  font-size: var(--fs-13);
}

.task-form-errors ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.form-swatch {
  cursor: pointer;
  line-height: 0;
}

.form-swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.form-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-icon-box {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: var(--fs-14);
  transition: border-color var(--dur-fast), color var(--dur-fast),
              background var(--dur-fast);
}

.form-swatch:hover .form-icon-box {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.1);
}

.form-swatch input[type="radio"]:checked + .form-icon-box {
  border-color: var(--field-optional-border);
  color: var(--field-optional-border);
  background: rgba(29, 161, 242, 0.12);
}

/* Two fields on one line — date beside time, name beside colour. Collapses on
   narrow screens, where 520px of overlay is already the whole viewport. */
.task-form-row {
  display: flex;
  gap: 10px;
}

.task-form-row > * {
  flex: 1;
  min-width: 0;
}

@media (max-width: 480px) {
  .task-form-row {
    flex-direction: column;
  }
}
