/* Shared add/edit dialog pattern — used by the Calendar event dialog and
   the Task dialog. A native <dialog> element rather than a hand-rolled
   modal: free focus-trapping, Escape-to-close, and a ::backdrop, with no
   JS overlay/backdrop management to get wrong. */

.event-dialog {
  border: none;
  border-radius: calc(var(--radius) * 1.5);
  padding: 0;
  max-width: 420px;
  width: 90vw;
  /* A native <dialog> has no built-in max-height/scroll — on a short
     phone screen, form content taller than the viewport would otherwise
     get clipped with no way to reach the rest of it. */
  max-height: 85vh;
}

.event-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

.event-form {
  padding: calc(var(--spacing-unit) * 3);
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing-unit) * 2);
  max-height: 85vh;
  overflow-y: auto;
}

.event-form h2 {
  margin: 0;
  font-size: 1.2rem;
}

.event-form__field select {
  width: 100%;
  min-height: var(--touch-target-min);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0 calc(var(--spacing-unit) * 1.5);
  font-size: inherit;
  font-family: inherit;
  background-color: var(--color-surface);
  color: var(--color-text);
}

.event-form__field--checkbox {
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-unit));
}

.event-form__field--checkbox input {
  width: 22px;
  height: 22px;
}

.event-form__field--checkbox label {
  margin: 0;
}

.event-form__row {
  display: flex;
  gap: calc(var(--spacing-unit) * 1.5);
}

.event-form__row .event-form__field {
  flex: 1;
  /* A date or time input carries a large intrinsic minimum width — it has
     to fit "yyyy-mm-dd" or "--:-- --" — and a flex item's automatic minimum
     is its content, so without this the pair refuses to shrink to half the
     row each, overflows, and the two fields visibly overlap on a phone. */
  min-width: 0;
}

/* The control itself, not just its wrapper. Safari gives date and time
   inputs a minimum width of their rendered value ("Sep 24, 2026") and lets
   them overflow the box they're in rather than shrink — which is how the
   two ended up drawn on top of each other. This keeps the side-by-side case
   safe at the widths that keep it, such as an iPad in portrait. */
.event-form__row .event-form__field input,
.event-form__row .event-form__field select {
  min-width: 0;
}

/* Even at their correct half-width, two date/time controls side by side are
   cramped on a phone, so a paired row stacks instead. Above this width —
   including the kiosk, which is wider — they stay side by side and the
   dialog stays short enough to use with the on-screen keyboard up. */
@media (max-width: 720px) {
  .event-form__row {
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
  }
}

.event-form__actions {
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-unit));
  margin-top: calc(var(--spacing-unit));
}

.event-form__actions-spacer {
  flex: 1;
}
