/* =====================================================================
   Pending-work notifications — bell, panel ("مهامك المعلّقة"), toast.
   Markup: Views/Shared/_UserSession.cshtml   Script: wwwroot/js/amana-tasks.js
   ===================================================================== */

:root {
    --amt-navy: #0b2545;
    --amt-teal: #0d9488;
    --amt-blue: #2563eb;
    --amt-ink: #0f1f33;
    --amt-muted: #64748b;
    --amt-line: #e3e9f0;
    --amt-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --amt-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tone palette (icon gradient / accent) */
.tone-indigo { --tone-a: #6366f1; --tone-b: #4338ca; --tone-soft: #eef2ff; --tone-ink: #4338ca; }
.tone-amber  { --tone-a: #f59e0b; --tone-b: #d97706; --tone-soft: #fffbeb; --tone-ink: #b45309; }
.tone-teal   { --tone-a: #14b8a6; --tone-b: #0f766e; --tone-soft: #f0fdfa; --tone-ink: #0f766e; }
.tone-blue   { --tone-a: #3b82f6; --tone-b: #1d4ed8; --tone-soft: #eff6ff; --tone-ink: #1d4ed8; }
.tone-violet { --tone-a: #8b5cf6; --tone-b: #6d28d9; --tone-soft: #f5f3ff; --tone-ink: #6d28d9; }
.tone-rose   { --tone-a: #f43f5e; --tone-b: #be123c; --tone-soft: #fff1f2; --tone-ink: #be123c; }
.tone-orange { --tone-a: #fb923c; --tone-b: #ea580c; --tone-soft: #fff7ed; --tone-ink: #c2410c; }
.tone-green  { --tone-a: #22c55e; --tone-b: #15803d; --tone-soft: #f0fdf4; --tone-ink: #15803d; }

/* ---------- Bell ---------- */
.am-tasks {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
}

.am-tasks-bell {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #e3e9f0;
    border-radius: 14px;
    color: #12324f;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px -6px rgba(11, 37, 69, 0.3);
    transition: transform 0.3s var(--amt-spring), box-shadow 0.25s ease, border-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

    .am-tasks-bell svg {
        width: 21px;
        height: 21px;
        transform-origin: 50% 8%;
    }

    .am-tasks-bell:hover {
        transform: translateY(-2px);
        color: var(--amt-teal);
        border-color: #99f6e4;
        box-shadow: 0 10px 20px -10px rgba(13, 148, 136, 0.6);
    }

    .am-tasks-bell:focus-visible {
        outline: 2px solid var(--amt-teal);
        outline-offset: 2px;
    }

    .am-tasks-bell[aria-expanded="true"] {
        color: #fff;
        border-color: transparent;
        background: linear-gradient(135deg, var(--amt-teal), var(--amt-blue));
    }

/* gentle idle swing while there is pending work */
.am-tasks.has-tasks .am-tasks-bell svg {
    animation: amtSwing 4.5s ease-in-out infinite;
}

.am-tasks-bell.is-ring svg {
    animation: amtRing 1.1s ease-in-out 2 !important;
}

@keyframes amtSwing {
    0%, 82%, 100% { transform: rotate(0); }
    85% { transform: rotate(14deg); }
    89% { transform: rotate(-12deg); }
    93% { transform: rotate(8deg); }
    97% { transform: rotate(-4deg); }
}

@keyframes amtRing {
    0%, 100% { transform: rotate(0); }
    10%, 30%, 50%, 70% { transform: rotate(16deg); }
    20%, 40%, 60%, 80% { transform: rotate(-16deg); }
}

/* pulse halo */
.am-tasks.has-tasks .am-tasks-bell::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 2px solid rgba(244, 63, 94, 0.55);
    animation: amtHalo 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes amtHalo {
    0% { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.35); }
}

.am-tasks-bell.is-loading::before {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    width: 4px;
    height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--amt-teal);
    animation: amtDot 0.9s ease-in-out infinite;
}

@keyframes amtDot {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.am-tasks-badge {
    position: absolute;
    top: -7px;
    left: -7px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font: 800 0.72rem/1 var(--font-display, "Cairo", system-ui, sans-serif);
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    box-shadow: 0 0 0 2px #fff, 0 6px 14px -4px rgba(225, 29, 72, 0.7);
    animation: amtPop 0.5s var(--amt-spring) both;
}

    .am-tasks-badge[hidden] { display: none; }

    .am-tasks-badge.is-bump { animation: amtBump 0.6s var(--amt-spring); }

@keyframes amtPop {
    from { transform: scale(0); }
    to { transform: none; }
}

@keyframes amtBump {
    0% { transform: scale(1); }
    40% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

/* ---------- Panel ---------- */
.am-tasks-panel {
    position: fixed;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #f6f9fc;
    box-shadow: 0 30px 80px -20px rgba(5, 15, 30, 0.55), 0 0 0 1px rgba(11, 37, 69, 0.08);
    font-family: var(--font-display, "Cairo", system-ui, sans-serif);
    color: var(--amt-ink);
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
    transform-origin: var(--arrow-x, 50%) top;
    transition: opacity 0.22s ease, transform 0.35s var(--amt-ease);
}

    .am-tasks-panel.is-up { transform-origin: var(--arrow-x, 50%) bottom; transform: translateY(10px) scale(0.97); }
    .am-tasks-panel.is-open { opacity: 1; transform: none; }
    .am-tasks-panel[hidden] { display: none !important; }

.am-tp-head {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.05rem 1.05rem;
    padding-inline-end: 2.9rem; /* room for the close button */
    color: #fff;
    background: linear-gradient(140deg, var(--amt-navy) 0%, #0f3b5f 55%, #0f5f63 100%);
}

.am-tp-aurora {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

    .am-tp-aurora i {
        position: absolute;
        width: 180px;
        height: 180px;
        border-radius: 50%;
        filter: blur(46px);
        opacity: 0.5;
        animation: amtFloat 11s ease-in-out infinite alternate;
    }

        .am-tp-aurora i:nth-child(1) { background: #14b8a6; top: -100px; right: -30px; }
        .am-tp-aurora i:nth-child(2) { background: #f43f5e; bottom: -130px; left: 10%; opacity: 0.35; animation-delay: -5s; }

@keyframes amtFloat {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-26px, 16px) scale(1.15); }
}

.am-tp-head-txt {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-width: 0;
}

.am-tp-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    color: #99f6e4;
}

.am-tp-head h2 {
    margin: 0.05rem 0 0.1rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

.am-tp-head p {
    margin: 0;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.8);
}

    .am-tp-head p b { color: #fde68a; }

.am-tp-total {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    line-height: 1.05;
}

    .am-tp-total b { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
    .am-tp-total span { font-size: 0.62rem; font-weight: 700; opacity: 0.8; }

.am-tp-x {
    position: absolute;
    z-index: 2;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 9px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.35s var(--amt-ease), background 0.2s;
}

    .am-tp-x svg { width: 15px; height: 15px; }
    .am-tp-x:hover { transform: rotate(90deg); background: rgba(255, 255, 255, 0.22); }

.am-tp-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.8rem;
    scrollbar-width: thin;
}

.am-tp-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.75rem;
    border-radius: 16px;
    color: inherit;
    text-decoration: none;
    background: #fff;
    box-shadow: 0 8px 18px -14px rgba(11, 37, 69, 0.45), 0 0 0 1px var(--amt-line);
    animation: amtRise 0.45s var(--amt-ease) both;
    animation-delay: calc(var(--i, 0) * 0.05s + 0.05s);
    transition: transform 0.3s var(--amt-ease), box-shadow 0.3s ease;
}

    .am-tp-item:hover {
        color: inherit;
        transform: translateX(-4px);
        box-shadow: 0 14px 26px -16px rgba(11, 37, 69, 0.5), 0 0 0 1px var(--tone-a, var(--amt-teal));
    }

    .am-tp-item.is-done { opacity: 0.7; }

@keyframes amtRise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.am-tp-ico {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(145deg, var(--tone-a), var(--tone-b));
    box-shadow: 0 8px 16px -8px var(--tone-a);
    transition: transform 0.4s var(--amt-spring);
}

    .am-tp-ico svg { width: 21px; height: 21px; }

.am-tp-item:hover .am-tp-ico { transform: rotate(-8deg) scale(1.08); }

.am-tp-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

    .am-tp-body strong { font-size: 0.88rem; font-weight: 800; }
    .am-tp-body small { font-size: 0.7rem; font-weight: 600; color: var(--amt-muted); }

.am-tp-bar {
    display: block;
    height: 4px;
    margin-top: 0.3rem;
    border-radius: 99px;
    background: #eef2f7;
    overflow: hidden;
}

    .am-tp-bar i {
        display: block;
        height: 100%;
        border-radius: inherit;
        background: linear-gradient(90deg, var(--tone-b), var(--tone-a));
        animation: amtGrow 0.9s var(--amt-ease) both;
        animation-delay: calc(var(--i, 0) * 0.05s + 0.2s);
        transform-origin: right;
    }

@keyframes amtGrow {
    from { transform: scaleX(0); }
    to { transform: none; }
}

.am-tp-count {
    flex: 0 0 auto;
    min-width: 40px;
    height: 32px;
    padding: 0 0.55rem;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--tone-ink);
    background: var(--tone-soft);
}

    .am-tp-count b { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
    .am-tp-count svg { width: 17px; height: 17px; }

.am-tp-item.is-done .am-tp-count { color: #15803d; background: #f0fdf4; }

.am-tp-go {
    flex: 0 0 auto;
    color: #94a3b8;
    transition: transform 0.3s var(--amt-ease), color 0.2s;
}

    .am-tp-go svg { width: 18px; height: 18px; display: block; }

.am-tp-item:hover .am-tp-go { color: var(--tone-ink); transform: translateX(-3px); }

.am-tp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.6rem 1rem;
    text-align: center;
    animation: amtRise 0.45s var(--amt-ease) both;
}

    .am-tp-empty svg {
        width: 46px;
        height: 46px;
        padding: 11px;
        box-sizing: content-box;
        border-radius: 50%;
        color: #15803d;
        background: #dcfce7;
    }

    .am-tp-empty strong { font-size: 0.95rem; }
    .am-tp-empty span { font-size: 0.76rem; color: var(--amt-muted); }

.am-tp-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem 0.7rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--amt-muted);
    border-top: 1px solid var(--amt-line);
    background: #fff;
}

    .am-tp-foot button {
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.25rem 0.65rem;
        border: 1px solid #a7f3d0;
        border-radius: 999px;
        font: inherit;
        font-weight: 800;
        color: #0f766e;
        background: #ecfdf5;
        cursor: pointer;
    }

        .am-tp-foot button svg { width: 13px; height: 13px; transition: transform 0.5s var(--amt-ease); }
        .am-tp-foot button:hover svg { transform: rotate(-200deg); }

/* ---------- Toast ---------- */
.am-task-toast {
    position: fixed;
    z-index: 4100;
    left: 18px;
    bottom: 18px;
    width: min(380px, calc(100vw - 24px));
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.95rem 1rem 1.05rem;
    overflow: hidden;
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(140deg, rgba(11, 37, 69, 0.97), rgba(15, 59, 95, 0.97) 55%, rgba(15, 95, 99, 0.97));
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: 0 30px 70px -20px rgba(5, 15, 30, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
    font-family: var(--font-display, "Cairo", system-ui, sans-serif);
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.6s var(--amt-spring);
}

    .am-task-toast.is-in { opacity: 1; transform: none; }
    .am-task-toast.is-out { opacity: 0; transform: translateX(-40px); transition-duration: 0.3s; }

.am-tt-ring {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: linear-gradient(145deg, #f43f5e, #e11d48);
    box-shadow: 0 10px 20px -8px rgba(244, 63, 94, 0.8);
}

    .am-tt-ring svg {
        width: 23px;
        height: 23px;
        transform-origin: 50% 8%;
        animation: amtRing 1.1s ease-in-out 0.4s 2;
    }

    .am-tt-ring::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        border: 2px solid rgba(244, 63, 94, 0.7);
        animation: amtHalo 1.8s ease-out infinite;
    }

.am-tt-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

    .am-tt-body > strong { font-size: 1rem; font-weight: 800; padding-left: 1.6rem; }

.am-tt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.am-tt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.3rem 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
    transition: background 0.2s ease;
}

    .am-tt-chip:hover { color: #fff; background: rgba(255, 255, 255, 0.2); }
    .am-tt-chip svg { width: 13px; height: 13px; color: var(--tone-a); }

    .am-tt-chip b {
        min-width: 20px;
        padding: 0 0.3rem;
        border-radius: 999px;
        text-align: center;
        color: var(--amt-navy);
        background: #fff;
    }

.am-tt-open {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--amt-navy);
    background: #fde68a;
    cursor: pointer;
    transition: transform 0.25s var(--amt-spring), gap 0.25s ease;
}

    .am-tt-open svg { width: 15px; height: 15px; }
    .am-tt-open:hover { transform: translateY(-2px); gap: 0.55rem; }

.am-tt-x {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

    .am-tt-x svg { width: 14px; height: 14px; }
    .am-tt-x:hover { color: #fff; background: rgba(255, 255, 255, 0.2); }

.am-tt-timer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #fde68a, #5eead4);
    transform-origin: right;
    animation: amtTimer var(--toast-ms, 9000ms) linear forwards;
}

.am-task-toast.is-paused .am-tt-timer { animation-play-state: paused; }

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

@media (max-width: 600px) {
    .am-tasks-bell { width: 38px; height: 38px; border-radius: 12px; }
    .am-task-toast { left: 12px; right: 12px; bottom: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .am-tasks *,
    .am-tasks *::after,
    .am-tasks-panel,
    .am-tasks-panel *,
    .am-task-toast,
    .am-task-toast * {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
