﻿/* ============================================================
   Toast Notification System for ASP.NET Core MVC
   ============================================================
   Drop-in toast notifications with animations, stacking,
   progress bar, and responsive layout.

   All classes are prefixed with `meq-` to AVOID collisions
   with Bootstrap's built-in .toast component (which sets
   display:none by default).
   ============================================================ */

/* ---------- Container ---------- */
#meq-toast-container {
    position: fixed;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;          /* let clicks pass through */
    max-height: 100vh;
    max-width: 350px;
    overflow: visible;
    padding: 16px;
    box-sizing: border-box;
}

/* Position variants â€” added to #meq-toast-container by toast.js */
#meq-toast-container.toast-top-right    { top: 8%; right: 0; }
#meq-toast-container.toast-top-left     { top: 8%; left: 0; align-items: flex-start; }
#meq-toast-container.toast-top-center   { top: 8%; left: 50%; transform: translateX(-50%); align-items: center; }
#meq-toast-container.toast-bottom-right { bottom: 0; right: 0; flex-direction: column-reverse; }
#meq-toast-container.toast-bottom-left  { bottom: 0; left: 0; flex-direction: column-reverse; align-items: flex-start; }
#meq-toast-container.toast-bottom-center{ bottom: 0; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; align-items: center; }

/* Default position: top-left (RTL layout) */
#meq-toast-container { top: 8%; left: 0; }

/* When pinned to the left edge, slide in from the left (RTL) */
#meq-toast-container.toast-top-left .meq-toast,
#meq-toast-container.toast-bottom-left .meq-toast {
    animation-name: meq-toast-slide-in-left;
}

/* ---------- Individual Toast ---------- */
.meq-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    /* Force LTR flex ordering so icon sits on the LEFT and close button on the
       RIGHT. The Arabic text in .meq-toast-body remains visually RTL because
       the .meq-toast-body element below sets direction: rtl explicitly. */
    direction: ltr;
    min-width: 320px;
    max-width: 460px;
    padding: 14px 18px 14px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
    pointer-events: auto;           /* re-enable clicks on the toast itself */
    cursor: default;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: #1F2933;
    background: #ffffff;
    /* Logical property: in RTL (dir=rtl) the accent appears on the inline-start edge (right);
       in LTR it appears on the left. Correct in both directions. */
    border-inline-start: 4px solid #9CA3AF;
    animation: meq-toast-slide-in 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ---------- Icon ---------- */
.meq-toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-inline-end: 12px;
    margin-top: 1px;
    font-size: 18px;
    line-height: 1;
}

/* ---------- Body ---------- */
.meq-toast-body {
    flex: 1;
    min-width: 0;                   /* allow text truncation */
    direction: rtl;                 /* keep Arabic body text RTL */
    text-align: right;
}

.meq-toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    color: #1F2933;
}

.meq-toast-message {
    font-size: 13px;
    color: #6B7280;
    word-wrap: break-word;
}

/* ---------- Close Button ---------- */
.meq-toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-inline-start: 12px;
    margin-top: -2px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #9CA3AF;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.meq-toast-close:hover {
    background: rgba(0,0,0,0.06);
    color: #6B7280;
}

/* ---------- Progress Bar ---------- */
.meq-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 8px;
    background: rgba(0,0,0,0.08);
    animation: meq-toast-progress linear forwards;
}

/* ============================================================
   TYPE VARIANTS
   Colors follow the site palette (site.css tokens).
   ============================================================ */

/* Success */
.meq-toast.meq-toast-success {
    border-inline-start-color: #3F7D58;
    background: #EAF3ED;
}
.meq-toast.meq-toast-success .meq-toast-icon { color: #3F7D58; }
.meq-toast.meq-toast-success .meq-toast-progress { background: #3F7D58; }

/* Error */
.meq-toast.meq-toast-error {
    border-inline-start-color: #B5473C;
    background: #F9ECEA;
}
.meq-toast.meq-toast-error .meq-toast-icon { color: #B5473C; }
.meq-toast.meq-toast-error .meq-toast-progress { background: #B5473C; }

/* Warning */
.meq-toast.meq-toast-warning {
    border-inline-start-color: #D4A017;
    background: #FBF1D4;
}
.meq-toast.meq-toast-warning .meq-toast-icon { color: #A87E0E; }
.meq-toast.meq-toast-warning .meq-toast-progress { background: #D4A017; }

/* Info */
.meq-toast.meq-toast-info {
    border-inline-start-color: #54786E;
    background: #ECF2F0;
}
.meq-toast.meq-toast-info .meq-toast-icon { color: #54786E; }
.meq-toast.meq-toast-info .meq-toast-progress { background: #54786E; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

/* Slide in from right (default) */
@keyframes meq-toast-slide-in {
    0%   { opacity: 0; transform: translateX(40px) scale(0.96); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* Slide in from left (for top-left / bottom-left containers â€” RTL) */
@keyframes meq-toast-slide-in-left {
    0%   { opacity: 0; transform: translateX(-40px) scale(0.96); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* Slide out to right (added by JS before removal) */
.meq-toast.meq-toast-removing {
    animation: meq-toast-slide-out 0.3s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

@keyframes meq-toast-slide-out {
    0%   { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(60px) scale(0.94); }
}

/* Progress bar shrink */
@keyframes meq-toast-progress {
    0%   { width: 100%; }
    100% { width: 0%; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 520px) {
    #meq-toast-container {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        padding: 10px;
        align-items: stretch !important;
    }

    .meq-toast {
        min-width: 0;
        max-width: 100%;
    }
}

/* ============================================================
   DARK MODE
   Activated by <html data-theme="dark"> (matches the site.js
   theme system). Also supports the legacy .dark-mode class for
   any external integration.
   ============================================================ */

:root[data-theme="dark"] .meq-toast,
.dark-mode .meq-toast {
    background: #1A2A25;
    color: #EAEFEC;
    border-inline-start-color: #3A4A45;
    box-shadow: 0 8px 24px rgba(0,0,0,0.55);
}

:root[data-theme="dark"] .meq-toast-title,
.dark-mode .meq-toast-title { color: #F3F6F4; }
:root[data-theme="dark"] .meq-toast-message,
.dark-mode .meq-toast-message { color: #94A29C; }
:root[data-theme="dark"] .meq-toast-close,
.dark-mode .meq-toast-close { color: #6B7872; }
:root[data-theme="dark"] .meq-toast-close:hover,
.dark-mode .meq-toast-close:hover { background: rgba(255,255,255,0.08); color: #C8D0CC; }

:root[data-theme="dark"] .meq-toast.meq-toast-success,
.dark-mode .meq-toast.meq-toast-success { border-inline-start-color: #5FA97E; background: #123A30; }
:root[data-theme="dark"] .meq-toast.meq-toast-success .meq-toast-icon,
.dark-mode .meq-toast.meq-toast-success .meq-toast-icon { color: #6CC490; }

:root[data-theme="dark"] .meq-toast.meq-toast-error,
.dark-mode .meq-toast.meq-toast-error { border-inline-start-color: #DE7A6E; background: #3A2120; }
:root[data-theme="dark"] .meq-toast.meq-toast-error .meq-toast-icon,
.dark-mode .meq-toast.meq-toast-error .meq-toast-icon { color: #F09083; }

:root[data-theme="dark"] .meq-toast.meq-toast-warning,
.dark-mode .meq-toast.meq-toast-warning { border-inline-start-color: #DDB04B; background: #3A2F14; }
:root[data-theme="dark"] .meq-toast.meq-toast-warning .meq-toast-icon,
.dark-mode .meq-toast.meq-toast-warning .meq-toast-icon { color: #EFC761; }

:root[data-theme="dark"] .meq-toast.meq-toast-info,
.dark-mode .meq-toast.meq-toast-info { border-inline-start-color: #7FB5AA; background: #14322E; }
:root[data-theme="dark"] .meq-toast.meq-toast-info .meq-toast-icon,
.dark-mode .meq-toast.meq-toast-info .meq-toast-icon { color: #93C5BA; }

/* ============================================================
   STACKING / OVERFLOW
   When toasts exceed the viewport height, older ones fade out.
   ============================================================ */

.meq-toast.meq-toast-stacked-hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
}
