/* =====================================================================
   Enpower Skill Lab — Unified Toast Notification System
   Brand: purple #6c32a8 / yellow #f4b400 · green-tick success
   Position: top-right slide-in · auto-dismiss 3s
   Used by every role base.html + all AJAX calls (window.showToast).
   ===================================================================== */

:root {
    --esl-toast-purple: #6c32a8;
    --esl-toast-yellow: #f4b400;
    --esl-toast-success: #16a34a;
    --esl-toast-error: #dc2626;
    --esl-toast-info: #6c32a8;
}

.esl-toast-container {
    position: fixed;
    /* Clear of the sticky header rather than on top of it. At 20px the
       toast covered the signed-in user name and the account menu, so you
       could not use the page until it dismissed itself. */
    top: 84px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.esl-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #ffffff;
    border-radius: 12px;
    border-left: 4px solid var(--esl-toast-purple);
    box-shadow: 0 10px 30px rgba(108, 50, 168, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;

    /* Visible by default. The slide-in is decoration only.
       This used to be opacity:0 / translateX(120%) with the animation as the
       ONLY thing that revealed it — so whenever the animation did not run
       (reduced-motion, devtools animation emulation, extensions that disable
       animations) the toast sat in the DOM fully built and permanently
       invisible. */
    opacity: 1;
    transform: translateX(0);
    animation: esl-toast-in 0.35s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.esl-toast.closing {
    animation: esl-toast-out 0.3s ease forwards;
}

@keyframes esl-toast-in {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes esl-toast-out {
    from { transform: translateX(0);    opacity: 1; }
    to   { transform: translateX(120%); opacity: 0; }
}

/* Respect reduced motion, but never at the cost of the toast being seen. */
@media (prefers-reduced-motion: reduce) {
    .esl-toast { animation: none; }
    .esl-toast.closing { animation: none; opacity: 0; }
    .esl-toast-progress-bar { animation: none; }
}

/* ---- Icon ---- */
.esl-toast-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #ffffff;
    background: var(--esl-toast-purple);
}

.esl-toast-icon .material-symbols-outlined,
.esl-toast-icon .material-icons {
    font-size: 20px;
    font-variation-settings: 'FILL' 1;
    /* The icon fonts carry their own leading, so the glyph sat slightly
       above the middle of the circle even with the flex centring above.
       line-height:1 makes the glyph box its own height, and block display
       stops the inline baseline nudging it again. */
    line-height: 1;
    display: block;
}

/* ---- Content ---- */
.esl-toast-content {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.esl-toast-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
    margin-bottom: 2px;
}

.esl-toast-message {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.35;
    word-wrap: break-word;
}

/* ---- Close button ---- */
.esl-toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.esl-toast-close:hover { color: #4b5563; }
.esl-toast-close .material-symbols-outlined,
.esl-toast-close .material-icons { font-size: 18px; }

/* ---- Progress bar (brand-tinted, counts down 3s) ---- */
.esl-toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: rgba(0, 0, 0, 0.06);
}

.esl-toast-progress-bar {
    height: 100%;
    width: 100%;
    background: var(--esl-toast-purple);
    transform-origin: left;
    animation: esl-toast-progress 3s linear forwards;
}

@keyframes esl-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ---- Type variants ----
   Each type tints the whole toast, not just the left border, so the status is
   readable at a glance instead of needing the thin edge to be noticed. */
.esl-toast-success { border-left-color: var(--esl-toast-success); background: #f0fdf4; }
.esl-toast-success .esl-toast-icon { background: var(--esl-toast-success); }
.esl-toast-success .esl-toast-progress-bar { background: var(--esl-toast-success); }
.esl-toast-success .esl-toast-title { color: #14532d; }
.esl-toast-success .esl-toast-message { color: #166534; }
.esl-toast-success .esl-toast-close { color: #4d7c5a; }

.esl-toast-error { border-left-color: var(--esl-toast-error); background: #fef2f2; }
.esl-toast-error .esl-toast-icon { background: var(--esl-toast-error); }
.esl-toast-error .esl-toast-progress-bar { background: var(--esl-toast-error); }
.esl-toast-error .esl-toast-title { color: #7f1d1d; }
.esl-toast-error .esl-toast-message { color: #991b1b; }
.esl-toast-error .esl-toast-close { color: #a56464; }

.esl-toast-warning { border-left-color: var(--esl-toast-yellow); background: #fffbeb; }
.esl-toast-warning .esl-toast-icon { background: var(--esl-toast-yellow); }
.esl-toast-warning .esl-toast-progress-bar { background: var(--esl-toast-yellow); }
.esl-toast-warning .esl-toast-title { color: #713f12; }
.esl-toast-warning .esl-toast-message { color: #854d0e; }

.esl-toast-info { border-left-color: var(--esl-toast-info); background: #faf5ff; }
.esl-toast-info .esl-toast-icon { background: var(--esl-toast-info); }
.esl-toast-info .esl-toast-progress-bar { background: var(--esl-toast-info); }
.esl-toast-info .esl-toast-title { color: #4c1d95; }
.esl-toast-info .esl-toast-message { color: #5b21b6; }



@media (max-width: 480px) {
    .esl-toast-container {
        top: 76px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
    }
}
