/* Marjaa global flash toast — dark pill, variant accent, countdown bar */

.marjaa-toast {
    --marjaa-toast-duration: 5s;
    --marjaa-toast-radius: 1.25rem;
    --marjaa-toast-accent: #4ade80;
    --marjaa-toast-surface: rgba(26, 32, 48, 0.94);
    --marjaa-toast-border: rgba(255, 255, 255, 0.08);

    position: fixed;
    z-index: 1090;
    top: calc(env(safe-area-inset-top, 0px) + 5.75rem);
    inset-inline-end: max(1rem, env(safe-area-inset-right, 0px));
    inset-inline-start: auto;
    transform: translate3d(calc(100% + 1.25rem), 0, 0);
    opacity: 0;
    transition:
        opacity 0.2s ease,
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: min(calc(100vw - 2rem), 420px);
    min-width: min(calc(100vw - 2rem), 260px);
    width: max-content;
    pointer-events: auto;
}

.marjaa-toast-surface:focus-visible {
    outline: 2px solid rgba(139, 92, 246, 0.75);
    outline-offset: 2px;
}

.marjaa-toast--show {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.marjaa-toast-surface {
    font-family: var(--font-app, 'The Year of Handicrafts', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    position: relative;
    overflow: hidden;
    background: var(--marjaa-toast-surface);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid var(--marjaa-toast-border);
    border-radius: var(--marjaa-toast-radius);
    padding: 0.9rem 1.1rem 0;
    cursor: pointer;
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.35),
        0 4px 12px rgba(15, 23, 42, 0.2);
}

.marjaa-toast--persistent .marjaa-toast-surface {
    padding-bottom: 0.9rem;
}

/* Keep message + icon order stable: text then badge (icon on the trailing edge). */
.marjaa-toast-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    direction: ltr;
}

.marjaa-toast-text {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.45;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.98);
    text-align: start;
}

html[dir="rtl"] .marjaa-toast-text {
    direction: rtl;
    text-align: right;
}

.marjaa-toast-badge {
    position: relative;
    flex-shrink: 0;
    order: 2;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--marjaa-toast-accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    font-size: 0.9rem;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.marjaa-toast-badge i {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    line-height: 1;
    margin: 0 !important; /* rtl.css .fas margins break centering */
    padding: 0;
    width: 1em;
    height: 1em;
    font-size: 0.85rem;
    text-align: center;
    transform: translate(-50%, -50%);
}

.marjaa-toast--success {
    --marjaa-toast-accent: #4ade80;
}

.marjaa-toast--error {
    --marjaa-toast-accent: #f87171;
}

.marjaa-toast--info {
    --marjaa-toast-accent: #60a5fa;
}

.marjaa-toast--warning {
    --marjaa-toast-accent: #fbbf24;
}

.marjaa-toast-progress {
    margin: 0.75rem -1.1rem 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0 0 var(--marjaa-toast-radius) var(--marjaa-toast-radius);
    overflow: hidden;
    direction: ltr;
}

.marjaa-toast-progress-bar {
    display: block;
    height: 100%;
    width: 100%;
    transform: scaleX(1);
    transform-origin: right center;
    background: var(--marjaa-toast-accent);
}

.marjaa-toast--show .marjaa-toast-progress-bar {
    animation: marjaaToastProgress linear forwards;
    animation-duration: var(--marjaa-toast-duration, 5s);
}

@keyframes marjaaToastProgress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Processing / uploading toast */
.marjaa-toast--processing {
    --marjaa-toast-accent: #60a5fa;
}

.marjaa-toast-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    line-height: 1;
    margin: 0 !important;
    padding: 0;
    width: 1em;
    height: 1em;
    font-size: 0.9rem;
    text-align: center;
    transform: translate(-50%, -50%);
    animation: marjaaSpinner 0.85s linear infinite;
}

@keyframes marjaaSpinner {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.marjaa-toast--processing.marjaa-toast--show .marjaa-toast-progress-bar,
.marjaa-toast--processing .marjaa-toast-progress-bar {
    animation: marjaaShimmer 1.4s ease-in-out infinite !important;
    background: var(--marjaa-toast-accent);
    width: 40%;
    transform: none;
    transform-origin: left center;
}

@keyframes marjaaShimmer {
    0%   { margin-left: 0;   }
    50%  { margin-left: 60%; }
    100% { margin-left: 0;   }
}

@media (prefers-reduced-motion: reduce) {
    .marjaa-toast {
        transition: opacity 0.15s ease;
        transform: none;
    }

    .marjaa-toast--show {
        transform: none;
    }

    .marjaa-toast--show .marjaa-toast-progress-bar {
        animation: none;
    }

    .marjaa-toast-spinner {
        animation: none;
    }
}
