/* Notifications: top-bar panel (#notificationsmodal in modals.php) and notifications.php.
   Markup: functions_notifications.php bcNotifItemHtml() + notifications_content.php.
   Behaviour: scripts/bc-notifications.js (open/close, anchoring, mark all as read). */

/* ---------- Panel shell ---------- */
#notificationsmodal {
  --bcnt-top: 64px;
  --bcnt-right: 16px;
  position: fixed !important;
  top: var(--bcnt-top) !important;
  right: var(--bcnt-right) !important;
  left: auto !important;
  bottom: auto !important;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: auto !important;
  max-height: min(620px, calc(100vh - var(--bcnt-top) - 16px));
  padding: 0 !important;
  margin: 0 !important;
  flex-direction: column;
  overflow: hidden !important;
  border-radius: 18px !important;
  background: var(--bc-surface, #fff) !important;
  box-shadow: 0 0 0 1px var(--bc-line, rgba(15, 15, 25, 0.07)), var(--bc-shadow-3, 0 18px 48px -12px rgba(16, 16, 30, 0.18)) !important;
  transform: translateY(-6px) scale(0.98) !important;
  transform-origin: calc(100% - 28px) 0;
  opacity: 0;
  /* Closed but still in the layout (the theme can leave it display:block): never catch clicks,
     or the invisible items sit on top of the page and hijack buttons under them */
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s var(--bc-ease, ease), transform 0.22s var(--bc-ease, ease), visibility 0s linear 0.22s !important;
  z-index: 1065 !important;
}
#notificationsmodal.bcnt-open {
  transform: none !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.18s var(--bc-ease, ease), transform 0.22s var(--bc-ease, ease), visibility 0s !important;
}
#notificationsmodal_content {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* "Show all notifications" button (modals.php) becomes the panel footer */
#notificationsmodal > button {
  flex: 0 0 auto;
  display: block;
  width: 100%;
  margin: 0 !important;
  padding: 12px 16px !important;
  height: auto !important;
  border: 0 !important;
  border-top: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07)) !important;
  border-radius: 0 !important;
  background: var(--bc-surface, #fff) !important;
  color: var(--bc-accent, #5b4bd1) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  box-shadow: none !important;
  line-height: 1.3 !important;
}
#notificationsmodal > button:hover { background: var(--bc-surface-2, #f6f6f8) !important; }

/* ---------- Header (sticky glass) ---------- */
.bcnt-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07));
}
.bcnt-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--bc-ink, #0b0b10);
  letter-spacing: -0.01em;
}
.bcnt-markall {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--bc-accent, #5b4bd1);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.2s var(--bc-ease, ease);
}
.bcnt-markall:hover { background: rgba(91, 75, 209, 0.08); }
.bcnt-markall:focus-visible { outline: none; box-shadow: var(--bc-ring, 0 0 0 4px rgba(91, 75, 209, 0.16)); }
.bcnt-markall[disabled] { color: var(--bc-faint, #9a9aa5); cursor: default; background: transparent; }

/* ---------- Groups ---------- */
.bcnt-group-label {
  padding: 12px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bc-muted, #6b6b76);
}
.bcnt-list { display: flex; flex-direction: column; padding: 0 6px 6px; }

/* ---------- Item ---------- */
a.bcnt-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 28px 10px 10px;
  border-radius: 12px;
  color: var(--bc-ink-2, #3a3a44) !important;
  text-decoration: none !important;
  transition: background-color 0.15s var(--bc-ease, ease);
}
a.bcnt-item:hover { background: var(--bc-surface-2, #f6f6f8); }
a.bcnt-item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(91, 75, 209, 0.35); }
a.bcnt-item.is-unread { background: rgba(91, 75, 209, 0.055); }
a.bcnt-item.is-unread:hover { background: rgba(91, 75, 209, 0.09); }
a.bcnt-item + a.bcnt-item { margin-top: 2px; }

.bcnt-av {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
}
.bcnt-av > img,
.bcnt-av > .bc-av {
  width: 44px !important;
  height: 44px !important;
  margin: 0 !important;
}
.bcnt-av > img { display: block; object-fit: cover; }
.bcnt-av > .bc-av[hidden] { display: none !important; }
.bcnt-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  color: #fff;
  background: var(--bcnt-tone, #5b4bd1);
  box-shadow: 0 0 0 2px var(--bc-surface, #fff);
}
.bcnt-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--bcnt-tone, #5b4bd1);
  background: color-mix(in srgb, var(--bcnt-tone, #5b4bd1) 12%, var(--bc-surface));
}

/* Type tones */
.bcnt-k-vote    { --bcnt-tone: var(--bc-green, #16a34a); }
.bcnt-k-dispute { --bcnt-tone: var(--bc-red, #e11d48); }
.bcnt-k-react   { --bcnt-tone: #e2336b; }
.bcnt-k-comment { --bcnt-tone: var(--bc-blue, #2563eb); }
.bcnt-k-promo   { --bcnt-tone: var(--bc-amber, #f59e0b); }
.bcnt-k-verify  { --bcnt-tone: var(--bc-accent, #5b4bd1); }
.bcnt-k-friend  { --bcnt-tone: #0891b2; }
.bcnt-k-academy { --bcnt-tone: var(--bc-violet, #7a3aa8); }
.bcnt-k-event   { --bcnt-tone: var(--bc-clay, #d4744f); }
.bcnt-k-order   { --bcnt-tone: #0d9488; }
.bcnt-k-message { --bcnt-tone: var(--bc-blue, #2563eb); }
.bcnt-k-system  { --bcnt-tone: var(--bc-muted, #6b6b76); }
.bcnt-item.bcnt-good { --bcnt-tone: var(--bc-green, #16a34a); }
.bcnt-item.bcnt-bad  { --bcnt-tone: var(--bc-red, #e11d48); }

.bcnt-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 1px;
}
.bcnt-text {
  font-size: 14px;
  line-height: 1.42;
  color: var(--bc-ink-2, #3a3a44);
  overflow-wrap: anywhere;
  hyphens: auto;
}
.bcnt--panel .bcnt-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bcnt-text strong,
.bcnt-text .bcnt-actor { font-weight: 650; color: var(--bc-ink, #0b0b10); }
.bcnt-text em { color: var(--bc-muted, #6b6b76); }
.bcnt-text .w3-opacity { opacity: 1 !important; }
.bcnt-time {
  font-size: 12px;
  color: var(--bc-faint, #9a9aa5);
}
a.bcnt-item.is-unread .bcnt-time { color: var(--bc-accent, #5b4bd1); font-weight: 600; }
.bcnt-dot {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--bc-accent, #5b4bd1);
  box-shadow: 0 0 0 3px rgba(91, 75, 209, 0.14);
}

/* Legacy inline markup inside texts: badge() tags become coloured text, points/belt spans small pills */
.bcnt-text .w3-tag {
  display: inline !important;
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
  box-shadow: none !important;
  font-size: inherit !important;
  font-weight: 500;
  line-height: inherit !important;
  color: var(--bc-ink, #0b0b10) !important;
}
.bcnt-text .w3-tag i { margin-right: 4px; }
.bcnt-text span.w3-green:not(.w3-tag),
.bcnt-text span.w3-red:not(.w3-tag) {
  display: inline-block;
  padding: 0 7px !important;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}
.bcnt-text span.w3-green:not(.w3-tag) { background: rgba(22, 163, 74, 0.12) !important; color: #15803d !important; }
.bcnt-text span.w3-red:not(.w3-tag) { background: rgba(225, 29, 72, 0.1) !important; color: #be123c !important; }
/* whole-text red wrappers (types 26, 44) read as plain text; the badge tone carries the meaning */
.bcnt-k-dispute .bcnt-text > span.w3-red:first-child,
.bcnt-k-system .bcnt-text > span.w3-red:first-child {
  display: inline;
  padding: 0 !important;
  background: none !important;
  color: inherit !important;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}
.bcnt-text span[class*="w3-"][style*="padding"]:not(.w3-green):not(.w3-red):not(.w3-opacity):not(.w3-tag) {
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* Reactions (smiley PNGs rendered as the Font Awesome reaction icons) */
.bcnt-react { display: inline-grid; place-items: center; width: 22px; height: 20px; margin: 0 1px; border-radius: 999px; vertical-align: -4px; background: rgba(91, 75, 209, 0.10); color: var(--bc-accent, #5b4bd1); }
.bcnt-react i { font-size: 11px; }
/* The quoted post / photo text under the sentence, two lines at most */
.bcnt-quote { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; color: var(--bc-muted, #6b6b76); font-size: 0.93em; }
.bcnt-quote .w3-opacity { opacity: 1 !important; }

/* ---------- Empty state ---------- */
.bcnt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 36px 24px 40px;
}
.bcnt-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border-radius: 50%;
  font-size: 22px;
  color: var(--bc-accent, #5b4bd1);
  background: rgba(91, 75, 209, 0.08);
}
.bcnt-empty-title { font-size: 15px; font-weight: 650; color: var(--bc-ink, #0b0b10); }
.bcnt-empty-sub { font-size: 13px; color: var(--bc-muted, #6b6b76); max-width: 260px; }

/* Skeleton inside the panel */
#notificationsmodal_content > .bc-skel { padding: 8px 6px; }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 767.98px) {
  #notificationsmodal {
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100%;
    max-width: none;
    max-height: 86vh;
    max-height: 86dvh;
    border-radius: 22px 22px 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    background: var(--bc-surface, #fff) !important;
    transform: translateY(100%) !important;
    transform-origin: 50% 100%;
    opacity: 1;
    transition: transform 0.32s var(--bc-ease, ease), visibility 0s linear 0.32s !important;
    z-index: 1070 !important;
  }
  #notificationsmodal.bcnt-open { transform: none !important; transition: transform 0.32s var(--bc-ease, ease), visibility 0s !important; }
  #notificationsmodal::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    z-index: 3;
    width: 38px;
    height: 4px;
    margin-left: -19px;
    border-radius: 999px;
    background: rgba(15, 15, 25, 0.16);
  }
  .bcnt-head { padding-top: 20px; }
  .bcnt-list { padding: 0 4px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  #notificationsmodal { transition: none !important; }
}

/* ---------- Full page (notifications.php) ---------- */
.bcnt-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.bcnt-page-title { margin: 0 !important; }
.bcnt-page-head .bcnt-filter {
  width: auto !important;
  max-width: 100%;
  min-width: 200px;
  margin: 0 !important;
}
.bcnt--page .bcnt-group-label { padding-left: 4px; padding-right: 4px; }
.bcnt--page .bcnt-list { padding: 0 0 6px; margin: 0 -6px; }
@media (max-width: 575.98px) {
  .bcnt-page-head .bcnt-filter { width: 100% !important; }
}

/* ---------- Settings link, page actions and category chips ---------- */
.bcnt-head-actions,
.bcnt-page-actions { display: inline-flex; align-items: center; gap: 4px; }
.bcnt-gear {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--bc-muted, #6b6b76) !important;
  text-decoration: none !important;
  transition: background-color 0.2s var(--bc-ease, ease), color 0.2s var(--bc-ease, ease);
}
.bcnt-gear:hover { background: var(--bc-surface-2, #f6f6f8); color: var(--bc-ink, #0b0b10) !important; }
.bcnt-gear:focus-visible { outline: none; box-shadow: var(--bc-ring, 0 0 0 4px rgba(91, 75, 209, 0.16)); }
.bcnt-page-actions .bcnt-gear { width: 40px; height: 40px; box-shadow: inset 0 0 0 1px var(--bc-line-strong, rgba(15, 15, 25, 0.12)); }

.bcnt-chips {
  display: flex;
  gap: 8px;
  margin: 6px -4px 6px;
  padding: 2px 4px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.bcnt-chips::-webkit-scrollbar { display: none; }
.bcnt-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--bc-surface-2, #f6f6f8);
  box-shadow: inset 0 0 0 1px var(--bc-line-strong, rgba(15, 15, 25, 0.12));
  color: var(--bc-ink-2, #3a3a44) !important;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background-color 0.15s var(--bc-ease, ease);
}
.bcnt-chip:hover { background: var(--bc-surface-3, #eeeef2); }
.bcnt-chip.is-active { background: var(--bc-ink, #0b0b10); color: var(--bc-on-ink) !important; box-shadow: none; }
.bcnt-chip:focus-visible { outline: none; box-shadow: var(--bc-ring, 0 0 0 4px rgba(91, 75, 209, 0.16)); }
