/* Sonner-inspired toast notifications */

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 99999;
    pointer-events: none;
    padding-left: env(safe-area-inset-left);
    padding-top: env(safe-area-inset-top);
}

.toast {
    pointer-events: auto;
    width: min(100vw - 1.5rem, 420px);
    background: hsl(var(--popover) / 0.96);
    color: hsl(var(--popover-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 8px);
    box-shadow: 0 22px 60px -24px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px);
    overflow: hidden;
    padding: 0.9rem 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transform: translateY(-12px) scale(0.98);
    opacity: 0;
    transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    min-width: 0;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.toast-icon svg {
    width: 1.05rem;
    height: 1.05rem;
    stroke-width: 2.25;
}

.toast-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.toast-message {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.toast-detail {
    font-size: 0.825rem;
    line-height: 1.45;
    color: hsl(var(--muted-foreground));
    word-break: break-word;
}

.toast-close {
    align-self: flex-start;
    margin-left: auto;
    background: transparent;
    border: 1px solid transparent;
    color: hsl(var(--muted-foreground));
    border-radius: 999px;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
    flex: 0 0 auto;
}

.toast-close:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    border-color: hsl(var(--border));
}

.toast-close svg {
    width: 0.9rem;
    height: 0.9rem;
}

.toast-progress {
    width: 100%;
    height: 0.25rem;
    border-radius: 999px;
    background: hsl(var(--muted) / 0.75);
    overflow: hidden;
}

.toast-progress-bar {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: hsl(var(--primary));
    transition: width 160ms ease;
}

.toast-success {
    border-color: hsl(var(--file-green) / 0.4);
}

.toast-success .toast-icon {
    background: hsl(var(--file-green) / 0.12);
    color: hsl(var(--file-green));
}

.toast-error {
    border-color: hsl(var(--destructive) / 0.45);
}

.toast-error .toast-icon {
    background: hsl(var(--destructive) / 0.12);
    color: hsl(var(--destructive));
}

.toast-warning {
    border-color: hsl(35 100% 50% / 0.42);
}

.toast-warning .toast-icon {
    background: hsl(35 100% 50% / 0.14);
    color: hsl(35 100% 50%);
}

.toast-loading {
    border-color: hsl(var(--primary) / 0.4);
}

.toast-loading .toast-icon {
    background: hsl(var(--primary) / 0.12);
    color: hsl(var(--primary));
}

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

.toast-info .toast-icon {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .toast-container {
        left: 0;
        right: 0;
        top: 0.75rem;
        padding: 0 0.75rem;
        align-items: center;
    }

    .toast {
        width: 100%;
    }
}
