/*
 * NIZU toasts — the card drawn by assets/js/app-toast.js (appAlert) and the
 * corner picker of Settings -> Interface (app/Views/settings/ui_options.php).
 *
 * One card in two themes: white with a coloured outline icon in light mode,
 * deep navy in dark mode (body.color-1E202D), a countdown bar along the bottom
 * edge in the type's colour. Every colour is a token on .nz-toast, so the
 * dark theme only re-sets tokens.
 */

/* ------------------------------------------------------------- tokens --- */

.nz-toast,
.nz-toast-picker {
    --nzt-bg: #ffffff;
    --nzt-title: #0f172a;
    --nzt-text: #334155;
    --nzt-close: #64748b;
    --nzt-close-hover: rgba(15, 23, 42, .06);
    --nzt-track: #e2e8f0;
    --nzt-ring: rgba(15, 23, 42, .06);
    --nzt-shadow: 0 14px 34px -14px rgba(15, 23, 42, .38), 0 2px 6px rgba(15, 23, 42, .07);

    --nzt-info: #2563eb;
    --nzt-success: #059669;
    --nzt-error: #dc2626;
    --nzt-warning: #d97706;
    --nzt-undo: #7c3aed;
}

body.color-1E202D .nz-toast,
body.color-1E202D .nz-toast-picker {
    --nzt-bg: #111a2e;
    --nzt-title: #f8fafc;
    --nzt-text: #cbd5e1;
    --nzt-close: #94a3b8;
    --nzt-close-hover: rgba(255, 255, 255, .08);
    --nzt-track: rgba(255, 255, 255, .10);
    --nzt-ring: rgba(255, 255, 255, .07);
    --nzt-shadow: 0 16px 36px -14px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .35);

    --nzt-info: #60a5fa;
    --nzt-success: #34d399;
    --nzt-error: #f87171;
    --nzt-warning: #fbbf24;
    --nzt-undo: #a78bfa;
}

.nz-toast--info    { --nzt-accent: var(--nzt-info); }
.nz-toast--success { --nzt-accent: var(--nzt-success); }
.nz-toast--error   { --nzt-accent: var(--nzt-error); }
.nz-toast--warning { --nzt-accent: var(--nzt-warning); }
/* a delete that can be undone: appTable adds .undo-delete to the toast */
.nz-toast:has(.undo-delete) { --nzt-accent: var(--nzt-undo); }

/* ---------------------------------------------------------- the card --- */

.nz-toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 12px 17px 16px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--nzt-bg);
    color: var(--nzt-text);
    box-shadow: var(--nzt-shadow), 0 0 0 1px var(--nzt-ring);
    font-size: 14px;
    line-height: 1.4;
    text-align: start;
    pointer-events: auto;
}

.nz-toast__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--nzt-accent);
    border-radius: 50%;
    color: var(--nzt-accent);
    font-size: 14px;
    line-height: 1;
}

/* two classes: Font Awesome's own .fa-regular { display } loads after this sheet */
.nz-toast .nz-toast__glyph--undo,
.nz-toast:has(.undo-delete) .nz-toast__glyph {
    display: none;
}

.nz-toast:has(.undo-delete) .nz-toast__glyph.nz-toast__glyph--undo {
    display: inline-block;
}

/* title + text in column 1, the Undo button (inserted after the text by
   appTable) in column 2 spanning both lines */
.nz-toast__body {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: center;
}

.nz-toast__title {
    grid-column: 1;
    color: var(--nzt-title);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

.nz-toast .app-alert-message.nz-toast__text {
    grid-column: 1;
    display: block;
    min-width: 0;
    max-width: none;
    margin: 0;
    color: var(--nzt-text);
    overflow-wrap: anywhere;
}

.nz-toast__text ul,
.nz-toast__text ol {
    margin: 4px 0 0;
    padding-inline-start: 18px;
}

.nz-toast .nz-toast__text a {
    color: var(--nzt-accent);
    font-weight: 500;
}

/* push notifications wrap the whole text in a.color-white (made for the old
   coloured alert): on this card it reads as the text it is */
.nz-toast .nz-toast__text a.color-white {
    color: inherit !important;
    font-weight: inherit;
}

.nz-toast .undo-delete {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding: 3px 10px;
    border: 1px solid var(--nzt-accent);
    border-radius: 5px;
    color: var(--nzt-accent);
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
    white-space: nowrap;
}

.nz-toast .undo-delete strong {
    font-weight: 500;
}

.nz-toast .undo-delete:hover,
.nz-toast .undo-delete:focus-visible {
    background: color-mix(in srgb, var(--nzt-accent) 12%, transparent);
}

.nz-toast .btn-close.nz-toast__close {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--nzt-close);
    font-size: 16px;
    opacity: 1;
    filter: none;
    box-shadow: none;
}

.nz-toast .btn-close.nz-toast__close:hover {
    background: var(--nzt-close-hover);
    color: var(--nzt-title);
}

.nz-toast .btn-close.nz-toast__close:focus-visible {
    outline: 2px solid var(--nzt-accent);
    outline-offset: 1px;
}

/* the countdown along the bottom edge; full and still when the toast stays */
.nz-toast__track {
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: var(--nzt-track);
}

.nz-toast__bar {
    height: 100%;
    background: var(--nzt-accent);
    transform-origin: left center;
}

[dir="rtl"] .nz-toast__bar,
.rtl .nz-toast__bar {
    transform-origin: right center;
}

.nz-toast--timed .nz-toast__bar {
    animation: nz-toast-countdown var(--nz-toast-duration, 5000ms) linear forwards;
}

.nz-toast--paused .nz-toast__bar {
    animation-play-state: paused;
}

.nz-toast--nobar .nz-toast__bar {
    opacity: 0;
}

@keyframes nz-toast-countdown {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* printed inside a modal or a card (container option): same card, in place */
.nz-toast--inline {
    margin-bottom: 15px;
    box-shadow: 0 0 0 1px var(--nzt-ring), 0 1px 2px rgba(15, 23, 42, .06);
}

/* ------------------------------------------------------ the corners --- */

.nz-toast-region {
    --nz-toast-from: 28px;
    position: fixed;
    z-index: 1090; /* above modals (1055) and their backdrop */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 420px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.nz-toast-region:empty {
    display: none;
}

.nz-toast-region--top_left,
.nz-toast-region--top_right {
    top: 16px;
    flex-direction: column-reverse; /* the newest toast nearest the edge */
}

body:has(#default-navbar) .nz-toast-region--top_left,
body:has(#default-navbar) .nz-toast-region--top_right {
    top: 76px; /* under the topbar, not over its menus */
}

.nz-toast-region--bottom_left,
.nz-toast-region--bottom_right {
    bottom: 24px;
}

.nz-toast-region--top_left,
.nz-toast-region--bottom_left {
    left: 24px;
    --nz-toast-from: -28px;
}

.nz-toast-region--top_right,
.nz-toast-region--bottom_right {
    right: 24px;
}

/* the Team Messenger bubble (50px, 20px off the corner) keeps its corner */
@media (min-width: 576px) {
    body:has(#js-init-chat-icon) .nz-toast-region--bottom_right {
        bottom: 84px;
    }
}

.nz-toast--floating {
    transition: transform .34s cubic-bezier(.2, .9, .25, 1.15), opacity .22s ease;
}

.nz-toast--floating.nz-toast--enter {
    opacity: 0;
    transform: translateX(var(--nz-toast-from));
}

.nz-toast--floating.nz-toast--out {
    opacity: 0;
    transform: translateX(var(--nz-toast-from)) scale(.98);
    transition-duration: .24s;
}

/* a phone: full width, at the top or bottom the admin picked */
@media (max-width: 575.98px) {
    .nz-toast-region {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        --nz-toast-from: 0;
    }

    .nz-toast-region--top_left,
    .nz-toast-region--top_right {
        top: calc(12px + env(safe-area-inset-top, 0px));
    }

    body:has(#default-navbar) .nz-toast-region--top_left,
    body:has(#default-navbar) .nz-toast-region--top_right {
        top: 64px;
    }

    .nz-toast-region--bottom_left,
    .nz-toast-region--bottom_right {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    /* clear the iOS 26 tab bar (its height is published by bottombar-ios26.js) */
    body.nz-bb26-on .nz-toast-region--bottom_left,
    body.nz-bb26-on .nz-toast-region--bottom_right {
        bottom: var(--nz-bb26-clear, 96px);
    }

    .nz-toast--floating.nz-toast--enter,
    .nz-toast--floating.nz-toast--out {
        transform: translateY(12px);
    }

    .nz-toast-region--top_left .nz-toast--floating.nz-toast--enter,
    .nz-toast-region--top_right .nz-toast--floating.nz-toast--enter,
    .nz-toast-region--top_left .nz-toast--floating.nz-toast--out,
    .nz-toast-region--top_right .nz-toast--floating.nz-toast--out {
        transform: translateY(-12px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nz-toast--floating,
    .nz-toast-picker__demo {
        transition: opacity .2s ease !important;
    }

    .nz-toast--floating.nz-toast--enter,
    .nz-toast--floating.nz-toast--out {
        transform: none !important;
    }
}

/* ------------------------------------- Settings -> Interface: corner picker --- */

.nz-toast-picker {
    --nzp-screen: #f1f5f9;
    --nzp-chrome: #e2e8f0;
    --nzp-skel: #dbe3ec;
    --nzp-skel-strong: #cbd5e1;
    --nzp-edge: rgba(15, 23, 42, .12);
    --nzp-target: rgba(37, 99, 235, .55);
    max-width: 480px;
}

body.color-1E202D .nz-toast-picker {
    --nzp-screen: #171b27;
    --nzp-chrome: #232838;
    --nzp-skel: #262c3d;
    --nzp-skel-strong: #30374b;
    --nzp-edge: rgba(255, 255, 255, .10);
    --nzp-target: rgba(96, 165, 250, .6);
}

.nz-toast-picker__screen {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid var(--nzp-edge);
    border-radius: 10px;
    background: var(--nzp-screen);
    box-shadow: 0 10px 30px -18px rgba(15, 23, 42, .45);
    user-select: none;
}

/* the mock app: window bar, sidebar, page skeleton */
.nz-toast-picker__chrome {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    background: var(--nzp-chrome);
}

.nz-toast-picker__chrome span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--nzp-skel-strong);
}

.nz-toast-picker__app {
    position: absolute;
    inset: 22px 0 0 0;
    display: flex;
}

.nz-toast-picker__nav {
    width: 18%;
    padding: 12px 8px;
    border-inline-end: 1px solid var(--nzp-edge);
}

.nz-toast-picker__page {
    flex: 1;
    padding: 14px 16px;
}

.nz-toast-picker__nav i,
.nz-toast-picker__page i {
    display: block;
    height: 6px;
    margin-bottom: 9px;
    border-radius: 3px;
    background: var(--nzp-skel);
}

.nz-toast-picker__page i:first-child {
    width: 38%;
    height: 9px;
    margin-bottom: 14px;
    background: var(--nzp-skel-strong);
}

.nz-toast-picker__page i:nth-child(3n) { width: 72%; }
.nz-toast-picker__page i:nth-child(3n+1):not(:first-child) { width: 88%; }
.nz-toast-picker__nav i:nth-child(odd) { width: 80%; }

/* four quadrants are the click targets; the dashed slot shows where a toast lands */
.nz-toast-picker__corner {
    position: absolute;
    z-index: 2;
    width: 50%;
    height: calc(50% - 11px);
    margin: 0;
    cursor: pointer;
}

.nz-toast-picker__corner--top_left     { top: 22px; left: 0; }
.nz-toast-picker__corner--top_right    { top: 22px; right: 0; }
.nz-toast-picker__corner--bottom_left  { bottom: 0; left: 0; }
.nz-toast-picker__corner--bottom_right { bottom: 0; right: 0; }

.nz-toast-picker__slot {
    position: absolute;
    width: 92%;
    height: 40px;
    border: 1.5px dashed transparent;
    border-radius: 6px;
    transition: border-color .15s ease, background-color .15s ease;
}

.nz-toast-picker__corner--top_left .nz-toast-picker__slot     { top: 8px; left: 8px; }
.nz-toast-picker__corner--top_right .nz-toast-picker__slot    { top: 8px; right: 8px; }
.nz-toast-picker__corner--bottom_left .nz-toast-picker__slot  { bottom: 8px; left: 8px; }
.nz-toast-picker__corner--bottom_right .nz-toast-picker__slot { bottom: 8px; right: 8px; }

.nz-toast-picker__screen:hover .nz-toast-picker__slot {
    border-color: var(--nzp-edge);
}

.nz-toast-picker__corner:hover .nz-toast-picker__slot {
    border-color: var(--nzp-target);
    background: color-mix(in srgb, var(--nzp-target) 10%, transparent);
}

.nz-toast-picker__radio:focus-visible + .nz-toast-picker__slot {
    border-style: solid;
    border-color: var(--nzp-target);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--nzp-target) 30%, transparent);
}

/* the miniature toast: the real card's look at a third of the size */
.nz-toast-picker__demo {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(46% - 8px);
    height: 40px;
    padding: 0 8px 2px 10px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--nzt-bg);
    box-shadow: var(--nzt-shadow), 0 0 0 1px var(--nzt-ring);
    pointer-events: none;
    transition: opacity .2s ease;
}

.nz-toast-picker__demo--undo { --nzt-accent: var(--nzt-undo); }

.nz-toast-picker[data-position="top_left"] .nz-toast-picker__demo     { top: 31px; left: 9px; }
.nz-toast-picker[data-position="top_right"] .nz-toast-picker__demo    { top: 31px; right: 9px; }
.nz-toast-picker[data-position="bottom_left"] .nz-toast-picker__demo  { bottom: 9px; left: 9px; }
.nz-toast-picker[data-position="bottom_right"] .nz-toast-picker__demo { bottom: 9px; right: 9px; }

.nz-toast-picker__demo.is-playing {
    animation: nz-toast-picker-in-right .42s cubic-bezier(.2, .9, .25, 1.2) both;
}

.nz-toast-picker[data-position$="_left"] .nz-toast-picker__demo.is-playing {
    animation-name: nz-toast-picker-in-left;
}

@keyframes nz-toast-picker-in-right {
    from { opacity: 0; transform: translateX(22px); }
    to   { opacity: 1; transform: none; }
}

@keyframes nz-toast-picker-in-left {
    from { opacity: 0; transform: translateX(-22px); }
    to   { opacity: 1; transform: none; }
}

.nz-toast-picker__demo .nz-toast__icon {
    width: 16px;
    height: 16px;
    border-width: 1px;
    font-size: 8px;
}

.nz-toast-picker__demo-body {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
    white-space: nowrap;
}

.nz-toast-picker__demo-title {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--nzt-title);
    font-size: 10px;
    font-weight: 600;
}

.nz-toast-picker__demo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--nzt-text);
    font-size: 9px;
}

.nz-toast-picker__demo-close {
    color: var(--nzt-close);
    font-size: 9px;
}

.nz-toast-picker__demo .nz-toast__track {
    height: 2px;
}

.nz-toast-picker__demo.is-playing .nz-toast__bar {
    animation: nz-toast-countdown 4s linear forwards;
}

.nz-toast-picker__label {
    white-space: nowrap;
}

.nz-toast-picker__caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin-top: 10px;
}

@media (prefers-reduced-motion: reduce) {
    .nz-toast-picker__demo.is-playing {
        animation: none;
    }
}
