/*
 * dialog.css - the app's own alert / confirm / prompt / toast (assets/dialog.js),
 * replacing SweetAlert2. Same look as the app's dialogs (modules.css .modal):
 * dark panel, orange accent, the zoom in / out animation.
 *
 * Everything is scoped under .dlg (the container), so the class names kept
 * from SweetAlert2 for compatibility (.swal2-popup, .swal2-confirm ...) do not
 * pick up stray rules and the app's own rules do not leak in.
 */
.dlg {
    --dlg-bg: #151515; --dlg-fg: #eaeaea; --dlg-sub: #b5b5b5; --dlg-line: #333;
    --dlg-accent: #ff9800; --dlg-accent-fg: #111;
    position: fixed; inset: 0; z-index: 2000;
    display: flex; padding: 16px; box-sizing: border-box;
    align-items: center; justify-content: center;
    background-color: rgba(0, 0, 0, 0); transition: background-color .3s ease;
    font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.dlg.swal2-backdrop-show { background-color: rgba(0, 0, 0, .72); }
.dlg.dlg-closing { background-color: rgba(0, 0, 0, 0); }
.dlg.dlg-no-backdrop, .dlg.dlg-toast-wrap { background: none !important; pointer-events: none; }
.dlg.dlg-toast-wrap { z-index: 2100; }
.dlg *, .dlg *::before, .dlg *::after { box-sizing: border-box; }

/* positions (toasts mostly) - "start/end" follow the reading direction */
.dlg.dlg-top-end, .dlg.dlg-top-right { align-items: flex-start; justify-content: flex-end; }
.dlg.dlg-top-start, .dlg.dlg-top-left { align-items: flex-start; justify-content: flex-start; }
.dlg.dlg-top { align-items: flex-start; }
.dlg.dlg-bottom { align-items: flex-end; }
.dlg.dlg-bottom-end, .dlg.dlg-bottom-right { align-items: flex-end; justify-content: flex-end; }
.dlg.dlg-bottom-start, .dlg.dlg-bottom-left { align-items: flex-end; justify-content: flex-start; }
.dlg.dlg-center-end { justify-content: flex-end; }
.dlg.dlg-center-start { justify-content: flex-start; }

/* ---- the panel ---- */
.dlg .dlg-popup {
    position: relative; pointer-events: auto;
    width: min(440px, 100%); max-width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
    display: flex; flex-direction: column; align-items: stretch;
    background: var(--dlg-bg); color: var(--dlg-fg);
    border: 1px solid var(--dlg-line); border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
    padding: 22px 22px 18px; text-align: center; outline: none;
    animation: dlgIn .3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.dlg.dlg-closing .dlg-popup { animation: dlgOut .28s ease-in both; }
@keyframes dlgIn { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes dlgOut { 0% { opacity: 1; transform: scale(1); } 40% { opacity: 1; transform: scale(1.04); } 100% { opacity: 0; transform: scale(.7); } }
.dlg .dlg-popup.dlg-shake { animation: dlgShake .35s; }
@keyframes dlgShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
/* motion reduced - but animationend must still fire (the close waits for it) */
@media (prefers-reduced-motion: reduce) {
    .dlg .dlg-popup, .dlg.dlg-closing .dlg-popup, .dlg .dlg-popup.dlg-shake { animation-duration: .01ms; }
}
/* 4px room top and bottom too (cancelled by the margin): the body scrolls, so it clipped
   the focus glow of an input at its bottom edge ("the border is broken below", 2026-10-21) */
.dlg .dlg-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; margin: -4px -6px; padding: 4px 6px; }

.dlg .dlg-x {
    position: absolute; top: 8px; inset-inline-end: 8px; width: 34px; height: 34px;
    border: 0; border-radius: 8px; background: none; color: var(--dlg-sub);
    font-size: 24px; line-height: 1; cursor: pointer;
}
.dlg .dlg-x:hover, .dlg .dlg-x:focus-visible { color: var(--dlg-fg); background: rgba(255, 255, 255, .07); }

/* ---- icon ---- */
.dlg .dlg-icon { width: 64px; height: 64px; margin: 2px auto 12px; flex: 0 0 auto; color: var(--dlg-ic, #9e9e9e); }
.dlg .dlg-icon svg { width: 100%; height: 100%; display: block; }
.dlg .dlg-icon .ring { fill: none; stroke: currentColor; stroke-width: 3; opacity: .3; }
.dlg .dlg-icon .mark { fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 60; stroke-dashoffset: 60; animation: dlgDraw .45s .15s ease-out forwards; }
.dlg .dlg-icon .dot { fill: currentColor; opacity: 0; animation: dlgDot .2s .45s forwards; }
@keyframes dlgDraw { to { stroke-dashoffset: 0; } }
@keyframes dlgDot { to { opacity: 1; } }
.dlg .swal2-success { --dlg-ic: #4caf50; } .dlg .swal2-error { --dlg-ic: #f44336; }
.dlg .swal2-warning { --dlg-ic: #ff9800; } .dlg .swal2-info { --dlg-ic: #42a5f5; } .dlg .swal2-question { --dlg-ic: #9e9e9e; }
.dlg .swal2-image { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto 12px; border-radius: 10px; object-fit: contain; }

/* ---- text ---- */
.dlg .swal2-title { margin: 0 0 8px; font-size: 1.28em; font-weight: 700; line-height: 1.35; color: var(--dlg-fg); overflow-wrap: anywhere; }
.dlg .swal2-html-container { margin: 0 0 4px; font-size: 1em; line-height: 1.55; color: var(--dlg-sub); overflow-wrap: anywhere; }
.dlg .swal2-html-container:empty, .dlg .swal2-title:empty { display: none; }
.dlg .swal2-html-container b, .dlg .swal2-html-container strong { color: var(--dlg-fg); }
.dlg .swal2-html-container a { color: var(--dlg-accent); }
.dlg .swal2-footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--dlg-line); font-size: .88em; color: var(--dlg-sub); }

/* ---- input (also styles inputs a page puts in its own html) ---- */
.dlg .swal2-input, .dlg .swal2-textarea, .dlg .swal2-select, .dlg .swal2-file {
    display: block; width: 100%; margin: 12px 0 0; padding: 10px 12px; font: inherit; font-size: 1em;
    background: #222; color: var(--dlg-fg); border: 1px solid #444; border-radius: 9px; outline: none;
}
.dlg .swal2-textarea { min-height: 90px; resize: vertical; }
.dlg .swal2-input, .dlg .swal2-textarea, .dlg .swal2-select { transition: border-color .15s, box-shadow .15s; }
.dlg .swal2-input:focus, .dlg .swal2-textarea:focus, .dlg .swal2-select:focus { border-color: var(--dlg-accent); box-shadow: inset 0 0 0 1px var(--dlg-accent); }   /* a crisp 2px line - no muddy halo outside */
/* the themes recolour the input's border (theme.css) - the focus colour still wins */
html[data-theme] .dlg .swal2-input:focus, html[data-theme] .dlg .swal2-textarea:focus, html[data-theme] .dlg .swal2-select:focus { border-color: var(--dlg-accent); }
.dlg .swal2-input-label { display: block; margin: 12px 0 -6px; font-size: .9em; color: var(--dlg-sub); text-align: start; }
.dlg .swal2-validation-message {
    margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; font-size: .9em; text-align: start;
    background: rgba(244, 67, 54, .12); color: #ff8a80; border: 1px solid rgba(244, 67, 54, .35);
}
.dlg .swal2-validation-message[hidden] { display: none; }

/* ---- buttons ---- */
.dlg .swal2-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; flex: 0 0 auto; }
.dlg .swal2-actions:empty { display: none; }
.dlg .swal2-styled {
    min-width: 96px; padding: 10px 18px; border: 1px solid transparent; border-radius: 9px;
    font: inherit; font-size: .98em; font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s;
}
.dlg .swal2-styled:hover { filter: brightness(1.08); }
.dlg .swal2-styled:active { transform: translateY(1px); }
.dlg .swal2-styled:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dlg .swal2-styled[disabled] { opacity: .55; cursor: default; }
.dlg .swal2-confirm { background: var(--dlg-accent); color: var(--dlg-accent-fg); }
.dlg .swal2-deny { background: #c62828; color: #fff; }
.dlg .swal2-cancel { background: #2b2b2b; color: var(--dlg-fg); border-color: #444; }
.dlg .swal2-styled[hidden] { display: none; }
.dlg .dlg-loader { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 152, 0, .25); border-top-color: var(--dlg-accent); animation: dlgSpin .8s linear infinite; }
.dlg .dlg-loader[hidden] { display: none; }
@keyframes dlgSpin { to { transform: rotate(360deg); } }

/* ---- timer bar ---- */
.dlg .swal2-timer-progress-bar-container { position: absolute; inset-inline: 0; bottom: 0; height: 4px; overflow: hidden; border-radius: 0 0 14px 14px; }
.dlg .swal2-timer-progress-bar { height: 100%; background: rgba(255, 255, 255, .35); transform-origin: left center; }
[dir="rtl"] .dlg .swal2-timer-progress-bar { transform-origin: right center; }

/* ---- toast ---- */
.dlg .dlg-popup.swal2-toast {
    width: auto; min-width: 240px; max-width: min(420px, 100%); flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 10px 14px; gap: 0 10px; text-align: start; border-radius: 12px;
    animation: dlgToastIn .28s ease-out both;
}
.dlg.dlg-closing .dlg-popup.swal2-toast { animation: dlgToastOut .22s ease-in both; }
@keyframes dlgToastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes dlgToastOut { to { opacity: 0; transform: translateY(-8px); } }
.dlg .swal2-toast .dlg-icon { width: 30px; height: 30px; margin: 0; }
.dlg .swal2-toast .dlg-body { flex: 1 1 160px; margin: 0; padding: 0; overflow: visible; }
.dlg .swal2-toast .swal2-title { margin: 0; font-size: 1em; }
.dlg .swal2-toast .swal2-html-container { margin: 2px 0 0; font-size: .9em; }
.dlg .swal2-toast .swal2-actions { flex-basis: 100%; margin-top: 8px; justify-content: flex-end; }
.dlg .swal2-toast .swal2-styled { min-width: 0; padding: 6px 12px; font-size: .9em; }
.dlg .swal2-toast .swal2-timer-progress-bar-container { border-radius: 0 0 12px 12px; }

@media (max-width: 480px) {
    .dlg { padding: 10px; }
    .dlg .dlg-popup:not(.swal2-toast) { padding: 18px 16px 14px; }
    .dlg .swal2-actions .swal2-styled { flex: 1 1 0; }
}
