/* ------------------------------------------------------------------
   App-Dialoge — einheitliche, hübsche Ersatzdialoge für die nativen
   confirm() / alert() / prompt(). Funktioniert in allen Browsern gleich
   (kein Chrome-„Diese Seite fragt …"-Kasten mehr). Farbwelt: Weiß/Blau,
   Grün für Bestätigen/Speichern, Rot für gefährliche Aktionen.
   ------------------------------------------------------------------ */
:root {
    --appdlg-blue: #2b6777;
    --appdlg-light-blue: #c8d8e4;
    --appdlg-light-gray: #f2f2f2;
    --appdlg-text: #333333;
    --appdlg-green: #4CAF50;
    --appdlg-green-dark: #3d9140;
    --appdlg-danger: #c0392b;
    --appdlg-danger-dark: #a5301f;
    --appdlg-border: #d5dde3;
}

.appdlg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(43, 103, 119, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.appdlg-overlay.appdlg-visible { opacity: 1; }

.appdlg-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px;
    color: var(--appdlg-text);
    transform: translateY(8px);
    transition: transform 0.15s ease;
    box-sizing: border-box;
}
.appdlg-overlay.appdlg-visible .appdlg-box { transform: translateY(0); }

.appdlg-title {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 700;
    color: var(--appdlg-blue);
    line-height: 1.3;
}
.appdlg-message {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.appdlg-message:last-of-type { margin-bottom: 0; }

.appdlg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    margin: 0 0 18px;
    border: 1px solid var(--appdlg-border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--appdlg-text);
    font-family: inherit;
}
.appdlg-input:focus {
    outline: none;
    border-color: var(--appdlg-blue);
    box-shadow: 0 0 0 3px rgba(43, 103, 119, 0.15);
}

.appdlg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.appdlg-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    min-width: 110px;
    font-family: inherit;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.appdlg-btn:focus-visible {
    outline: 3px solid rgba(43, 103, 119, 0.4);
    outline-offset: 2px;
}

.appdlg-btn-cancel {
    background: var(--appdlg-light-gray);
    color: var(--appdlg-text);
    border-color: var(--appdlg-border);
}
.appdlg-btn-cancel:hover { background: #e6e6e6; }

.appdlg-btn-confirm {
    background: var(--appdlg-green);
    color: #fff;
}
.appdlg-btn-confirm:hover { background: var(--appdlg-green-dark); }

.appdlg-box.appdlg-tone-danger .appdlg-title { color: var(--appdlg-danger); }
.appdlg-box.appdlg-tone-danger .appdlg-btn-confirm { background: var(--appdlg-danger); }
.appdlg-box.appdlg-tone-danger .appdlg-btn-confirm:hover { background: var(--appdlg-danger-dark); }

/* Alert hat nur einen Knopf — blau statt grün, da es kein „Speichern" ist. */
.appdlg-box.appdlg-mode-alert .appdlg-btn-confirm { background: var(--appdlg-blue); }
.appdlg-box.appdlg-mode-alert .appdlg-btn-confirm:hover { background: #22525f; }
.appdlg-box.appdlg-mode-alert.appdlg-tone-danger .appdlg-btn-confirm { background: var(--appdlg-danger); }
.appdlg-box.appdlg-mode-alert.appdlg-tone-danger .appdlg-btn-confirm:hover { background: var(--appdlg-danger-dark); }

/* ---- Toast (kurze, selbst-schließende Rückmeldung) ---- */
.appdlg-toast-wrap {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 32px);
}
.appdlg-toast {
    background: var(--appdlg-blue);
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 100%;
    word-break: break-word;
    text-align: center;
}
.appdlg-toast.appdlg-visible { opacity: 1; transform: translateY(0); }
.appdlg-toast.appdlg-toast-success { background: var(--appdlg-green); }
.appdlg-toast.appdlg-toast-error { background: var(--appdlg-danger); }

@media (max-width: 520px) {
    .appdlg-box { padding: 20px; border-radius: 10px; }
    .appdlg-title { font-size: 18px; }
    .appdlg-actions { flex-direction: column-reverse; }
    .appdlg-btn { width: 100%; min-width: 0; }
}
