/* PointTurkey dialogs + toasts (pt-dialogs.css): ONE look for the website and the admin. Loaded after pt.css.
   JS: js/pt-dialogs.js. Markup is built by the script (<dialog class="pt-dlg">, .pt-toasts > .pt-toast) and server flash banners
   (.pt-flashes > .pt-flash) are the no-JS fallback. Logical properties throughout (RTL-safe). Tokens come from pt.css. */

/* ---------- confirm / alert dialog (native <dialog>) ---------- */
html.pt-dlg-lock { overflow: hidden; }
dialog.pt-dlg {
  --dlg-accent: var(--pt-red-600, #cf1f1d); --dlg-soft: var(--pt-red-50, #fff1f1);
  box-sizing: border-box; padding: 0; border: 0; background: transparent; color: var(--pt-text, #171716);
  width: min(440px, calc(100vw - 32px)); max-width: 440px; max-height: calc(100dvh - 32px);
  margin: auto; overflow: visible; font-family: var(--pt-font, "Inter", system-ui, sans-serif); font-size: 16px; line-height: 1.5;
  overscroll-behavior: contain;
}
dialog.pt-dlg:not([open]) { display: none; }
dialog.pt-dlg *, dialog.pt-dlg *::before, dialog.pt-dlg *::after { box-sizing: border-box; }
dialog.pt-dlg::backdrop { background: rgba(11, 26, 48, .52); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }   /* v3: navy scrim */
dialog.pt-dlg--success { --dlg-accent: var(--pt-success, #15803d); --dlg-soft: var(--pt-success-bg, #ecfdf3); }
dialog.pt-dlg--warning { --dlg-accent: var(--pt-warning, #b45309); --dlg-soft: var(--pt-warning-bg, #fffaeb); }
dialog.pt-dlg--info { --dlg-accent: var(--pt-navy-700, #172f55); --dlg-soft: var(--pt-navy-50, #f1f5fb); }
dialog.pt-dlg--error, dialog.pt-dlg--danger { --dlg-accent: var(--pt-red-700, #ad1917); --dlg-soft: var(--pt-red-50, #fff1f1); }

dialog.pt-dlg .pt-dlg__box {
  position: relative; margin: 0; background: var(--pt-surface, #fff); border-radius: var(--pt-r-xl, 20px);
  padding: 24px 24px 20px; box-shadow: 0 28px 60px -20px rgba(11, 26, 48, .42), 0 0 0 1px rgba(11, 26, 48, .06);
  display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
}
dialog.pt-dlg .pt-dlg__grab { display: none; }
dialog.pt-dlg .pt-dlg__head { display: flex; align-items: center; gap: 14px; }
dialog.pt-dlg .pt-dlg__icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--dlg-soft); color: var(--dlg-accent); }
dialog.pt-dlg .pt-dlg__icon .pt-icon { width: 22px; height: 22px; stroke: currentColor; fill: none; }
dialog.pt-dlg .pt-dlg__title {
  margin: 0; font-family: var(--pt-font-ui, "Plus Jakarta Sans", "Inter", system-ui, sans-serif); font-size: 1.1875rem; font-weight: 700; line-height: 1.3;
  letter-spacing: -.01em; color: var(--pt-heading, #0b1a30); overflow-wrap: anywhere;
}
dialog.pt-dlg .pt-dlg__msg { margin: 0; padding-inline-start: 58px; color: var(--pt-text-2, #55554f); font-size: .9375rem; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
dialog.pt-dlg .pt-dlg__head + .pt-dlg__msg { margin-top: -2px; }
dialog.pt-dlg .pt-dlg__type { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; padding-inline-start: 58px; font-size: .875rem; color: var(--pt-text-2, #55554f); }
dialog.pt-dlg .pt-dlg__type-value { color: var(--pt-text, #171716); font-family: var(--pt-mono, ui-monospace, Menlo, Consolas, monospace); font-weight: 700; background: var(--pt-gray-100, #efefec); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
dialog.pt-dlg .pt-dlg__input {
  width: 100%; min-height: 46px; padding: 10px 14px; font: inherit; font-size: 1rem; color: var(--pt-text, #171716); background: #fff;
  border: 1px solid var(--pt-gray-300, #d2d2cc); border-radius: 10px; box-shadow: none; margin: 0;
}
dialog.pt-dlg .pt-dlg__input:hover { border-color: var(--pt-gray-400, #a3a39d); }
dialog.pt-dlg .pt-dlg__input:focus { outline: none; border-color: var(--pt-navy-600, #1f3d6b); box-shadow: 0 0 0 4px var(--pt-ring, rgba(31, 61, 107, .38)); }
dialog.pt-dlg .pt-dlg__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
dialog.pt-dlg .pt-dlg__btn {
  appearance: none; -webkit-appearance: none; cursor: pointer; margin: 0; min-height: 44px; padding: 10px 20px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-size: .9375rem; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none;
  transition: background-color .16s, border-color .16s, box-shadow .16s, transform .16s;
}
dialog.pt-dlg .pt-dlg__btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--pt-ring, rgba(31, 61, 107, .38)); }
dialog.pt-dlg .pt-dlg__btn:active { transform: scale(.985); }
dialog.pt-dlg .pt-dlg__btn--cancel { background: var(--pt-surface, #fff); color: var(--pt-navy-800, #10233f); border-color: var(--pt-navy-200, #c3d2ea); }
dialog.pt-dlg .pt-dlg__btn--cancel:hover { border-color: var(--pt-navy-700, #172f55); background: var(--pt-navy-50, #f1f5fb); }
dialog.pt-dlg .pt-dlg__btn--ok { background: var(--pt-red-600, #cf1f1d); color: #fff; }
dialog.pt-dlg .pt-dlg__btn--ok:hover { background: var(--pt-red-700, #ad1917); box-shadow: 0 6px 16px -6px rgba(173, 25, 23, .55); }
dialog.pt-dlg .pt-dlg__btn--ok.is-danger { background: var(--pt-red-700, #ad1917); }
dialog.pt-dlg .pt-dlg__btn--ok.is-danger:hover { background: var(--pt-red-800, #8e1714); }
dialog.pt-dlg .pt-dlg__btn--ok[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* open / close motion */
dialog.pt-dlg[open] { animation: pt-dlg-in .22s cubic-bezier(.2, .8, .2, 1); }
dialog.pt-dlg[open]::backdrop { animation: pt-dlg-fade .2s ease-out; }
dialog.pt-dlg.is-closing { animation: pt-dlg-out .18s ease-in forwards; }
dialog.pt-dlg.is-closing::backdrop { animation: pt-dlg-fade-out .18s ease-in forwards; }
@keyframes pt-dlg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes pt-dlg-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes pt-dlg-fade { from { opacity: 0; } }
@keyframes pt-dlg-fade-out { to { opacity: 0; } }

/* phones: bottom sheet, full-width 48px buttons, safe-area insets */
@media (max-width: 599px) {
  dialog.pt-dlg { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 100dvh; }
  dialog.pt-dlg .pt-dlg__box {
    border-radius: 20px 20px 0 0; max-height: calc(100dvh - 24px);
    padding: 10px max(20px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    gap: 10px; box-shadow: 0 -12px 40px -12px rgba(11, 26, 48, .38);
  }
  dialog.pt-dlg .pt-dlg__grab { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--pt-gray-300, #d2d2cc); margin: 0 auto 8px; }
  dialog.pt-dlg .pt-dlg__head { gap: 12px; }
  dialog.pt-dlg .pt-dlg__msg, dialog.pt-dlg .pt-dlg__type { padding-inline-start: 0; }
  dialog.pt-dlg .pt-dlg__head + .pt-dlg__msg { margin-top: 0; }
  dialog.pt-dlg .pt-dlg__foot { flex-direction: column-reverse; gap: 10px; margin-top: 8px; }
  dialog.pt-dlg .pt-dlg__btn { width: 100%; min-height: 48px; font-size: 1rem; }
  dialog.pt-dlg .pt-dlg__input { min-height: 48px; font-size: 16px; }   /* 16px: no iOS zoom on focus */
  dialog.pt-dlg[open] { animation: pt-dlg-sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
  dialog.pt-dlg.is-closing { animation: pt-dlg-sheet-out .2s ease-in forwards; }
}
@keyframes pt-dlg-sheet-in { from { transform: translateY(100%); } }
@keyframes pt-dlg-sheet-out { to { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  dialog.pt-dlg[open], dialog.pt-dlg[open]::backdrop, dialog.pt-dlg.is-closing, dialog.pt-dlg.is-closing::backdrop { animation: none !important; }
  dialog.pt-dlg .pt-dlg__btn { transition: none; }
}

/* ---------- toasts ---------- */
.pt-toasts {
  position: fixed; z-index: var(--pt-z-toast, 100); inset-inline: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom) + var(--pt-tabbar-h, 0px) + var(--pt-consent-h, 0px));
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; margin: 0; padding: 0;
}
.pt-toast {
  --tst: var(--pt-navy-700, #172f55);
  position: relative; pointer-events: auto; overflow: hidden; display: flex; align-items: flex-start; gap: 12px;
  width: 100%; max-width: 420px; padding: 12px 8px 12px 14px; background: var(--pt-surface, #fff); color: var(--pt-text, #121c2e);
  border: 1px solid rgba(11, 26, 48, .08); border-inline-start: 4px solid var(--tst); border-radius: var(--pt-r-lg, 14px);
  box-shadow: 0 14px 36px -12px rgba(11, 26, 48, .34), 0 2px 6px rgba(11, 26, 48, .06);
  font-family: var(--pt-font, "Inter", system-ui, sans-serif); font-size: .9375rem; line-height: 1.45;
  animation: pt-toast-in .26s cubic-bezier(.2, .8, .2, 1);
}
.pt-toast--success { --tst: var(--pt-success, #15803d); }
.pt-toast--error { --tst: var(--pt-red-600, #cf1f1d); }
.pt-toast--warning { --tst: var(--pt-warning, #b45309); }
.pt-toast__icon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; color: var(--tst); }
.pt-toast__icon .pt-icon { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.pt-toast__body { flex: 1; min-width: 0; padding-block: 1px; overflow-wrap: anywhere; }
.pt-toast__title { display: block; font-weight: 700; margin-bottom: 1px; }
.pt-toast__msg { color: var(--pt-text, #171716); }
.pt-toast__title + .pt-toast__msg { color: var(--pt-text-2, #55554f); }
.pt-toast .pt-toast__close {
  appearance: none; -webkit-appearance: none; flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin: -4px 0; padding: 0;
  background: none; border: 0; border-radius: 50%; cursor: pointer; color: var(--pt-text-3, #6b6b65); min-width: 0; min-height: 0;
}
.pt-toast .pt-toast__close:hover { background: var(--pt-gray-100, #efefec); color: var(--pt-text, #171716); }
.pt-toast .pt-toast__close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--pt-ring, rgba(31, 61, 107, .38)); }
.pt-toast .pt-toast__close .pt-icon { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.pt-toast__bar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--tst); opacity: .35; transform-origin: left center; animation: pt-toast-bar linear forwards; }
[dir="rtl"] .pt-toast__bar { transform-origin: right center; }
.pt-toast.is-leaving { opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .2s, transform .2s; }
.pt-toast.is-bump { animation: pt-toast-bump .3s; }
@keyframes pt-toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes pt-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes pt-toast-bump { 40% { transform: scale(1.03); } }
@media (min-width: 900px) {
  .pt-toasts, body.pt-has-actionbar .pt-toasts { inset-inline: auto 24px; bottom: 24px; width: min(400px, calc(100vw - 48px)); align-items: stretch; transform: none; left: auto; }
  [dir="rtl"] .pt-toasts { inset-inline: 24px auto; }
  .pt-toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pt-toast, .pt-toast.is-bump { animation: none; }
  .pt-toast__bar { animation: none; display: none; }
  .pt-toast.is-leaving { transition: none; }
}
@media print { .pt-toasts, dialog.pt-dlg { display: none !important; } }

/* ---------- no-JS fallback: server flash banners (script turns them into toasts and removes this box) ---------- */
.pt-flashes { display: flex; flex-direction: column; gap: 8px; width: min(100% - 32px, 760px); margin: 12px auto 0; }
.pt-flash {
  margin: 0; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--pt-gray-200, #e4e4e0); border-inline-start-width: 4px;
  background: var(--pt-navy-50, #f1f5fb); border-color: var(--pt-navy-100, #e1e9f5); color: var(--pt-navy-800, #10233f); font-size: .9375rem; line-height: 1.45;
}
.pt-flash--success { background: var(--pt-success-bg, #ecfdf3); border-color: #b7ebcb; color: #14532d; }
.pt-flash--warning { background: var(--pt-warning-bg, #fffaeb); border-color: #f5dba6; color: #78350f; }
.pt-flash--error { background: var(--pt-danger-bg, #fff1f3); border-color: #f9c4cf; color: #7f1030; }
.adm .pt-flashes { width: auto; margin: 0 0 16px; }
