/* ============================================================
   APP TOAST — CORE
   Notificações modernas e reutilizáveis
============================================================ */

.app-toast-container {
    position: fixed;
    top: 18px;
    right: 18px;

    width: min(
        390px,
        calc(100vw - 32px)
    );

    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;

    pointer-events: none;

    z-index: 20000;
}


/* ============================================================
   TOAST
============================================================ */

.app-toast {
    --app-toast-accent: #3b82f6;
    --app-toast-soft: #eff6ff;
    --app-toast-border: #dbeafe;
    --app-toast-duration: 5000ms;

    position: relative;

    width: 100%;

    background:
        rgba(255, 255, 255, 0.97);

    border:
        1px solid
        rgba(226, 232, 240, 0.92);

    border-radius: 16px;

    box-shadow:
        0 18px 45px
        rgba(15, 23, 42, 0.13),
        0 4px 12px
        rgba(15, 23, 42, 0.06);

    overflow: hidden;

    opacity: 0;

    transform:
        translate3d(
            26px,
            -4px,
            0
        )
        scale(0.98);

    transition:
        opacity 220ms ease,
        transform 260ms
        cubic-bezier(
            0.22,
            1,
            0.36,
            1
        );

    pointer-events: auto;

    backdrop-filter:
        blur(14px);

    -webkit-backdrop-filter:
        blur(14px);

    will-change:
        opacity,
        transform;
}

.app-toast--visible {
    opacity: 1;

    transform:
        translate3d(
            0,
            0,
            0
        )
        scale(1);
}

.app-toast--leaving {
    opacity: 0;

    transform:
        translate3d(
            18px,
            -8px,
            0
        )
        scale(0.98);
}


/* ============================================================
   SUPERFÍCIE INTERNA
============================================================ */

.app-toast__surface {
    position: relative;

    min-height: 76px;

    display: grid;

    grid-template-columns:
        42px
        minmax(0, 1fr)
        30px;

    align-items: center;

    gap: 13px;

    padding:
        14px
        13px
        14px
        14px;
}


/* ============================================================
   ÍCONE
============================================================ */

.app-toast__icon {
    width: 42px;
    height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    color:
        var(--app-toast-accent);

    background:
        var(--app-toast-soft);

    border:
        1px solid
        var(--app-toast-border);

    border-radius: 13px;

    font-size: 15px;

    box-shadow:
        inset 0 1px 0
        rgba(255, 255, 255, 0.65);
}


/* ============================================================
   CONTEÚDO
============================================================ */

.app-toast__content {
    min-width: 0;
}

.app-toast__title {
    margin: 0;

    color: #111827;

    font-size: 0.91rem;
    font-weight: 750;
    line-height: 1.3;

    letter-spacing: -0.01em;
}

.app-toast__message {
    margin-top: 4px;

    color: #64748b;

    font-size: 0.79rem;
    font-weight: 500;
    line-height: 1.45;

    overflow-wrap: anywhere;
}


/* ============================================================
   BOTÃO FECHAR
============================================================ */

.app-toast__close {
    width: 30px;
    height: 30px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    align-self: start;

    margin-top: 0;

    padding: 0;

    color: #94a3b8;

    background: transparent;

    border: 0;
    border-radius: 9px;

    cursor: pointer;

    transition:
        color 160ms ease,
        background-color 160ms ease,
        transform 160ms ease;
}

.app-toast__close:hover {
    color: #334155;
    background: #f1f5f9;
}

.app-toast__close:active {
    transform: scale(0.93);
}

.app-toast__close:focus-visible {
    outline:
        3px solid
        rgba(59, 130, 246, 0.22);

    outline-offset: 1px;
}


/* ============================================================
   AÇÃO OPCIONAL
============================================================ */

.app-toast__action {
    margin-top: 8px;

    padding: 0;

    color:
        var(--app-toast-accent);

    background: transparent;

    border: 0;

    font-size: 0.78rem;
    font-weight: 750;

    cursor: pointer;
}

.app-toast__action:hover {
    text-decoration: underline;
}


/* ============================================================
   BARRA DE PROGRESSO
============================================================ */

.app-toast__progress {
    position: absolute;

    right: 0;
    bottom: 0;
    left: 0;

    height: 3px;

    background:
        rgba(148, 163, 184, 0.12);

    overflow: hidden;
}

.app-toast__progress span {
    display: block;

    width: 100%;
    height: 100%;

    background:
        var(--app-toast-accent);

    transform-origin: left center;

    animation:
        app-toast-progress
        var(--app-toast-duration)
        linear forwards;
}

.app-toast--paused
.app-toast__progress span {
    animation-play-state: paused;
}

@keyframes app-toast-progress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}


/* ============================================================
   TIPOS
============================================================ */

.app-toast--success {
    --app-toast-accent: #16a34a;
    --app-toast-soft: #ecfdf3;
    --app-toast-border: #bbf7d0;
}

.app-toast--error {
    --app-toast-accent: #dc2626;
    --app-toast-soft: #fef2f2;
    --app-toast-border: #fecaca;
}

.app-toast--warning {
    --app-toast-accent: #d97706;
    --app-toast-soft: #fffbeb;
    --app-toast-border: #fde68a;
}

.app-toast--info {
    --app-toast-accent: #2563eb;
    --app-toast-soft: #eff6ff;
    --app-toast-border: #bfdbfe;
}


/* ============================================================
   TEMA ESCURO
============================================================ */

[data-theme="dark"]
.app-toast,
body.dark-mode
.app-toast,
body.theme-dark
.app-toast {
    background:
        rgba(17, 24, 39, 0.96);

    border-color:
        rgba(71, 85, 105, 0.72);

    box-shadow:
        0 20px 50px
        rgba(0, 0, 0, 0.38),
        0 5px 14px
        rgba(0, 0, 0, 0.22);
}

[data-theme="dark"]
.app-toast__title,
body.dark-mode
.app-toast__title,
body.theme-dark
.app-toast__title {
    color: #f8fafc;
}

[data-theme="dark"]
.app-toast__message,
body.dark-mode
.app-toast__message,
body.theme-dark
.app-toast__message {
    color: #94a3b8;
}

[data-theme="dark"]
.app-toast__close:hover,
body.dark-mode
.app-toast__close:hover,
body.theme-dark
.app-toast__close:hover {
    color: #e2e8f0;
    background:
        rgba(148, 163, 184, 0.13);
}


/* ============================================================
   RESPONSIVO
============================================================ */

@media (
    max-width: 576px
) {
    .app-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;

        width: auto;
    }

    .app-toast__surface {
        min-height: 70px;

        grid-template-columns:
            38px
            minmax(0, 1fr)
            28px;

        gap: 11px;

        padding:
            12px
            11px
            12px
            12px;
    }

    .app-toast__icon {
        width: 38px;
        height: 38px;

        border-radius: 12px;
    }

    .app-toast__title {
        font-size: 0.88rem;
    }

    .app-toast__message {
        font-size: 0.77rem;
    }
}


/* ============================================================
   ACESSIBILIDADE
============================================================ */

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

    .app-toast__progress span {
        animation: none;
    }
}