/**
 * Unified responsive toast system (overrides page-local toast CSS).
 * Desktop: top-right card. Mobile: full-width, safe-area aware.
 */
.portal-toast-host {
    position: fixed;
    z-index: 10050;
    top: max(16px, env(safe-area-inset-top, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    left: auto;
    width: min(420px, calc(100vw - 32px));
    max-width: min(420px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    box-sizing: border-box;
}

.portal-toast-host .toast-notification,
.toast-notification {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 14px 16px !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    border: 1px solid #E2EAF1 !important;
    box-shadow: 0 14px 32px rgba(11, 43, 68, 0.16) !important;
    pointer-events: auto;
    animation: portalToastIn 0.35s ease both !important;
}

/* Legacy toasts not yet moved into the host — desktop stays top-right */
body > .toast-notification {
    position: fixed !important;
    top: max(16px, env(safe-area-inset-top, 0px)) !important;
    right: max(16px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
    bottom: auto !important;
    width: min(420px, calc(100vw - 32px)) !important;
    max-width: min(420px, calc(100vw - 32px)) !important;
    z-index: 10050 !important;
}

.toast-notification.toast-hide {
    animation: portalToastOut 0.3s ease forwards !important;
}

.toast-notification .toast-icon,
.toast-icon {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.toast-notification .toast-content,
.toast-content {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: left !important;
}

.toast-notification .toast-title,
.toast-title {
    font-size: 14px !important;
    font-weight: 800 !important;
    margin-bottom: 2px !important;
    line-height: 1.3 !important;
}

.toast-notification .toast-message,
.toast-message {
    font-size: 13px !important;
    color: #475569 !important;
    line-height: 1.45 !important;
    word-break: break-word !important;
    padding-top: 0 !important;
}

.toast-notification .toast-close,
.toast-close {
    border: none !important;
    background: transparent !important;
    color: #94A3B8 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    padding: 2px !important;
    line-height: 1 !important;
}

.toast-success,
.toast-notification.toast-success { border-left: 4px solid #10B981 !important; }
.toast-success .toast-icon { background: #D1FAE5 !important; color: #059669 !important; }
.toast-success .toast-title { color: #065F46 !important; }

.toast-error,
.toast-danger,
.toast-notification.toast-error,
.toast-notification.toast-danger { border-left: 4px solid #EF4444 !important; }
.toast-error .toast-icon,
.toast-danger .toast-icon { background: #FEE2E2 !important; color: #DC2626 !important; }
.toast-error .toast-title,
.toast-danger .toast-title { color: #991B1B !important; }

.toast-warning,
.toast-notification.toast-warning { border-left: 4px solid #F59E0B !important; }
.toast-warning .toast-icon { background: #FEF3C7 !important; color: #D97706 !important; }
.toast-warning .toast-title { color: #92400E !important; }

.toast-info,
.toast-notification.toast-info { border-left: 4px solid #3B82F6 !important; }
.toast-info .toast-icon { background: #DBEAFE !important; color: #2563EB !important; }
.toast-info .toast-title { color: #1E40AF !important; }

@keyframes portalToastIn {
    from { opacity: 0; transform: translateY(-10px) translateX(8px); }
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

@keyframes portalToastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

@media (max-width: 768px) {
    .portal-toast-host {
        top: max(12px, calc(env(safe-area-inset-top, 0px) + 8px));
        left: max(12px, env(safe-area-inset-left, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        width: auto;
        max-width: none;
    }

    body > .toast-notification {
        top: max(12px, calc(env(safe-area-inset-top, 0px) + 8px)) !important;
        left: max(12px, env(safe-area-inset-left, 0px)) !important;
        right: max(12px, env(safe-area-inset-right, 0px)) !important;
        width: auto !important;
        max-width: none !important;
    }
}

@media (max-width: 480px) {
    .toast-notification {
        padding: 12px 14px !important;
        border-radius: 12px !important;
    }
    .toast-notification .toast-title,
    .toast-title { font-size: 13px !important; }
    .toast-notification .toast-message,
    .toast-message { font-size: 12.5px !important; }
}

@media (prefers-reduced-motion: reduce) {
    .toast-notification,
    .toast-notification.toast-hide {
        animation: none !important;
    }
}
