/* Header notification bell + dropdown (last 30 days from API) */

.header-notif-wrap {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
  z-index: 301;
}

.header-notif-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.header-notif-btn:hover {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.header-notif-btn.header-notif-btn--open {
  color: var(--accent2);
  border-color: rgba(59, 130, 246, 0.5);
}

.header-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.header-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, 70vh);
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header-notif-panel.hidden {
  display: none !important;
}

.header-notif-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.header-notif-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-notif-markall {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--accent2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.header-notif-markall:hover {
  text-decoration: underline;
}

.header-notif-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 6px 0;
}

.header-notif-empty {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.header-notif-item {
  padding: 10px 14px;
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
}

.header-notif-item:hover {
  background: rgba(59, 130, 246, 0.06);
}

.header-notif-item--unread {
  background: rgba(59, 130, 246, 0.09);
}

.header-notif-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.header-notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}

.header-notif-item-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.header-notif-item-image-wrap {
  margin: 6px 0 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.header-notif-item-image {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
}

.header-notif-item-meta {
  font-size: 10px;
  color: var(--dim);
  margin-top: 6px;
}

/* Mobile / narrow: tap targets; panel position may be overridden by notifications-ui.js (fixed) */
@media (max-width: 640px) {
  .header-notif-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 17px;
  }

  .header-notif-panel {
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(58vh, 400px);
    right: max(0px, env(safe-area-inset-right));
    top: calc(100% + 6px);
  }

  .header-notif-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 12px 10px;
  }

  .header-notif-head > span:first-of-type {
    font-size: 14px;
  }

  .header-notif-markall {
    margin-left: 0;
    align-self: stretch;
    text-align: center;
    padding: 10px 12px;
    min-height: 44px;
    font-size: 12px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.1);
  }

  .header-notif-list {
    padding: 4px 0;
  }

  .header-notif-item {
    padding: 12px 12px;
    min-height: 48px;
  }

  .header-notif-item-title {
    font-size: 13px;
  }

  .header-notif-item-body {
    font-size: 12px;
  }

  .header-notif-item-image {
    max-height: 140px;
  }

  .header-notif-empty {
    padding: 18px 14px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .header-notif-panel {
    max-height: min(58vh, 340px);
  }

  .header-notif-sub {
    font-size: 9px;
  }
}

/* Dropdown must not be clipped by the header flex row (esp. with overflow-x on body). */
.app-header,
.header-right {
  overflow: visible;
}
