/* =============================================================================
   css/screens/day.css
   Where things go inside the Open Day, Close Day and Reopen dialogs
   (js/ui/day-dialogs.js). The day button in the header and the "Yesterday
   is still open" banner are part of the shell, in app.css.

   Positioning only. The figure box, the summary list, the difference
   colours, the hold button and the number pad are all components in
   components.css; this file arranges them. Every value is a token
   (docs/05-ux-spec.md section 8, CLAUDE.md rule 9).
   ============================================================================= */


/* -----------------------------------------------------------------------------
   THE DIALOGS
   Open Day: the figure on the left, the pad on the right.
   Close Day: the summary on the left, the count, difference and pad on the
   right. Both end with a row of two buttons and a line of status.
   ----------------------------------------------------------------------------- */

/* A figure and a number pad side by side need more room than a question.
   Close Day adds the summary column and uses .dialog--wide as well. */
.day-dialog {
  width: min(760px, calc(100vw - var(--space-6)));
}

.day-dialog.dialog--wide {
  width: min(1040px, calc(100vw - var(--space-6)));
}

.day-dialog .dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
}

/* "Fri 19 Sept · Santha" under the title. */
.day-dialog__when {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--color-text-muted);
}

/* Why the dialog appeared (DAY-01) or what to do about a stale day (DAY-06). */
.day-dialog__reason {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary-faint);
  border-radius: var(--radius-sm);
}

/* The same line when it is a warning: today was already closed, so the
   thing to do is Reopen, not open (DAY-05). */
.day-dialog__reason.is-danger {
  color: var(--color-danger);
  background: var(--color-danger-faint);
}

.day-dialog__columns {
  display: grid;
  /* minmax(0, 1fr) lets the figure column shrink below the width of its
     widest number, so a big float never pushes the pad out of the box. */
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
}

.day-dialog__figure,
.day-dialog__count {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.day-dialog__hint {
  margin: 0;
}

.day-dialog__reopen {
  margin: auto 0 0;
}

/* Close Day: the list of figures scrolls if it is taller than the pad
   column beside it, so the pad and the hold button never move. The
   expected cash total sits under the list, outside the scroll, so it is on
   screen whatever the list is doing. The height matches the right hand
   column: the figure box plus the compact pad. */
.day-dialog__figures {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.day-dialog__summary {
  max-height: 340px;
  overflow-y: auto;
  padding-right: var(--space-2);
}

.day-dialog__pad {
  justify-self: end;
}

/* Two buttons: Not now on the left, the hold button on the right taking the
   room, because holding is the thing this dialog exists for. Rule 2.6's
   "safe option larger" is for destructive choices; here the safe choice is
   to do nothing, and a bigger target for the deliberate two second press is
   what keeps a thumb on it. */
.day-dialog__actions {
  display: flex;
  gap: var(--space-3);
}

.day-dialog__actions > :first-child {
  flex: 1 1 0;
}

.day-dialog__actions > :last-child {
  flex: 2 1 0;
  min-height: var(--tap-primary);
  white-space: nowrap;
}

/* What is happening, or what went wrong, under the buttons. */
.day-dialog__status {
  margin: 0;
  text-align: center;
  color: var(--color-text-muted);
}

.day-dialog__status.is-danger {
  color: var(--color-danger);
}

/* Reopen: the recent closed days as a row of chips. */
/* The closed days to choose from: one .unit-option per day, the same list
   the Sell screen uses for selling units. */
.day-dialog__days {
  margin-top: calc(-1 * var(--space-2));
}

/* On a phone the columns stack, figures first, pad under them. */
@media (max-width: 480px) {
  .day-dialog__columns {
    grid-template-columns: 1fr;
  }

  .day-dialog__pad {
    justify-self: center;
  }

  .day-dialog__summary {
    max-height: none;
  }

  /* The hold button on top at full width, Not now under it. */
  .day-dialog__actions {
    flex-direction: column-reverse;
  }
}

