/* ─── Toasts ─────────────────────────────────────────────────────────────────
   Every message the app used to show as a full-width flash bar or a browser
   alert() floats here instead: a white Mono card, top-right, at --z-toast so
   nothing covers it. Colour comes only from the semantic trio in the icon tile
   and the timer line, so the card itself stays quiet.

   The server renders the flash straight into .toast-region, so the message is
   there without JS; app.js adds the dismiss timer, and SendInvoiceUI.toast()
   adds new ones to the same region. Info toasts leave on their own; errors stay
   until closed, because an error that disappears is an error nobody read. */
.toast-region {
  position: fixed;
  /* Under the top bar, not over its search and account buttons. */
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  --toast-tone: var(--accent);
  --toast-tone-weak: var(--accent-weak);
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 12px 12px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-pop), 0 1px 2px rgba(10, 10, 10, 0.04);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease) both;
}

.toast-error { --toast-tone: var(--red); --toast-tone-weak: var(--red-weak); }
.toast-warning { --toast-tone: var(--amber); --toast-tone-weak: var(--amber-weak); }

.toast.is-leaving { animation: toast-out var(--dur-slow) var(--ease) both; }

/* The glyph is a mask so its colour is the tone token and one stylesheet rule
   serves the server's toast and the script's alike - no SVG copied into both. */
.toast-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--toast-tone-weak);
}

.toast-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--toast-tone);
  -webkit-mask: var(--toast-glyph) center / contain no-repeat;
  mask: var(--toast-glyph) center / contain no-repeat;
}

.toast-info { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.toast-error { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7M12 17.5v.01'/%3E%3C/svg%3E"); }
.toast-warning { --toast-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7M12 17.5v.01'/%3E%3C/svg%3E"); }

.toast-message {
  flex: 1;
  min-width: 0;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.toast-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0 -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.toast-close:hover { color: var(--text); background: var(--hover); }
.toast-close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }

/* How long an info toast has left. Hovering or focusing the toast pauses it,
   so a merchant reading a longer message doesn't lose it mid-sentence. */
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--toast-tone);
  opacity: 0.55;
  transform-origin: left;
  animation: toast-timer var(--toast-duration, 5s) linear forwards;
}

.toast:hover .toast-timer,
.toast:focus-within .toast-timer { animation-play-state: paused; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(12px); }
}

@keyframes toast-timer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Phones: full width, below the sticky 56px top bar rather than over it. */
@media (max-width: 1023px) {
  .toast-region { top: 68px; right: 16px; left: 16px; width: auto; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation-duration: 0.001ms; }
}

/* ─── Confirm dialog ─────────────────────────────────────────────────────────
   Replaces the browser's confirm() for destructive actions. A native <dialog>
   like the export dialog, so focus trapping, Escape and the top layer come from
   the browser. Forms opt in with data-confirm; see bootConfirmations(). */
.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.confirm-dialog[open] { animation: toast-in var(--dur-slow) var(--ease) both; }
.confirm-dialog::backdrop { background: rgba(8, 22, 18, .45); }

.confirm-dialog-body {
  display: flex;
  gap: 14px;
  padding: 20px 20px 16px;
}

.confirm-dialog-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-weak);
  color: var(--red);
}

.confirm-dialog-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.confirm-dialog-message { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-subtle);
}

@media (max-width: 480px) {
  .confirm-dialog-actions > * { flex: 1; }
}

