:root {
    --toast-width: 360px;
    --toast-border-radius: 16px;
    --toast-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
    --toast-text: #0f172a;
    --toast-muted: #64748b;

    --success-accent: #22c55e;
    --danger-accent: #ef4444;
    --primary-accent: #3b82f6;
    --warning-accent: #f59e0b;
    --info-accent: #06b6d4;
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* اجازه می‌ده کلیک‌ها از زیرش رد شن */
}

.custom-toast {
    width: min(var(--toast-width), calc(100vw - 24px));
    pointer-events: auto; /* قابلیت کلیک روی خود نوتیفیکیشن */
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--toast-border-radius);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.96), rgba(248,250,252,0.92));
    box-shadow: var(--toast-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--toast-text);
    transform: translateX(120%); /* شروع از بیرون صفحه */
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.custom-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.custom-toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

/* نوار رنگی سمت چپ */
.custom-toast::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0; /* سمت چپ */
    width: 5px;
    background: var(--accent-color, var(--primary-accent)); /* استفاده از متغیر رنگ */
}

/* کلاس‌های رنگی */
.custom-toast.success { --accent-color: var(--success-accent); }
.custom-toast.danger { --accent-color: var(--danger-accent); }
.custom-toast.primary { --accent-color: var(--primary-accent); }
.custom-toast.warning { --accent-color: var(--warning-accent); }
.custom-toast.info { --accent-color: var(--info-accent); }

.toast-content {
    padding: 14px 16px 12px 18px;
}

.toast-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.toast-icon-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.toast-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: var(--accent-color, var(--primary-accent));
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent-color) 35%, transparent);
}

.toast-texts {
    min-width: 0;
    flex: 1;
}

.toast-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
}

.toast-message {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: #334155;
    word-break: break-word;
}

.toast-close {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 24px; /* کمی بزرگتر */
    line-height: 1;
    padding: 4px 8px; /* فضای داخلی بیشتر */
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    margin-left: auto; /* فشار دادن به سمت چپ */
}

.toast-close:hover {
    background: rgba(148, 163, 184, 0.12);
    color: #0f172a;
    transform: scale(1.05);
}

.toast-meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--toast-muted);
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    transform-origin: right center; /* از راست به چپ کوچک شود */
    background: var(--accent-color, var(--primary-accent));
    transition: width 0.1s linear; /* انیمیشن کوتاه برای نرمی */
}

/* Responsive adjustments */
@media (max-width: 576px) {
    #toast-container {
        top: 12px;
        right: 12px;
        left: 12px; /* اجازه می‌ده پیام‌ها کل عرض رو بگیرن */
    }
    .custom-toast {
        width: 100%;
    }
    .toast-close {
        font-size: 20px; /* کمی کوچکتر برای موبایل */
        padding: 2px 6px;
    }
}
