/* ════════════════════════════════════════════════════════════════
   FS Toast Notifications System
   ─────────────────────────────────────────────────────────────
   ▸ 4 أنواع: success / error / warning / info
   ▸ Position: top-center (mobile) | top-right (desktop)
   ▸ Stack: max 3 toasts
   ▸ Auto-dismiss: 4s default + progress bar
   ▸ Swipe to dismiss: up (mobile) / right (desktop)
   ▸ RTL-aware
   ════════════════════════════════════════════════════════════════ */

/* ═══ Container ═══ */
#fs-toast-container {
    position: fixed;
    top: 20px;
    inset-inline-end: 20px;       /* RTL: left | LTR: right */
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;          /* الـ container شفاف للـ clicks */
    width: 380px;                  /* أعرض شوية على الديسكتوب */
    max-width: calc(100vw - 40px);
}

/* ═══ تابلت متوسط (769px - 1023px) — top-right لكن أصغر ═══ */
@media (min-width: 769px) and (max-width: 1023px) {
    #fs-toast-container {
        width: 340px;
        top: 16px;
        inset-inline-end: 16px;
    }
}

/* ═══ على الموبايل — top-center ═══ */
@media (max-width: 768px) {
    /* تحت بدل فوق: فوق كانت بتغطى الهيدر كله (المنيو والأزرار) لحد ما تتقفل؛
       تحت فوق شريط التنقل زى تنبيهات تطبيقات الموبيل */
    #fs-toast-container {
        top: auto;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        flex-direction: column-reverse;
        inset-inline-end: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 92vw;
        max-width: 92vw;
        gap: 10px;
    }
}

/* ═══ Toast Card ═══ */
.fs-toast {
    pointer-events: auto;
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, .15),
        0 4px 12px rgba(0, 0, 0, .08),
        0 0 0 1px rgba(0, 0, 0, .04);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    min-height: 60px;
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    cursor: default;
    /* Initial state for animation */
    opacity: 0;
    transform: translateY(-20px) scale(.95);
    transition: opacity .25s cubic-bezier(0.22, 1, 0.36, 1),
                transform .25s cubic-bezier(0.22, 1, 0.36, 1);
}

.fs-toast.fs-toast-show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.fs-toast.fs-toast-hide {
    opacity: 0;
    transform: translateY(-12px) scale(.95);
    transition: opacity .2s ease, transform .2s ease;
}

/* Swipe states */
.fs-toast.fs-toast-swiping {
    transition: none;
}

/* ═══ Color Bar (left side) ═══ */
.fs-toast::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--fs-toast-color, var(--fs-primary));
}

/* ═══ Icon ═══ */
.fs-toast-icon {
    flex: 0 0 auto;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fs-toast-color, var(--fs-primary));
    background: var(--fs-toast-bg, var(--fs-tint-2));
    margin-inline-start: 4px;
    margin-block: 8px;
    margin-inline-end: 0;
    border-radius: 8px;
}

.fs-toast-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.4;
}

/* ═══ Body ═══ */
.fs-toast-body {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.fs-toast-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--fs-toast-title, #1f2937);
    line-height: 1.3;
    margin: 0;
}

.fs-toast-text {
    font-size: 12.5px;
    font-weight: 500;
    color: #475569;
    line-height: 1.4;
    margin: 0;
    word-break: break-word;
}

/* ═══ Close Button ═══ */
.fs-toast-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin: 6px 4px 0 4px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.fs-toast-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.fs-toast-close:active {
    transform: scale(.92);
}

.fs-toast-close svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

/* ═══ Action Button (optional) ═══ */
.fs-toast-action {
    border: none;
    background: transparent;
    color: var(--fs-toast-color, var(--fs-primary));
    font-weight: 800;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 4px;
    align-self: flex-start;
    font-family: inherit;
    transition: background .15s;
}

.fs-toast-action:hover {
    background: var(--fs-toast-bg, var(--fs-tint-2));
}

/* ═══ Progress Bar ═══ */
.fs-toast-progress {
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    height: 3px;
    background: var(--fs-toast-color, var(--fs-primary));
    opacity: .35;
    transform-origin: inset-inline-start;
    width: 100%;
    transition: width linear;
}

/* ═══ Type: Success ═══ */
.fs-toast-success {
    --fs-toast-color: #16a34a;
    --fs-toast-bg: #dcfce7;
    --fs-toast-title: #14532d;
}

/* ═══ Type: Error ═══ */
.fs-toast-error {
    --fs-toast-color: #dc2626;
    --fs-toast-bg: #fee2e2;
    --fs-toast-title: #7f1d1d;
}

/* ═══ Type: Warning ═══ */
.fs-toast-warning {
    --fs-toast-color: var(--fs-primary-deep);
    --fs-toast-bg: var(--fs-tint-3);
    --fs-toast-title: #7c2d12;
}

/* ═══ Type: Info ═══ */
.fs-toast-info {
    --fs-toast-color: #2563eb;
    --fs-toast-bg: #dbeafe;
    --fs-toast-title: #1e3a8a;
}

/* ═══ Phones ═══ */
@media (max-width: 480px) {
    .fs-toast {
        border-radius: 10px;
        min-height: 56px;
    }
    .fs-toast-icon {
        width: 36px;
    }
    .fs-toast-icon svg {
        width: 20px;
        height: 20px;
    }
    .fs-toast-title {
        font-size: 13.5px;
    }
    .fs-toast-text {
        font-size: 12px;
    }
    .fs-toast-body {
        padding: 10px 12px;
    }
}

/* ═══ Reduce motion accessibility ═══ */
@media (prefers-reduced-motion: reduce) {
    .fs-toast,
    .fs-toast-progress {
        transition: opacity .15s ease;
        transform: none !important;
    }
}
