/* AHSOFT Notification Center - desktop bell/dropdown + mobile sheet.
   Desktop mirrors the topbar gear menu (.user-menu-button / .user-menu-dropdown).
   Mobile rules live inside the .mobile-app namespace and use its design tokens. */

/* ------------------------------------------------------------------ desktop */
.notif-menu {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.notif-menu[hidden] {
  display: none !important;
}

.notif-bell-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.notif-bell-button:hover,
.notif-bell-button[aria-expanded="true"] {
  background: #f1f5f9;
  color: #0f172a;
}

.notif-bell-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  border-radius: 9px;
  background: #b91c1c;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.notif-badge[hidden] {
  display: none !important;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: 48px;
  z-index: 1200;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: min(520px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  overflow: hidden;
  text-align: left;
}

.notif-dropdown[hidden] {
  display: none !important;
}

body.compact-header .notif-bell-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

body.compact-header .notif-bell-button svg {
  width: 16px;
  height: 16px;
}

body.compact-header .notif-dropdown {
  top: 36px;
}

/* The compact bar puts the 30px bell 4px from the window top; keep the badge on screen. */
body.compact-header .notif-badge {
  top: -3px;
  right: -7px;
}

/* ------------------------------------------------------------ shared panel */
.notif-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

.notif-panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.notif-panel__count {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f2f5;
  color: #0b4f61;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.notif-panel__count[hidden] {
  display: none !important;
}

.notif-panel__mark-all {
  margin-left: auto;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #0b5f73;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.notif-panel__mark-all:hover:not(:disabled) {
  text-decoration: underline;
}

.notif-panel__mark-all:disabled {
  color: #94a3b8;
  cursor: default;
}

.notif-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notif-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notif-panel__entry + .notif-panel__entry {
  border-top: 1px solid #f1f5f9;
}

.notif-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: #ffffff;
  color: #334155;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.notif-item:hover,
.notif-item:focus-visible {
  background: #f8fafc;
}

.notif-item.is-unread {
  background: #f0f8fa;
}

.notif-item.is-unread:hover,
.notif-item.is-unread:focus-visible {
  background: #e3f1f5;
}

.notif-item__dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: transparent;
}

.notif-item.is-unread .notif-item__dot {
  background: #0b7285;
}

.notif-item__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.notif-item__title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.notif-item__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

.notif-item.is-unread .notif-item__title {
  font-weight: 700;
  color: #0f172a;
}

.notif-item__priority {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.notif-item__message {
  font-size: 12px;
  line-height: 1.35;
  color: #475569;
  overflow-wrap: anywhere;
}

.notif-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11px;
  color: #64748b;
}

.notif-item__ref {
  font-weight: 700;
  color: #334155;
}

/* The read/unread word is for screen readers; the dot + tint carry it visually. */
.notif-item__state {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.notif-panel__empty,
.notif-panel__loading {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  font-size: 13px;
  color: #64748b;
}

.notif-panel__error {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: #475569;
}

.notif-panel__error p {
  margin: 0 0 10px;
}

.notif-panel__retry,
.notif-panel__more {
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.notif-panel__more {
  display: block;
  margin: 10px auto 12px;
}

.notif-panel__more:disabled {
  color: #94a3b8;
  cursor: default;
}

.notif-panel__inline-error {
  margin: 0 14px 12px;
  font-size: 12px;
  color: #b91c1c;
  text-align: center;
}

/* Desktop topbar below 768px without the mobile shell: anchor like the gear menu. */
@media (max-width: 767px) {
  body:not(.mobile-shell-active) .notif-dropdown {
    position: fixed;
    top: 58px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 70px);
  }
}

/* ------------------------------------------------------------------- mobile */
@media (max-width: 767px) {
  .mobile-app .mobile-app__notification .notif-badge {
    top: -5px;
    right: -5px;
  }

  .mobile-app .mobile-notif-sheet {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom);
    max-width: 100vw;
    overflow: hidden;
  }

  .mobile-app .mobile-notif-sheet[hidden] {
    display: none !important;
  }

  .mobile-app .mobile-notif-sheet__bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    height: var(--mobile-shell-header-height, 52px);
    padding: 0 var(--mobile-space-3, 12px);
    border-bottom: 1px solid #c8dce2;
    box-sizing: border-box;
  }

  .mobile-app .mobile-notif-sheet__back:not([hidden]) {
    width: var(--mobile-touch-target, 44px);
    min-width: var(--mobile-touch-target, 44px);
    height: var(--mobile-touch-target, 44px) !important;
    min-height: var(--mobile-touch-target, 44px) !important;
    padding: 0;
    border: 1px solid #bdd5dd;
    border-radius: var(--mobile-radius, 10px);
    background: #eaf5f7;
    color: #073d52;
    font-size: 24px;
    line-height: 1;
  }

  .mobile-app .mobile-notif-sheet__panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .mobile-app .mobile-notif-sheet .notif-panel__header {
    flex-wrap: wrap;
    padding: var(--mobile-space-3, 12px) 14px;
  }

  .mobile-app .mobile-notif-sheet .notif-panel__title {
    font-size: var(--mobile-font-xl, 17px);
  }

  .mobile-app .mobile-notif-sheet .notif-panel__count {
    font-size: var(--mobile-font-xs, 11px);
  }

  .mobile-app .mobile-notif-sheet .notif-panel__mark-all {
    font-size: var(--mobile-font-md, 13px);
  }

  .mobile-app .mobile-notif-sheet .notif-item {
    padding: var(--mobile-space-3, 12px) 14px;
  }

  .mobile-app .mobile-notif-sheet .notif-item__title {
    font-size: var(--mobile-font-base, 14px);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mobile-app .mobile-notif-sheet .notif-item__message {
    font-size: var(--mobile-font-md, 13px);
  }

  .mobile-app .mobile-notif-sheet .notif-item__meta {
    font-size: var(--mobile-font-sm, 12px);
  }

  .mobile-app .mobile-notif-sheet .notif-panel__empty,
  .mobile-app .mobile-notif-sheet .notif-panel__loading,
  .mobile-app .mobile-notif-sheet .notif-panel__error {
    font-size: var(--mobile-font-base, 14px);
  }
}
