/*
 * Toast position/style variants and the corner-spinner loading indicator.
 *
 * Deliberately a small, hand-written, standalone stylesheet rather than an addition to
 * assets/css/tailwind.css: that file is generated by `npm run css:build` from
 * assets/css/tailwind.css (the source), and editing the source requires running that
 * build before anything here would take effect. Keeping this separate means the
 * System UI Optimizer's toast/spinner settings work immediately, with no build step.
 *
 * Applied to the existing .toast-stack (views/layout_bottom.php) and #page-progress
 * (views/layout_top.php) elements — this file only adds position/style *variants* on
 * top of their current base rules in tailwind.css, it does not redefine them.
 */

/* ---------- Toast position variants ---------- */
/* Default (no class) matches the existing bottom-center behavior already in tailwind.css. */
.toast-stack.toast-pos-top-left,
.toast-stack.toast-pos-top-center,
.toast-stack.toast-pos-top-right {
  top: calc(16px + env(safe-area-inset-top));
  bottom: auto;
}
.toast-stack.toast-pos-bottom-left,
.toast-stack.toast-pos-bottom-right {
  bottom: calc(72px + env(safe-area-inset-bottom));
}
.toast-stack.toast-pos-top-left,
.toast-stack.toast-pos-bottom-left {
  left: 16px;
  right: auto;
  transform: none;
  align-items: flex-start;
}
.toast-stack.toast-pos-top-right,
.toast-stack.toast-pos-bottom-right {
  left: auto;
  right: 16px;
  transform: none;
  align-items: flex-end;
}
.toast-stack.toast-pos-top-center {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

/* ---------- Toast style variants ---------- */
/* "solid" is the existing DaisyUI alert default (filled color) — no extra class needed. */
.toast-stack.toast-style-soft .alert {
  background: color-mix(in srgb, currentColor 12%, var(--surface));
}
.toast-stack.toast-style-bordered .alert {
  background: var(--surface);
  border: 2px solid currentColor;
  color: var(--ink);
}
.toast-stack.toast-style-bordered .alert.alert-success { border-color: var(--color-success); }
.toast-stack.toast-style-bordered .alert.alert-error { border-color: var(--color-error); }
.toast-stack.toast-style-bordered .alert.alert-warning { border-color: var(--color-warning); }

/* ---------- Corner spinner (alternative to the top progress bar) ---------- */
.corner-spinner {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 998;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .18s ease, transform .18s ease;
}
.corner-spinner.loading { opacity: 1; transform: scale(1); }
.corner-spinner span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 3px solid color-mix(in srgb, var(--spinner-color, var(--brand)) 25%, transparent);
  border-top-color: var(--spinner-color, var(--brand));
  animation: corner-spinner-spin .7s linear infinite;
}
@keyframes corner-spinner-spin { to { transform: rotate(360deg); } }

/* ---------- Central spinner (fixed to the middle of the viewport) ---------- */
.center-spinner {
  position: fixed;
  top: 50%; left: 50%;
  z-index: 998;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.85);
  transition: opacity .18s ease, transform .18s ease;
}
.center-spinner.loading { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.center-spinner span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 4px solid color-mix(in srgb, var(--spinner-color, var(--brand)) 25%, transparent);
  border-top-color: var(--spinner-color, var(--brand));
  animation: corner-spinner-spin .7s linear infinite;
}

/* ---------- Page dim overlay: "make the page darker while it spins" ----------
   Independent of which spinner style is active — toggled by app.js alongside
   whichever indicator is showing, only when the admin has enabled it. Never
   captures clicks (pointer-events: none): it is feedback, not a modal block. */
.page-dim-overlay {
  position: fixed;
  inset: 0;
  z-index: 997;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.page-dim-overlay.active { opacity: 1; }

@media (max-width: 640px) {
  .toast-stack.toast-pos-top-left,
  .toast-stack.toast-pos-top-right,
  .toast-stack.toast-pos-bottom-left,
  .toast-stack.toast-pos-bottom-right {
    left: 12px;
    right: 12px;
    align-items: stretch;
  }
}
