/* ---------------------------------------------------------------------------
   Header notification bell.

   Replaces the pre-2026-08-04 look: a 300px black translucent box whose unread
   rows carried a 2px red border and whose timestamps were raw DATETIME strings.

   ⚠ THE WIDGET IS IN THE DOM TWICE — `besideMenuButton` (narrow) and
     `besideWideMenu` (wide), one hidden by the rules below. Every selector here
     is scoped to `div.bms.notifications` so both copies style identically.
   --------------------------------------------------------------------------- */

div.bms.notifications {
    position: relative;
    border-radius: 5px;
    background-image: url("images/notifications.png");
    background-color: #ffe9d9;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    background-size: auto 17px;
    padding: 5px;
    margin-top: 11px;
    margin-right: 10px;
    box-shadow: inset 0 0 2px 0 rgba(0, 0, 0, 0.59);
    width: 15px;
    height: 15px;
}

div.bms.notifications > a.dummy {
    display: block;
    height: 100%;
    width: 100%;
    margin: -5px;
    padding: 5px;
}

div.bms.notifications.besideMenuButton {
    position: absolute;
    top: 22px;
    right: 50px;
}

div.bms.notifications.besideMenuButton.wideMenu {
    display: none;
}

div.bms.notifications.besideWideMenu {
    display: inline-block;
    float: left;
    position: relative;
}

div.bms.notifications.besideWideMenu:not(.wideMenu) {
    display: none;
}

/* --- badge --------------------------------------------------------------- */

div.bms.notifications > span.counter {
    position: absolute;
    top: -8px;
    right: -8px;
    display: none;
    min-width: 8px;
    padding: 2px 5px;
    background: #d1242f;
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    border-radius: 9px;
    box-shadow: 0 0 0 2px #fff;
}

/* --- panel --------------------------------------------------------------- */

div.bms.notifications > div.list_items {
    display: none;
    position: absolute;
    top: 28px;
    right: 0;
    box-sizing: border-box;
    width: 360px;
    max-width: 92vw;
    padding: 0;
    background: #fff;
    color: #222;
    font-size: 12px;
    text-align: left;
    direction: ltr;
    z-index: 60;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

/* The narrow-screen copy is pinned near the right edge of the viewport, so an
   absolutely positioned panel would overflow off-screen on a phone. */
div.bms.notifications.besideMenuButton > div.list_items {
    right: -8px;
}

div.bms.notifications .ncPanelHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

div.bms.notifications .ncPanelTitle {
    font-weight: 700;
    font-size: 13px;
}

div.bms.notifications .ncPanelMarkAll {
    font-size: 11px;
    color: #1f6feb;
    text-decoration: none;
}

div.bms.notifications .ncPanelMarkAll:hover {
    text-decoration: underline;
}

div.bms.notifications .ncPanelMarkAll.disabled {
    color: #aaa;
    pointer-events: none;
}

div.bms.notifications .ncPanelTabs {
    display: flex;
    gap: 4px;
    padding: 6px 8px 0;
    border-bottom: 1px solid #eee;
}

div.bms.notifications .ncTab {
    padding: 4px 10px 6px;
    font-size: 11px;
    color: #666;
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

div.bms.notifications .ncTab.active {
    color: #1f6feb;
    border-bottom-color: #1f6feb;
    font-weight: 600;
}

/* ⚠ overflow-x MUST be stated. CSS computes a `visible` overflow-x to `auto`
   the moment the other axis is scrollable, so `overflow-y:auto` alone gave the
   panel a full-width horizontal scrollbar the instant any row was one pixel too
   wide — which a hard space (&nbsp) in a body reliably managed. */
div.bms.notifications .ncPanelBody {
    max-height: 380px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Firefox; the ::-webkit- rules below cover Chrome and Edge. */
    scrollbar-width: thin;
    scrollbar-color: #cfd6e2 transparent;
}

div.bms.notifications .ncPanelBody::-webkit-scrollbar {
    width: 8px;
}

div.bms.notifications .ncPanelBody::-webkit-scrollbar-track {
    background: transparent;
}

div.bms.notifications .ncPanelBody::-webkit-scrollbar-thumb {
    background: #d3dae4;
    border: 2px solid #fff;
    border-radius: 8px;
}

div.bms.notifications .ncPanelBody::-webkit-scrollbar-thumb:hover {
    background: #b6c0cf;
}

/* --- items --------------------------------------------------------------- */

div.bms.notifications .ncItem {
    display: flex;
    gap: 9px;
    padding: 9px 12px;
    border-bottom: 1px solid #f2f2f2;
    text-decoration: none;
    color: inherit;
    position: relative;
}

div.bms.notifications .ncItem:hover {
    background: #f6f9ff;
}

div.bms.notifications .ncItem.unread {
    background: #f4f8ff;
}

div.bms.notifications .ncItem.unread:hover {
    background: #eaf2ff;
}

/* Priority stripe. The colour is set inline per item. */
div.bms.notifications .ncItem.unread::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: currentColor;
}

div.bms.notifications .ncItemIcon {
    flex: 0 0 auto;
    padding-top: 1px;
    /* stroke="currentColor" on the inline SVG, tinted per priority. */
}

div.bms.notifications .ncItemMain {
    flex: 1 1 auto;
    min-width: 0;
}

div.bms.notifications .ncItemTitle {
    font-weight: 600;
    color: #222;
    margin-bottom: 1px;
    word-break: break-word;
}

div.bms.notifications .ncItem.unread .ncItemTitle {
    font-weight: 700;
}

div.bms.notifications .ncItemText {
    color: #555;
    line-height: 1.4;
    /* Two lines, then ellipsis — the full body is on the Center page. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

div.bms.notifications .ncItemMeta {
    margin-top: 3px;
    font-size: 10px;
    color: #999;
}

div.bms.notifications .ncItemCount {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    background: #e8eefb;
    color: #1f6feb;
    border-radius: 8px;
    font-weight: 700;
}

/* Per-item mark-read dot. Present because plenty of notifications explain
   themselves and should not need opening a link to be cleared. */
div.bms.notifications .ncItemDot {
    flex: 0 0 auto;
    width: 16px;
    align-self: center;
    text-align: center;
}

/* ⚠ This is a <span role="button">, not a <button> — see itemHtml() in
   notifications.js. style.css:408 restyles every bare <button> with specificity
   (1,0,1) and the bell is in the DOM twice, so it has no id to outrank it with;
   as a <button> the dot rendered as a grey gradient pill. Everything below
   therefore also has to supply what a <button> used to give for free. */
div.bms.notifications .ncDot {
    display: inline-block;
    box-sizing: border-box;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #1f6feb;
    background-image: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0;
    line-height: 0;
    text-indent: -9999px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.14s ease, background-color 0.14s ease;
}

div.bms.notifications .ncDot:hover,
div.bms.notifications .ncDot:focus-visible {
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
    outline: none;
}

div.bms.notifications .ncItem:not(.unread) .ncDot {
    background: transparent;
    border: 1px solid #ccc;
}

div.bms.notifications .ncItem:not(.unread) .ncDot:hover,
div.bms.notifications .ncItem:not(.unread) .ncDot:focus-visible {
    border-color: #1f6feb;
    box-shadow: none;
}

div.bms.notifications .ncEmpty {
    padding: 26px 12px;
    text-align: center;
    color: #999;
}

/* --- footer / push ------------------------------------------------------- */

div.bms.notifications .ncPanelPush {
    padding: 8px 12px;
    background: #fffbe6;
    border-top: 1px solid #f0e6c0;
    text-align: center;
}

div.bms.notifications .ncEnablePush {
    font-size: 11px;
    color: #8a6d00;
    text-decoration: none;
    font-weight: 600;
}

div.bms.notifications .ncEnablePush:hover {
    text-decoration: underline;
}

/* The browser-tab twin of that row: no permission to offer, only an install.
   Blue rather than amber — it is a suggestion, not a pending action. */
div.bms.notifications .ncPanelInstall {
    background: #f2f7ff;
    border-top-color: #d8e6ff;
}

div.bms.notifications .ncInstallForPush {
    font-size: 11px;
    color: #1f6feb;
    text-decoration: none;
    font-weight: 600;
}

div.bms.notifications .ncInstallForPush:hover {
    text-decoration: underline;
}

div.bms.notifications .ncPanelFoot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

div.bms.notifications .ncPanelFoot a {
    font-size: 11px;
    color: #1f6feb;
    text-decoration: none;
}

div.bms.notifications .ncPanelFoot a:hover {
    text-decoration: underline;
}

div.bms.notifications .ncPrefs {
    color: #888 !important;
}

/* --- in-page toast ------------------------------------------------------- */
/* Layer 1 of the three delivery layers: always available, no permission, no
   HTTPS requirement. Lives on <body>, not inside the bell, so it survives the
   panel being closed. */

#ncToastStack {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
    pointer-events: none;
}

#ncToastStack .ncToast {
    pointer-events: auto;
    display: flex;
    gap: 9px;
    padding: 11px 12px;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-left: 4px solid #1f6feb;
    border-radius: 7px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
    font-size: 12px;
    color: #222;
    text-decoration: none;
    animation: ncToastIn 0.22s ease-out;
}

#ncToastStack .ncToast:hover {
    background: #f6f9ff;
}

#ncToastStack .ncToastTitle {
    font-weight: 700;
    margin-bottom: 2px;
}

#ncToastStack .ncToastText {
    color: #555;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#ncToastStack .ncToastClose {
    margin-left: auto;
    align-self: flex-start;
    color: #bbb;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    padding: 0 2px;
}

#ncToastStack .ncToastClose:hover {
    color: #666;
}

@keyframes ncToastIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 480px) {
    #ncToastStack {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    div.bms.notifications > div.list_items {
        width: 92vw;
    }
}

/* --- first-run permission card ------------------------------------------- */
/* Built by notifications/push.js on the first launch of the INSTALLED app, and
   only where the browser refused a permission request that had no user gesture
   behind it (Safari, Firefox). Its one job is to turn a tap into that gesture.

   ⚠ IT SITS ABOVE THE HOME-BAR INSET, like the install banner it replaces on
     that screen — without env(safe-area-inset-bottom) the primary action lands
     under the iPhone gesture indicator and half the taps miss.

   ⚠ THE BUTTON RULES ARE ROOTED AT THE id AND THAT IS THE ONLY REASON THEY WIN.
     style.css restyles every bare <button> through
     `button:not(#chatbase-bubble-button, …)`; :not() takes the specificity of
     its most specific argument, so that rule scores (1,0,1) and no class-only
     selector can beat it. `#ncPushPrompt .ncPushBtn` is (1,1,0). Re-root these
     at the class and both buttons come back as the portal's 2008 grey gradient. */

#ncPushPrompt {
    position: fixed;
    z-index: 9998;   /* under a modal, over the page */
    left: 12px;
    right: 12px;
    bottom: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));

    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    padding: 12px 14px;

    font-family: inherit;
    color: #1f2933;
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.18);

    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

#ncPushPrompt.ncPushIn {
    opacity: 1;
    transform: translateY(0);
}

#ncPushPrompt .ncPushIcon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    color: #1f6feb;
    background: #e7f0ff;
    border-radius: 10px;
}

#ncPushPrompt .ncPushText {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

#ncPushPrompt .ncPushText strong {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
}

#ncPushPrompt .ncPushText span {
    font-size: 12px;
    line-height: 1.45;
    color: #5b6472;
}

#ncPushPrompt .ncPushActions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

#ncPushPrompt .ncPushBtn {
    padding: 8px 14px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 8px;
    border: 1px solid #d5dbe4;
    background: #ffffff;
    background-image: none;
    color: #333f4d;
    box-shadow: none;
    text-shadow: none;
    height: auto;
}

#ncPushPrompt .ncPushBtn:hover {
    background: #f5f7fa;
    background-image: none;
    border-color: #c7cfda;
}

#ncPushPrompt .ncPushPrimary {
    color: #ffffff;
    background: #1f6feb;
    background-image: none;
    border-color: #1a5fcc;
}

#ncPushPrompt .ncPushPrimary:hover {
    color: #ffffff;
    background: #1a5fcc;
    background-image: none;
    border-color: #164fa8;
}

@media (max-width: 480px) {
    #ncPushPrompt {
        flex-wrap: wrap;
        gap: 10px;
    }
    #ncPushPrompt .ncPushText {
        flex: 1 1 160px;
    }
    #ncPushPrompt .ncPushActions {
        width: 100%;
        justify-content: flex-end;
    }
}
