/* =============================================================================
   Notification engine - bell + dropdown + full-page list styling.
   Brand tokens come from site.css (--jbf-mauve, --jbf-plum, --rz-* palette).
   ========================================================================== */

/* ---------- bell button + badge ---------- */

.jbf-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.jbf-bell-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #4e5e65;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    position: relative;
    flex-shrink: 0;
}

.jbf-bell-button:hover,
.jbf-bell-button:focus-visible {
    background: rgba(125, 91, 129, 0.10);
    color: var(--jbf-plum);
    outline: none;
}

/* Fixed box matching the SVG - badge positions against this, not the 40×40 button. */
.jbf-bell-icon-wrap {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    vertical-align: middle;
}

.jbf-bell-icon {
    display: block;
    width: 22px;
    height: 22px;
}

button.jbf-bell-button .jbf-bell-badge {
    position: absolute;
    /* Slightly past the glyph corner (common app pattern) */
    top: -6px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #d23c77;
    background: var(--jbf-magenta, #d23c77);
    color: #fff;
    /* Lock font to Radzen body font (Monserrat) so the badge digits stay
       identical across host layouts. .public-page / .onb-page wrappers
       set Overpass via --pl-font / --onb-font, and inheriting that made
       the digits render slightly wider, changing the visible badge
       padding next to the launch-pad badge in the same header. */
    font-family: var(--rz-text-font-family, Monserrat, sans-serif);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid #fff;
    box-sizing: border-box;
    pointer-events: none;
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    animation: badgeFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Pulse animation when new notification arrives */
.jbf-bell-badge.pulse {
    animation: badgePulse 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Gentle shake on urgent notifications */
.jbf-bell.has-new-notification .jbf-bell-button {
    animation: bellShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

/* Respect reduced motion accessibility preference */
@media (prefers-reduced-motion: reduce) {
    .jbf-bell-badge,
    .jbf-bell-badge.pulse,
    .jbf-bell.has-new-notification .jbf-bell-button {
        animation: none;
    }
    
    .jbf-bell-badge {
        /* Still show the badge but without animation */
        opacity: 1;
        transform: scale(1);
    }
}

/* ---------- dropdown ---------- */

/* Click-outside catcher rendered as a sibling of .jbf-bell. Inherits the
   .app-header (z-index: 10) stacking context, so its own z-index of 1099 is
   only meaningful versus other elements inside the header - page content
   underneath would not be intercepted on its own. That is fine: the dropdown
   itself is portaled to <body> by JS so it floats above everything; clicking
   anywhere outside it (page content, elsewhere in the header, etc.) hits
   either the bell button itself (re-toggles), this backdrop (closes), or a
   page link (navigates, which unmounts the bell on reload). */
.jbf-bell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1099;
    background: transparent;
}

/* Position is owned by jbf-notification-bell.js (fixed, anchored to bell rect)
   so the popover escapes any sticky-header / overflow:hidden ancestor.

   The dropdown starts INVISIBLE so the user never sees the "right-to-left"
   jump that used to happen between (a) Blazor mounting the popover in its
   original parent with the CSS-fallback right:12px and (b) JS portaling it
   to <body> and recomputing the position relative to the bell. JS adds the
   `--ready` modifier after compute() runs, which fades the popover in at
   its FINAL position - no slide, no flicker. */
.jbf-bell-dropdown {
    position: fixed;
    top: 64px;
    right: 12px;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--rz-text-font-family, inherit);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.jbf-bell-dropdown.jbf-bell-dropdown--ready {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .jbf-bell-dropdown {
        transition: none;
        transform: none;
    }
}

.jbf-bell-dropdown__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f5;
    background: #fafafa;
}

.jbf-bell-dropdown__title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.jbf-bell-dropdown__action {
    background: transparent;
    border: none;
    color: var(--jbf-plum);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

.jbf-bell-dropdown__action:hover {
    background: rgba(125, 91, 129, 0.08);
}

.jbf-bell-dropdown__body {
    max-height: 360px;
    overflow-y: auto;
}

.jbf-bell-dropdown__footer {
    padding: 10px 16px;
    border-top: 1px solid #f1f3f5;
    text-align: center;
    background: #fafafa;
}

.jbf-bell-dropdown__footer a {
    font-size: 13px;
    font-weight: 600;
    color: var(--jbf-plum);
    text-decoration: none;
}

.jbf-bell-dropdown__footer a:hover {
    text-decoration: underline;
}

/* ---------- dropdown items ---------- */

.jbf-bell-item {
    width: 100%;
    display: grid;
    grid-template-columns: 12px 1fr;
    column-gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.12s ease;
    font: inherit;
}

.jbf-bell-item:last-child { border-bottom: none; }

.jbf-bell-item:hover {
    background: #f9f7fb;
}

.jbf-bell-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    background: transparent;
}

.jbf-bell-item.is-unread .jbf-bell-item__dot {
    background: var(--jbf-magenta);
    box-shadow: 0 0 0 2px rgba(210, 60, 119, 0.18);
}

.jbf-bell-item__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jbf-bell-item__title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.jbf-bell-item.is-read .jbf-bell-item__title {
    color: #4b5563;
    font-weight: 500;
}

.jbf-bell-item__detail {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.jbf-bell-item__time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ---------- empty state ---------- */

.jbf-bell-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px 16px;
    color: #6b7280;
}

.jbf-bell-empty__icon {
    color: #cdb4d3;
    margin-bottom: 8px;
}

.jbf-bell-empty__title {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.jbf-bell-empty__hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

/* xs/sm tier (max-width 767.98px mirrors --bp-md). Media queries cannot deref
   CSS vars. Fallback bounds for the brief pre-JS window - once
   jbf-notification-bell.js runs it will overwrite top/left/right/width inline
   based on the bell's bounding rect. */
@media (max-width: 767.98px) {
    .jbf-bell-dropdown {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 120px);
    }

    .jbf-bell-dropdown__body {
        max-height: calc(100vh - 220px);
    }
}

/* =============================================================================
   Full-page notifications list (/notifications)
   ========================================================================== */

.jbf-notifications-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.jbf-notifications-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.jbf-notifications-page__title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.jbf-notifications-page__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.jbf-notifications-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 12px;
}

.jbf-notifications-mark-all__btn {
    flex-shrink: 0;
    margin-left: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--jbf-plum, #7d5b81);
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.jbf-notifications-mark-all__btn:hover:not(:disabled) {
    border-color: var(--jbf-plum, #7d5b81);
    background: rgba(125, 91, 129, 0.06);
}

.jbf-notifications-mark-all__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: #6b7280;
}

.jbf-notifications-filter {
    display: inline-flex;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 2px;
    gap: 0;
}

.jbf-notifications-filter__btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.jbf-notifications-filter__btn.is-active {
    background: #fff;
    color: var(--jbf-plum);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.jbf-notifications-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jbf-notifications-item {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    column-gap: 12px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.jbf-notifications-item:hover {
    border-color: #d6d6d6;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.jbf-notifications-item.is-unread {
    border-left: 3px solid var(--jbf-magenta);
    padding-left: 13px;
}

.jbf-notifications-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 7px;
    background: transparent;
}

.jbf-notifications-item.is-unread .jbf-notifications-item__dot {
    background: var(--jbf-magenta);
    box-shadow: 0 0 0 2px rgba(210, 60, 119, 0.18);
}

.jbf-notifications-item__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.jbf-notifications-item__title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.jbf-notifications-item.is-read .jbf-notifications-item__title {
    color: #4b5563;
    font-weight: 500;
}

.jbf-notifications-item__detail {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.jbf-notifications-item__meta {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.jbf-notifications-item__actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.jbf-notifications-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.jbf-notifications-icon-btn:hover {
    background: #f3f4f6;
    color: var(--jbf-plum);
}

.jbf-notifications-icon-btn.is-danger:hover {
    background: rgba(216, 15, 61, 0.08);
    color: var(--jbf-red);
}

.jbf-notifications-empty {
    text-align: center;
    padding: 80px 24px;
    color: #6b7280;
    background: #fff;
    border: 1px dashed #e5e7eb;
    border-radius: 12px;
}

.jbf-notifications-empty__icon {
    color: #cdb4d3;
    margin-bottom: 12px;
}

.jbf-notifications-empty__title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.jbf-notifications-empty__hint {
    margin-top: 4px;
    font-size: 13px;
    color: #9ca3af;
}

.jbf-notifications-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.jbf-notifications-pager__info {
    font-size: 12px;
    color: #6b7280;
}

.jbf-notifications-pager__btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: #1f2937;
    cursor: pointer;
}

.jbf-notifications-pager__btn:hover:not(:disabled) {
    border-color: var(--jbf-plum);
    color: var(--jbf-plum);
}

.jbf-notifications-pager__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
