/* Toast Notification System */
/* Toast Container - Strict Top Right Positioning */
.toast-container {
    position: fixed;
    top: max(20px, env(safe-area-inset-top)) !important;
    right: max(20px, env(safe-area-inset-right)) !important;
    z-index: 2147483647 !important;
    /* Max Z-Index */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    width: min(420px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    /* Safe width */
    align-items: flex-end;
}

/* Toast Notification Card */
.toast-container .toast {
    /* Glassmorphism & Premium Dark Theme */
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 2px 10px rgba(0, 0, 0, 0.3);

    border-radius: 12px;
    padding: 16px 20px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    /* Fill container width */

    display: flex;
    align-items: center;
    gap: 16px;

    color: #ffffff;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;

    pointer-events: auto;
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    animation: none;
    overflow: hidden;

    /* Default Animation State: Vertical Slide only */
    opacity: 0;
    transform: translateY(-20px);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

/* Accent Borders (Left Indicator) */
.toast-container .toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--toast-color, #3b82f6);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .toast-container {
        top: auto !important;
        bottom: max(20px, env(safe-area-inset-bottom)) !important;
        right: max(10px, env(safe-area-inset-right)) !important;
        left: max(10px, env(safe-area-inset-left)) !important;
        max-width: none;
        width: auto;
        align-items: center;
    }

    .toast-container .toast {
        width: 100%;
        transform: translateY(20px);
        /* Up from bottom */
    }
}

/* Animation Checkpoints */
.toast-container .toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-container .toast.hiding {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    pointer-events: none;
}

@media (max-width: 480px) {
    .toast-container .toast.hiding {
        transform: translateY(20px) scale(0.95);
    }
}

/* Type-specific Colors */
.toast-container .toast.success {
    --toast-color: #10b981;
}

.toast-container .toast.error {
    --toast-color: #ef4444;
}

.toast-container .toast.warning {
    --toast-color: #f59e0b;
}

.toast-container .toast.info {
    --toast-color: #3b82f6;
}

/* Content Layout */
.toast-container .toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--toast-color);
    filter: drop-shadow(0 0 8px rgba(var(--toast-color), 0.4));
}

.toast-container .toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.toast-container .toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    color: #fff;
    letter-spacing: -0.01em;
}

.toast-container .toast-message {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

/* Progress-bar at bottom */
.toast-container .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
}

.toast-container .toast-progress-bar {
    height: 100%;
    background: var(--toast-color);
    width: 0%;
    /* JS will animate width from 100% to 0% */
    transition: width linear;
}

/* Close Button */
.toast-container .toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    margin: -4px -4px 0 0;
    transition: color 0.2s;
    font-size: 16px;
    line-height: 1;
}

.toast-container .toast-close:hover {
    color: var(--text-primary);
}

/* Progress Bar */
.toast-container .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    width: 100%;
}

.toast-container .toast-progress-bar {
    height: 100%;
    background: currentColor;
    /* Inherits from border color via JS or specific class logic */
    width: 100%;
    transform-origin: left;
    animation: toast-progress linear forwards;
}

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

    to {
        transform: scaleX(0);
    }
}
