/* Shared OTDX notification presentation. Native controllers own messages,
   timers, queues, actions, dismissal and pointer/visibility state. */
:root {
    --otdx-toast-background: #3b82f6;
    --otdx-toast-error-background: #b91c1c;
    --otdx-toast-foreground: #fff;
    --otdx-toast-progress: rgba(255, 255, 255, .65);
    --otdx-toast-z-index: 12000;
}

/* Menus own the foreground through their native exit lifecycle. Profile stays
   portalled to body until its transition ends; navigation retains show-sidebar.
   Keep the original toast/modal ordering whenever those menus are closed. */
html body:has(#main-wrapper.show-sidebar, > #userSidebarPanel) {
    --otdx-toast-z-index: 1090;
}

/* Use the severity provided by each native renderer. */
html body :is(
    #toast-container .toast:is(.red, .orange, .amber, .toast-error, .toast-warning, .otdx-lir-toast-warning),
    .swal2-popup.swal2-toast:has(.swal2-icon:is(.swal2-error, .swal2-warning)),
    .otdx-toast:is(.otdx-toast--danger, .otdx-toast--warning),
    .rf-toast:is(.rf-toast-error, .rf-toast-warning),
    .bis-tr-toast.bis-tr-toast--warning,
    :is(.fe-notice, .fe-catalog-notice)[data-tone="negative"]
) {
    --otdx-toast-background: var(--otdx-toast-error-background);
}

/* SweetAlert dialogs are intentionally excluded: only toast containers dock. */
html body :is(#toast-container, #rf-toast-container, .bis-tr-toast-host,
             .swal2-container:has(> .swal2-toast)) {
    position: fixed !important;
    inset: auto 0 var(--otdx-toast-stack-offset, 0px) var(--desktop-hub-surface-left, 0px) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    z-index: var(--otdx-toast-z-index) !important;
    pointer-events: none !important;
    transition: left var(--otdx-motion-explorer-duration, var(--fe-motion-duration, .32s)) var(--otdx-motion-explorer-easing, var(--fe-motion-easing, ease)) !important;
}

html body :is(#toast-container .toast, .swal2-popup.swal2-toast, .otdx-toast,
             .rf-toast, .bookmark-toast, .cw-toast, .bis-tr-toast, .fe-notice) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 16px 20px !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--otdx-toast-background) !important;
    color: var(--otdx-toast-foreground) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: 0 -2px 12px rgba(15, 23, 42, .12) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    font-family: 'Nunito Sans', sans-serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    float: none !important;
}

html body :is(#toast-container .toast, .swal2-popup.swal2-toast, .rf-toast, .bis-tr-toast) {
    width: 100% !important;
}
html body :is(.swal2-popup.swal2-toast, .rf-toast, .bis-tr-toast) {
    display: flex !important;
}
/* Toastr's fadeOut sets inline display:none before its native removal check. */
html body #toast-container .toast { display: flex; left: 0 !important; }
/* Toastr shares Materialize's class name, but does not run its top animation. */
html body #toast-container .toast:is(.toast-success, .toast-info, .toast-warning, .toast-error) {
    top: 0 !important;
}
html body :is(#toast-container .toast, .swal2-popup.swal2-toast) {
    flex-wrap: wrap !important;
    pointer-events: auto !important;
}
html body :is(.otdx-toast, .bookmark-toast, .cw-toast, .fe-notice) {
    position: fixed !important;
    inset: auto 0 var(--otdx-toast-stack-offset, 0px) var(--desktop-hub-surface-left, 0px) !important;
    width: auto !important;
    z-index: var(--otdx-toast-z-index) !important;
}
html body :is(.otdx-toast, .bookmark-toast, .cw-toast) {
    display: flex !important;
    transform: translateY(100%) !important;
    transition: transform .3s ease, opacity .25s ease,
        left var(--otdx-motion-explorer-duration, var(--fe-motion-duration, .32s)) var(--otdx-motion-explorer-easing, var(--fe-motion-easing, ease)) !important;
}
html body .otdx-toast { cursor: pointer !important; }
html body :is(.otdx-toast.otdx-toast--show, .bookmark-toast.show, .cw-toast.show) {
    transform: translateY(0) !important;
}
html body .bookmark-toast.removing { transform: translateY(100%) !important; }
html body .fe-notice { transform: none !important; }
html body .fe-notice:not([hidden]) { display: flex !important; }
html body .fe-notice[hidden] { display: none !important; }

/* Keep meaning when colour alone previously distinguished a category. */
html body #toast-container .toast:is(.green, .teal, .toast-success)::before {
    content: '\2713';
    flex: 0 0 auto;
    font-weight: 700;
}
html body :is(#toast-container .toast.red, #toast-container .toast.orange, #toast-container .toast.amber,
             #toast-container .toast.toast-error, #toast-container .toast.toast-warning,
             #toast-container .toast.otdx-lir-toast-warning,
             .otdx-toast--danger, .otdx-toast--warning)::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-weight: 700;
    line-height: 1;
}

/* SweetAlert retains its icon shapes, progress, optional controls and lifecycle. */
html body .swal2-popup.swal2-toast :is(.swal2-title, .swal2-html-container, .swal2-content) {
    color: inherit !important;
    font: inherit !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    overflow-wrap: anywhere !important;
}
html body .swal2-popup.swal2-toast .swal2-title { flex: 0 1 auto; }
html body .swal2-popup.swal2-toast .swal2-icon {
    flex: 0 0 20px !important;
    box-sizing: content-box !important;
    width: 20px !important;
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-color: currentColor !important;
    color: var(--otdx-toast-foreground) !important;
    border-width: 2px !important;
    font-size: 10px !important;
}
html body .swal2-popup.swal2-toast .swal2-icon .swal2-icon-content { font-size: 16px !important; }
html body .swal2-popup.swal2-toast :is([class^='swal2-success-line'], [class^='swal2-x-mark-line']) {
    background: var(--otdx-toast-foreground) !important;
}
html body .swal2-popup.swal2-toast .swal2-success-ring { border-color: currentColor !important; }
html body .swal2-popup.swal2-toast :is(.swal2-success-fix, [class^='swal2-success-circular-line']) {
    background: var(--otdx-toast-background) !important;
}
html body .swal2-popup.swal2-toast.swal2-show { animation: otdx-toast-enter .3s ease !important; }
@keyframes otdx-toast-enter {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Progress widths/animations remain under each original timer's control. */
html body :is(.swal2-popup.swal2-toast .swal2-timer-progress-bar-container,
             .bookmark-toast-progress, .rf-toast-progress) {
    inset: auto 0 0 !important;
    height: 3px !important;
    border-radius: 0 !important;
}
html body :is(.swal2-popup.swal2-toast .swal2-timer-progress-bar,
             .bookmark-toast-progress, .rf-toast-progress::after) {
    background: var(--otdx-toast-progress) !important;
    height: 3px !important;
    border-radius: 0 !important;
}

/* Custom cards keep their existing content, close buttons and visibility states. */
html body :is(.bookmark-toast-content, .bookmark-toast-text, .rf-toast-message) {
    min-width: 0 !important;
    flex: 0 1 auto !important;
}
html body .bookmark-toast-content { gap: 10px !important; }
html body :is(.bookmark-toast-title, .bookmark-toast-subtitle, .rf-toast-message) {
    color: inherit !important;
    font: inherit !important;
    line-height: 1.4 !important;
    overflow-wrap: anywhere !important;
}
html body .bookmark-toast-title { margin: 0 !important; }
html body .bookmark-toast-subtitle { font-size: .8125rem !important; }
html body :is(.bookmark-toast-icon, .rf-toast-icon, .cw-toast-icon) {
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    color: var(--otdx-toast-foreground) !important;
    background: transparent !important;
    border-radius: 0 !important;
}
html body .bookmark-toast-icon.removed { opacity: .75; }
html body :is(.bookmark-toast-icon i, .cw-toast-icon) { font-size: 18px !important; }
html body .bookmark-toast,
html body .swal2-popup.swal2-toast:has(.swal2-close:not([style*='display: none'])) {
    padding-right: 56px !important;
    padding-left: 56px !important;
}
html body :is(.bookmark-toast-close, #toast-container .toast-close-button, .swal2-popup.swal2-toast .swal2-close) {
    position: absolute !important;
    inset: 12px 16px auto auto !important;
    width: 32px !important;
    height: 32px !important;
    border: 0 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    color: var(--otdx-toast-foreground) !important;
    background: transparent !important;
}
html body :is(.bookmark-toast-close, .swal2-popup.swal2-toast .swal2-close):hover {
    color: var(--otdx-toast-foreground) !important;
    background: rgba(255, 255, 255, .12) !important;
}
html body :is(.bookmark-toast-close, .swal2-popup.swal2-toast .swal2-close, #toast-container .toast-action):focus-visible {
    outline: 2px solid #fff !important;
    outline-offset: 2px !important;
}
html body #toast-container .toast :is(a, .toast-action) { color: #fff !important; }
html body #toast-container .toast .toast-action { margin-left: 10px !important; }
html body #toast-container .toast:has(.toast-close-button) { padding-inline: 56px !important; }
html body #toast-container .toast :is(.toast-title, .toast-message) { color: inherit !important; }

/* A modal's local feedback stays in its own footer/top layer. */
html body .fe-catalog-notice {
    background: var(--otdx-toast-background);
    color: var(--otdx-toast-foreground);
}
@media (prefers-reduced-motion: reduce) {
    html body :is(#toast-container, #rf-toast-container, .bis-tr-toast-host,
                 .otdx-toast, .bookmark-toast, .cw-toast, .rf-toast,
                 .swal2-container:has(> .swal2-toast)) { transition-duration: 0s !important; }
    html body .swal2-popup.swal2-toast.swal2-show { animation: none !important; }
}
