/*
 * Global toasts: bottom-right, or top-right (.fg-toasts--top: the admin and member layouts) below their ~70px top bar.
 * Markup: resources/views/app/partials/toasts.blade.php; behaviour: public/assets/js/toast.js.
 */

.fg-toasts {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1090; /* above Bootstrap modals (1055) */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.fg-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 12px 14px 16px;
    border: 0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(11, 47, 44, .16);
    color: #0b2f2c;
    font-family: var(--fg-font, sans-serif);
    pointer-events: auto;
    animation: fg-toast-in .2s ease-out;
}

.fg-toast.is-leaving {
    animation: fg-toast-out .15s ease-in forwards;
}

.fg-toast__icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.fg-toast__message {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.fg-toast__close {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: -4px 0 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.fg-toast__close:hover,
.fg-toast__close:focus-visible {
    background: #f3f4f6;
    color: #0b2f2c;
}

.fg-toast__close:focus-visible {
    outline: 2px solid #0b2f2c;
    outline-offset: 1px;
}

.fg-toast--success .fg-toast__icon {
    color: #00a63e;
}

.fg-toast--error .fg-toast__icon {
    color: #e7000b;
}

.fg-toast--warning .fg-toast__icon {
    color: #d08700;
}

.fg-toast--info .fg-toast__icon {
    color: #00786f;
}

/* Dark mode */
[data-theme="dark"] .fg-toast {
    background: #1e2939;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color: #f3f4f6;
}

[data-theme="dark"] .fg-toast__close {
    color: #99a1af;
}

[data-theme="dark"] .fg-toast__close:hover,
[data-theme="dark"] .fg-toast__close:focus-visible {
    background: #364153;
    color: #f3f4f6;
}

[data-theme="dark"] .fg-toast__close:focus-visible {
    outline-color: #cbfbf1;
}

[data-theme="dark"] .fg-toast--success .fg-toast__icon {
    color: #05df72;
}

[data-theme="dark"] .fg-toast--error .fg-toast__icon {
    color: #ff6467;
}

[data-theme="dark"] .fg-toast--warning .fg-toast__icon {
    color: #fdc700;
}

[data-theme="dark"] .fg-toast--info .fg-toast__icon {
    color: #46ecd5;
}

@keyframes fg-toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes fg-toast-out {
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* Top-right: the newest on top, coming in from above. */
.fg-toasts--top {
    top: 86px;
    bottom: auto;
    flex-direction: column-reverse;
    justify-content: flex-end;
}

.fg-toasts--top .fg-toast {
    animation-name: fg-toast-in-top;
}

.fg-toasts--top .fg-toast.is-leaving {
    animation-name: fg-toast-out-top;
}

@keyframes fg-toast-in-top {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes fg-toast-out-top {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (max-width: 575.98px) {
    .fg-toasts {
        right: 16px;
        bottom: 16px;
        left: 16px;
        width: auto;
    }

    .fg-toasts--top {
        top: 82px;
        bottom: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fg-toast,
    .fg-toast.is-leaving,
    .fg-toasts--top .fg-toast,
    .fg-toasts--top .fg-toast.is-leaving {
        animation: none;
    }
}
