/**
 * Global toast messages (Influencer.AI design system)
 * Source: Toast_Messages.html
 *
 * Alerts and status only:
 *   .toast-stack > .toast.t-{success|info|pending|revision|warning|error}
 *   .optin-toast-host > .optin-toast.optin-toast--{success|info|warning|error}
 *
 * Confirmation dialogs are a separate modal (see the block at the end of this file).
 * They are not toasts. Colour:
 *   danger  red    — delete, remove, deactivate, reject, discard, reset (focus starts on Cancel)
 *   primary orange — add, create, duplicate, upload, send, save, log out
 *   success green  — mark live, approve, verify, activate
 */

:root {
    --iai-toast-orange: #FF6B00;
    --iai-toast-orange-hover: #C85A0C;
    --iai-toast-black: #0D0D0D;
    --iai-toast-white: #FFFFFF;
    --iai-toast-slate: #4A5759;
    --iai-toast-warm: #E7E2DA;
    --iai-toast-g50: #F9F9F9;
    --iai-toast-g100: #F1F1F1;
    --iai-toast-g300: #CCCCCC;
    --iai-toast-g500: #808080;
    --iai-toast-g700: #606060;
    --iai-toast-yellow: #FFBE06;
    --iai-toast-aqua: #80DED9;
    --iai-toast-pink: #FF7B9C;
    --iai-toast-purple: #894CD4;
    --iai-toast-positive: #6CC34C;
    --iai-toast-negative: #A71515;
    --iai-toast-warning-ink: #C98F00;
    --iai-toast-btn-dark: #333333;
    --iai-toast-font: 'Barlow', system-ui, sans-serif;
}

/* ===== Design-system toast stack ===== */
.toast-stack {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
    pointer-events: none;
}

.toast-stack:focus {
    outline: none;
}

.toast-stack .toast,
.toast-stack > .toast {
    pointer-events: auto;
    width: 100%;
    max-width: 560px;
    background: var(--iai-toast-white);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 14px 34px rgba(0, 0, 0, 0.2);
    --accent: var(--iai-toast-positive);
    --icon: var(--iai-toast-positive);
    font-family: var(--iai-toast-font);
    animation: iai-toastIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.toast-stack .toast.leaving {
    animation: iai-toastOut 0.15s ease both;
}

.toast-stack .toast.t-success {
    --accent: var(--iai-toast-positive);
    --icon: var(--iai-toast-positive);
}

.toast-stack .toast.t-info {
    --accent: var(--iai-toast-aqua);
    --icon: var(--iai-toast-slate);
}

.toast-stack .toast.t-pending {
    --accent: var(--iai-toast-orange);
    --icon: var(--iai-toast-orange);
}

.toast-stack .toast.t-revision {
    --accent: var(--iai-toast-purple);
    --icon: var(--iai-toast-purple);
}

.toast-stack .toast.t-warning {
    --accent: var(--iai-toast-yellow);
    --icon: var(--iai-toast-warning-ink);
}

.toast-stack .toast.t-error {
    --accent: var(--iai-toast-negative);
    --icon: var(--iai-toast-negative);
}

.toast-stack .t-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--iai-toast-g50);
    border-bottom: 1px solid var(--iai-toast-g100);
    padding: 6px 8px 6px 16px;
}

.toast-stack .t-band .h6,
.toast-stack .t-band__label {
    color: var(--iai-toast-g500);
    font-weight: 500;
    font-size: 0.8125rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
}

.toast-stack .t-x {
    width: 32px;
    height: 32px;
    border: 0;
    background: none;
    color: var(--iai-toast-g500);
    cursor: pointer;
    display: grid;
    place-items: center;
    border-radius: 2px;
    padding: 0;
}

.toast-stack .t-x:hover {
    color: var(--iai-toast-black);
    background: var(--iai-toast-g100);
}

.toast-stack .t-x:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--iai-toast-orange);
}

.toast-stack .t-x svg {
    width: 18px;
    height: 18px;
    display: block;
}

.toast-stack .t-main {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 16px;
}

.toast-stack .t-icon {
    color: var(--icon);
    flex: 0 0 auto;
}

.toast-stack .t-icon svg {
    width: 32px;
    height: 32px;
    display: block;
    flex-shrink: 0;
}

.toast-stack .t-text {
    flex: 1;
    min-width: 0;
}

.toast-stack .t-text .h5,
.toast-stack .t-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    color: var(--iai-toast-black);
    margin: 0;
}

.toast-stack .t-msg,
.toast-stack .sub.t-msg {
    color: var(--iai-toast-g700);
    margin-top: 4px;
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.35;
}

.toast-stack .t-progress {
    height: 3px;
    background: var(--accent);
    transform-origin: left;
}

.toast-stack .t-sticky {
    height: 3px;
    background: var(--accent);
}

/* Action button inside toast (scoped so it does not clash with Bootstrap .btn) */
.toast-stack .toast .btn,
.toast-stack .t-action {
    height: 40px;
    padding: 0 22px;
    border: 0;
    border-radius: 2px;
    font: 500 0.875rem/1 var(--iai-toast-font);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    flex: 0 0 auto;
}

.toast-stack .toast .btn-dark,
.toast-stack .t-action {
    background: var(--iai-toast-btn-dark);
    color: #fff;
}

.toast-stack .toast .btn-dark:hover,
.toast-stack .t-action:hover {
    background: var(--iai-toast-black);
    color: var(--iai-toast-orange);
}

.toast-stack .toast .btn:focus-visible,
.toast-stack .t-action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--iai-toast-orange);
}

@keyframes iai-toastIn {
    from {
        opacity: 0;
        transform: translateY(-14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes iai-toastOut {
    from {
        opacity: 1;
        transform: none;
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes iai-toastShrink {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Alias used by Toast_Messages.html */
@keyframes shrink {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@media (max-width: 520px) {
    .toast-stack .t-main {
        flex-wrap: wrap;
    }

    .toast-stack .t-main .btn,
    .toast-stack .t-main .t-action {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast-stack .toast,
    .toast-stack .toast.leaving {
        animation-duration: 0.01ms;
    }

    .toast-stack .t-progress {
        display: none;
    }
}

/* ===== Legacy opt-in toast (global; matches design tokens) ===== */
/* Mobile default: centered top, compact */
.optin-toast-host {
    position: fixed;
    top: 10px;
    left: 50%;
    right: auto;
    width: min(320px, calc(100% - 24px));
    max-width: min(320px, calc(100% - 24px));
    margin: 0;
    transform: translateX(-50%);
    /* Above template modals (.ctpl-screen is 10000) and TinyMCE aux (10050) */
    z-index: 12000;
    pointer-events: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

/* Desktop: top-right, compact card */
@media (min-width: 768px) {
    .optin-toast-host {
        left: auto;
        right: 16px;
        top: 16px;
        width: 320px;
        max-width: calc(100vw - 32px);
        transform: none;
    }
}

.optin-toast {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    background: var(--iai-toast-white);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 10px 24px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    font-family: var(--iai-toast-font);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
}

.optin-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.optin-toast.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
}

.optin-toast__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 4px 12px;
    border-bottom: 1px solid var(--iai-toast-g100);
    background: var(--iai-toast-g50);
}

.optin-toast__label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--iai-toast-g500);
    text-transform: uppercase;
    line-height: 1.2;
}

.optin-toast__close {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--iai-toast-g500);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: grid;
    place-items: center;
    border-radius: 2px;
}

.optin-toast__close:hover {
    color: var(--iai-toast-black);
    background: var(--iai-toast-g100);
}

.optin-toast__body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 12px;
}

.optin-toast__icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.optin-toast--error .optin-toast__icon {
    background: var(--iai-toast-negative);
}

.optin-toast--success .optin-toast__icon {
    background: var(--iai-toast-positive);
}

.optin-toast--warning .optin-toast__icon {
    background: transparent;
    color: var(--iai-toast-warning-ink);
    font-size: 22px;
    width: 24px;
    height: 24px;
}

.optin-toast--info .optin-toast__icon {
    background: var(--iai-toast-slate);
}

.optin-toast__text {
    flex: 1 1 auto;
    min-width: 0;
}

.optin-toast__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--iai-toast-black);
    line-height: 1.25;
    margin: 0;
}

.optin-toast__msg {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    color: var(--iai-toast-g700);
    line-height: 1.35;
}

.optin-toast__action {
    flex: 0 0 auto;
    border: 0;
    border-radius: 2px;
    background: var(--iai-toast-btn-dark);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--iai-toast-font);
    height: 32px;
    padding: 0 12px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.optin-toast__action:hover {
    background: var(--iai-toast-black);
    color: var(--iai-toast-orange);
}

.optin-toast__progress {
    height: 2px;
    background: transparent;
    width: 100%;
}

.optin-toast__progress-bar {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(1);
    transition: transform linear;
}

.optin-toast__progress-bar.is-running {
    transform: scaleX(0);
}

.optin-toast--error .optin-toast__progress-bar {
    background: var(--iai-toast-negative);
}

.optin-toast--success .optin-toast__progress-bar {
    background: var(--iai-toast-positive);
}

.optin-toast--warning .optin-toast__progress-bar {
    background: var(--iai-toast-yellow);
}

.optin-toast--info .optin-toast__progress-bar {
    background: var(--iai-toast-aqua);
}

@media (max-width: 520px) {
    .optin-toast__body {
        flex-wrap: wrap;
    }

    .optin-toast__action {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .optin-toast {
        transition: none;
    }

    .optin-toast__progress {
        display: none;
    }
}

/* ===== Confirmation dialogs (modal only — alerts and status stay toasts) ===== */
.iai-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 13000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
    animation: iai-confirm-fade 0.15s ease-out;
}

.iai-confirm {
    --iai-c: #FF6B00;
    --iai-bg: #FFF1E6;
    --iai-h: #ca5710;
    width: 480px;
    max-width: 100%;
    background: #fff;
    color: #1E1E1E;
    border-radius: 4px;
    border-bottom: 4px solid var(--iai-c);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    font-family: "Barlow", sans-serif;
    animation: iai-confirm-pop 0.18s ease-out;
    box-sizing: border-box;
}

.iai-confirm[data-tone="danger"] {
    --iai-c: #A71515;
    --iai-bg: #F8E4E4;
    --iai-h: #A71515;
}

.iai-confirm[data-tone="primary"] {
    --iai-c: #FF6B00;
    --iai-bg: #FFF1E6;
    --iai-h: #ca5710;
}

.iai-confirm[data-tone="success"] {
    --iai-c: #6CC34C;
    --iai-bg: #EAF7E3;
    --iai-h: #5AAD3C;
}

.iai-confirm__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 18px 24px;
    border-bottom: 1px solid #E9E9E9;
}

.iai-confirm__icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 2px !important;
    background: var(--iai-c);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
}

.iai-confirm__icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.iai-confirm__label {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #7A7A7A;
    line-height: 1.2;
}

.iai-confirm__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin: 0;
    border: 0;
    background: transparent;
    color: #1E1E1E;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    border-radius: 2px;
    display: grid;
    place-items: center;
}

.iai-confirm__close:hover {
    background: #F3F3F3;
}

.iai-confirm__body {
    padding: 22px 24px 6px;
}

.iai-confirm__title {
    margin: 0 0 6px;
    padding: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    color: #1E1E1E;
    font-family: "Barlow", sans-serif !important;
}

.iai-confirm__msg {
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: #5F5F5F;
}

.iai-confirm__field {
    display: block;
    margin: 16px 0 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: 0;
    color: #3C3C3C;
}

.iai-confirm__input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0 0;
    border: 1px solid #DADADA;
    border-radius: 4px;
    padding: 10px 12px;
    font: 400 14px/1.4 "Barlow", sans-serif;
    color: #1E1E1E;
    background: #fff;
    box-shadow: none;
}

textarea.iai-confirm__input {
    min-height: 88px;
    resize: vertical;
}

.iai-confirm__input:focus {
    outline: none;
    border-color: #FF6B00;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.15);
}

.iai-confirm__input.is-invalid {
    border-color: #A71515;
}

.iai-confirm__error {
    display: none;
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.3;
    color: #A71515;
}

.iai-confirm__error.is-on {
    display: block;
}

.iai-confirm__foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 22px;
}

.iai-confirm__btn {
    appearance: none;
    -webkit-appearance: none;
    height: 32px;
    min-height: 32px;
    min-width: 96px;
    margin: 0;
    padding: 0 14px;
    border-radius: 2px;
    font-family: "Barlow", sans-serif;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    box-sizing: border-box;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.iai-confirm__btn--cancel {
    background: #fff;
    border-color: #CFCFCF;
    color: #1E1E1E;
}

.iai-confirm__btn--cancel:hover {
    background: #F3F3F3;
    color: #1E1E1E;
}

.iai-confirm__btn--ok {
    background: var(--iai-c);
    border-color: var(--iai-c);
    color: #fff;
}

.iai-confirm__btn--ok:hover {
    background: var(--iai-h);
    border-color: var(--iai-h);
    color: #fff;
}

.iai-confirm__btn:focus,
.iai-confirm__close:focus {
    outline: none;
}

.iai-confirm__btn:focus-visible,
.iai-confirm__close:focus-visible {
    outline: 2px solid var(--iai-c);
    outline-offset: 2px;
}

@keyframes iai-confirm-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes iai-confirm-pop {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 620px) {
    .iai-confirm__foot {
        flex-direction: column-reverse;
    }

    .iai-confirm__btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .iai-confirm-overlay,
    .iai-confirm {
        animation: none;
    }
}
