/* ==========================================
   Toast Notifications
   ========================================== */

.toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 76px);
    right: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    z-index: var(--z-toast);
    width: min(360px, calc(100vw - 16px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
    padding: 7px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.18s ease;
    pointer-events: auto;
}

.toast.hiding {
    animation: toastOut 0.16s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.toast-icon svg {
    width: 16px;
    height: 16px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    display: block;
    font-size: var(--font-size-xs);
    line-height: 1.35;
    color: var(--text-main);
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toast-close[hidden] {
    display: none;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.toast-close svg {
    width: 12px;
    height: 12px;
}

/* Toast Types */
.toast-info {
    border-left: 3px solid var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-error {
    border-left: 3px solid var(--error);
}

.toast-error .toast-icon {
    color: var(--error);
}

/* Responsive */
@media (max-width: 480px) {
    .toast-container {
        top: calc(env(safe-area-inset-top, 0px) + 76px);
        bottom: auto;
        right: 8px;
        left: auto;
        width: min(320px, calc(100vw - 16px));
        align-items: flex-end;
    }

    .toast {
        width: fit-content;
        animation: toastInMobile 0.18s ease;
    }

    .toast.hiding {
        animation: toastOutMobile 0.16s ease forwards;
    }

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

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes toastOutMobile {
        from {
            opacity: 1;
            transform: translateY(0);
        }

        to {
            opacity: 0;
            transform: translateY(-8px);
        }
    }
}
