/**
 * FinPal Toast Notification Component
 *
 * Temporary notifications for user actions and feedback.
 * Slides in from top, auto-dismisses, with type variants.
 *
 * Usage (via JavaScript):
 * showToast('Your plan has been updated!', 'success', 4000);
 * showToast('Please check your email', 'info', 3000);
 * showToast('Something went wrong', 'warning', 5000);
 *
 * Types: success, info, warning
 * (NO ERROR TYPE - we never use red!)
 */

/* Toast container - holds all active toasts */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
    max-width: 420px;
}

/* Individual toast */
.toast {
    position: relative;
    background: linear-gradient(
        135deg,
        rgba(168, 85, 247, 0.12) 0%,
        rgba(147, 51, 234, 0.08) 100%
    );
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1.5px solid rgba(168, 85, 247, 0.3);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    pointer-events: auto;
    cursor: default;
    overflow: hidden;

    /* Animation */
    animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: top right;
}

@keyframes toastSlideIn {
    0% {
        transform: translateX(120%) scale(0.9);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Exit animation */
.toast.toast-exit {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toastSlideOut {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(120%) scale(0.9);
        opacity: 0;
    }
}

/* Toast icon */
.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 0.75rem;
    font-size: 1.125rem;
    vertical-align: middle;
}

/* Toast content (title + description layout) - Always rich */
.toast {
    padding: 1rem 3rem 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.toast-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    line-height: 1.3;
    margin: 0;
}

.toast-description {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.4;
    margin: 0;
}

.toast .toast-icon {
    margin-right: 0;
    margin-top: 0.125rem;
}

/* Close button */
.toast-close {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.6;
}

.toast-close:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
    color: var(--text-primary, #ffffff);
}

/* Progress bar (auto-dismiss indicator) */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--purple-500, #a855f7), var(--purple-600, #9333ea));
    border-radius: 0 0 15px 15px;
    transform-origin: left;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    0% {
        width: 100%;
    }
    100% {
        width: 0%;
    }
}

/* ===== TYPE VARIANTS ===== */

/* Success - Green */
.toast.toast-success {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(
        135deg,
        rgba(16, 185, 129, 0.12) 0%,
        rgba(5, 150, 105, 0.08) 100%
    );
}

.toast.toast-success .toast-icon {
    color: var(--success, #10b981);
}

.toast.toast-success .toast-progress {
    background: linear-gradient(90deg, #10b981, #059669);
}

/* Info - Purple (default) */
.toast.toast-info {
    border-color: rgba(168, 85, 247, 0.3);
    background: linear-gradient(
        135deg,
        rgba(168, 85, 247, 0.12) 0%,
        rgba(147, 51, 234, 0.08) 100%
    );
}

.toast.toast-info .toast-icon {
    color: var(--purple-400, #c084fc);
}

.toast.toast-info .toast-progress {
    background: linear-gradient(90deg, var(--purple-500, #a855f7), var(--purple-600, #9333ea));
}

/* Warning - Orange/Amber */
.toast.toast-warning {
    border-color: rgba(251, 146, 60, 0.3);
    background: linear-gradient(
        135deg,
        rgba(251, 146, 60, 0.12) 0%,
        rgba(245, 158, 11, 0.08) 100%
    );
}

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

.toast.toast-warning .toast-progress {
    background: linear-gradient(90deg, #fb923c, #f59e0b);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .toast {
        padding: 0.875rem 1rem;
        padding-right: 2.75rem;
    }

    .toast-message {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .toast-container {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        padding: 0.875rem 2.5rem 0.625rem 0.875rem;
        border-radius: 12px;
        gap: 0.625rem;
    }

    .toast-icon {
        width: 20px;
        height: 20px;
        font-size: 1rem;
    }

    .toast-title {
        font-size: 0.875rem;
    }

    .toast-description {
        font-size: 0.75rem;
    }

    .toast-close {
        right: 0.75rem;
        font-size: 1.25rem;
    }
}
