/* App notifications (js/notify.js): toasts via Toastify, dialogs via native <dialog>.
   Same look as the redesigned pages (css/loanview.css). Accent = tenant ThemeColor (--theme-color from head.php). */
:root {
  --ap-accent: var(--theme-color, var(--lg-accent, #1e6fd9)); /* app pages / login pages */
  --ap-ink: #1d2433;
  --ap-muted: #5b6576;
  --ap-line: #e3e7ee;
  --ap-surface: #ffffff;
  --ap-ok: #1f8a4c;
  --ap-fail: #c62828;
  --ap-warn: #9a5b00;
  --ap-shadow: 0 10px 30px rgba(16, 24, 40, 0.14);
  --ap-backdrop: rgba(16, 24, 40, 0.45);
}
[data-theme="dark"] {
  --ap-ink: #eef1f6;
  --ap-muted: #a3acba;
  --ap-line: rgba(255, 255, 255, 0.1);
  --ap-surface: #1c1f26;
  --ap-ok: #4cc27f;
  --ap-fail: #f0706b;
  --ap-warn: #e6a740;
  --ap-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --ap-backdrop: rgba(0, 0, 0, 0.6);
}

.ap-v--ok     { --v: var(--ap-ok); }
.ap-v--fail   { --v: var(--ap-fail); }
.ap-v--warn   { --v: var(--ap-warn); }
.ap-v--accent { --v: var(--ap-accent); }

/* Text colours below use two classes (.ap-toast .x, .ap-dlg .x): darkmode.css colours every
   div/p/h4/span with [data-theme="dark"] el { color: var(--text-primary) }, which beats one class,
   and many pages redefine --text-primary as near-black on :root, so text went black in dark mode. */
.ap-icon {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--v); background: color-mix(in srgb, var(--v) 14%, transparent); font-size: 1rem;
}
.ap-toast .ap-icon, .ap-dlg .ap-icon { color: var(--v); }
.ap-spin {
  display: block; width: 34px; height: 34px; border: 3px solid var(--ap-line); border-top-color: var(--ap-accent);
  border-radius: 50%; animation: ap-spin .8s linear infinite;
}
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* Buttons: same as .lv-btn */
.ap-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px; font-family: inherit;
  font-weight: 700; font-size: 0.9rem; border: 1px solid var(--ap-line); background: var(--ap-surface);
  color: var(--ap-ink); cursor: pointer; line-height: 1.2; margin: 0;
}
/* :focus rules beat style.css "button:focus { color: #252525 }" (the primary button is focused on open) */
.ap-btn:focus { color: var(--ap-ink); }
.ap-btn:hover { border-color: var(--ap-accent); color: var(--ap-accent); }
.ap-btn--primary, .ap-btn--primary:focus { background: var(--ap-accent); border-color: var(--ap-accent); color: #fff; }
.ap-btn--primary:hover { color: #fff; filter: brightness(1.06); }
.ap-btn:focus-visible { outline: 3px solid var(--ap-ink); outline-offset: 2px; }

/* ── Toasts ── */
.toastify.ap-toastify {
  background: var(--ap-surface) !important; color: var(--ap-ink); border: 1px solid var(--ap-line); border-left: 4px solid var(--v);
  border-radius: 12px; box-shadow: var(--ap-shadow); padding: 12px 14px; width: 340px; max-width: calc(100vw - 32px);
  display: flex; align-items: flex-start; gap: 8px; font-family: inherit; text-align: left;
}
.toastify.ap-toastify .toast-close { color: var(--ap-muted); opacity: 1; padding: 0 4px; margin-left: auto; font-size: 1.1rem; background: none; border: 0; }
.ap-toast { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.ap-toast__body { min-width: 0; }
.ap-toast .ap-toast__title { font-weight: 700; font-size: 0.9rem; color: var(--ap-ink); }
.ap-toast .ap-toast__msg { font-size: 0.85rem; color: var(--ap-muted); margin-top: 2px; white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 575px) { .toastify.ap-toastify { width: auto; left: 16px; right: 16px; } }

/* ── Dialogs ── */
dialog.ap-dlg {
  border: 1px solid var(--ap-line); border-radius: 12px; background: var(--ap-surface); color: var(--ap-ink);
  padding: 24px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--ap-shadow); font-family: inherit; text-align: center;
}
dialog.ap-dlg::backdrop { background: var(--ap-backdrop); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.ap-dlg[open] { animation: ap-pop .18s ease-out; }
@keyframes ap-pop { from { transform: scale(.96); opacity: 0; } }
.ap-dlg .ap-icon, .ap-dlg .ap-spin { width: 52px; height: 52px; font-size: 1.5rem; margin: 0 auto 12px; display: flex; }
.ap-dlg .ap-dlg__title { font-size: 1.15rem; font-weight: 800; margin: 0 0 6px; color: var(--ap-ink); font-family: inherit; }
.ap-dlg .ap-dlg__text { color: var(--ap-muted); font-size: 0.9rem; margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.ap-dlg__actions { display: flex; gap: 8px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* ── Block (spinner over one element) ── */
.ap-block {
  position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--ap-surface) 75%, transparent); border-radius: inherit;
}
.ap-block .ap-block__msg { font-size: 0.85rem; font-weight: 600; color: var(--ap-muted); }
