﻿/* Unified Toast System - Apple/Google/Slack inspired */

.unified-toast-container {
    position: fixed;
    top: auto;
    right: max(var(--spacer, 1.25rem), env(safe-area-inset-right));
    bottom: max(var(--spacer, 1.25rem), env(safe-area-inset-bottom));
    left: auto;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.unified-toast {
    --toast-accent-rgb: 59, 130, 246;
    width: 380px;
    max-width: calc(100vw - 40px);
    position: relative;
    background:
        linear-gradient(0deg, rgba(var(--toast-accent-rgb), 0.08), rgba(var(--toast-accent-rgb), 0.08)),
        #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    box-shadow:
        0 20px 40px -20px rgba(15, 23, 42, 0.58),
        0 12px 24px -16px rgba(15, 23, 42, 0.36),
        0 4px 10px -6px rgba(15, 23, 42, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.75) inset;
    overflow: hidden;
    pointer-events: auto;
    transform: translateX(420px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .unified-toast::before {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: 4px;
        background: rgb(var(--toast-accent-rgb));
        border-radius: 16px 0 0 16px;
        pointer-events: none;
    }

    .unified-toast[data-severity="success"] {
        --toast-accent-rgb: 16, 185, 129;
    }

    .unified-toast[data-severity="error"] {
        --toast-accent-rgb: 239, 68, 68;
    }

    .unified-toast[data-severity="warning"] {
        --toast-accent-rgb: 245, 158, 11;
    }

    .unified-toast[data-severity="info"] {
        --toast-accent-rgb: 59, 130, 246;
    }

    .unified-toast.show {
        transform: translateX(0);
        opacity: 1;
    }

    .unified-toast.hide {
        transform: translateX(420px);
        opacity: 0;
    }

.unified-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    cursor: default;
}

.unified-toast-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.unified-toast-text {
    flex: 1;
    min-width: 0;
}

.unified-toast-message {
    font-size: 14px;
    color: #111827;
    line-height: 1.5;
    margin-bottom: 4px;
    font-weight: 500;
}

.unified-toast-details {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.45;
    margin-top: 2px;
}

.unified-toast-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.unified-toast-action {
    appearance: none;
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
}

.unified-toast-action.is-link {
    color: #2563eb;
}

.unified-toast-action.is-link:hover {
    background: #eff6ff;
}

.unified-toast-action.is-primary {
    color: #ffffff;
    background: #2563eb;
}

.unified-toast-action.is-primary:hover {
    background: #1d4ed8;
}

.unified-toast-action.is-danger {
    color: #b91c1c;
    background: #fee2e2;
}

.unified-toast-action.is-danger:hover {
    background: #fecaca;
}

.unified-toast-message .parlai-wordmark {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    letter-spacing: 0.01em;
    font-weight: 600;
}

.unified-toast-message .parlai-wordmark sup {
    font-size: 0.64em;
    line-height: 1;
    vertical-align: text-top;
    position: relative;
    top: -0.18em;
    font-weight: 700;
}

.unified-toast-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    margin-top: 6px;
}

    .unified-toast-count .count-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background: #ef4444;
        color: white;
        border-radius: 10px;
        font-size: 11px;
        font-weight: 600;
    }

.unified-toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: -4px;
    margin-right: -4px;
}

    .unified-toast-close:hover {
        background: #f3f4f6;
        color: #374151;
    }

    .unified-toast-close i {
        font-size: 16px;
    }

.unified-toast-progress {
    height: 3px;
    width: 100%;
    transition: width 5000ms linear;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .unified-toast-container {
        top: auto;
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        right: 0.75rem;
        left: 0.75rem;
    }

    .unified-toast {
        width: auto;
        max-width: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .unified-toast {
        background:
            linear-gradient(0deg, rgba(var(--toast-accent-rgb), 0.2), rgba(var(--toast-accent-rgb), 0.16)),
            #1f2937;
        border: 1px solid rgba(148, 163, 184, 0.28);
        box-shadow:
            0 24px 48px -18px rgba(0, 0, 0, 0.86),
            0 14px 26px -14px rgba(0, 0, 0, 0.68),
            0 4px 12px -8px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    }

    .unified-toast-message {
        color: #f9fafb;
    }

    .unified-toast-details {
        color: #cbd5e1;
    }

    .unified-toast-count {
        color: #9ca3af;
    }

    .unified-toast-close {
        color: #6b7280;
    }

        .unified-toast-close:hover {
            background: #374151;
            color: #d1d5db;
        }

    .unified-toast-action.is-link {
        color: #93c5fd;
    }

    .unified-toast-action.is-link:hover {
        background: rgba(59, 130, 246, 0.18);
    }

    .unified-toast-action.is-primary {
        background: #3b82f6;
        color: #f8fafc;
    }

    .unified-toast-action.is-primary:hover {
        background: #2563eb;
    }

    .unified-toast-action.is-danger {
        background: rgba(239, 68, 68, 0.25);
        color: #fecaca;
    }

    .unified-toast-action.is-danger:hover {
        background: rgba(239, 68, 68, 0.35);
    }
}

/* Animation for stacking effect */
.unified-toast:nth-child(2) {
    margin-top: -4px;
}

.unified-toast:nth-child(3) {
    margin-top: -8px;
}

.unified-toast:nth-child(4) {
    margin-top: -12px;
}

.unified-toast:nth-child(5) {
    margin-top: -16px;
}

/* Ensure toasts don't interfere with other UI elements */
.unified-toast-container * {
    box-sizing: border-box;
}

/* Remove conflicting Bootstrap toast styles if present */
#toast-container.position-fixed {
    position: fixed !important;
    top: auto !important;
    right: max(var(--spacer, 1.25rem), env(safe-area-inset-right)) !important;
    bottom: max(var(--spacer, 1.25rem), env(safe-area-inset-bottom)) !important;
    left: auto !important;
}

/* Hide old Bootstrap toasts */
.toast.align-items-center {
    display: none !important;
}
