/* topbar.css — WP4: the two live topbar affordances.
 *
 * 1. Expanding global search — icon-only 32px button that grows to 280px on
 *    hover / focus / typed text, with a sectioned results menu.
 *    Ported VERBATIM from eudr-x sidebar.css:378-539 (gt- → ct-), navy-mapped
 *    per spec-shell §16 (search field bg #222819 → #1a2836; accent tints
 *    rgba(92,120,82,α) → rgba(82,104,120,α); menu shadow forest → navy).
 * 2. Notification bell + panel — ported from eudr-x style.css:506-788 +
 *    sidebar.css:744-753 (gt-topbar reshape), renamed ct-bell-*, navy-mapped.
 *
 * Geometry, clamps, transitions, z-indices and keyframes are kept verbatim.
 * Dark-mode blocks ship here but stay inert until WP7 adds body.dark-mode.
 * The sidebar/topbar CHROME never flips (spec-theme §1.6) — only these two
 * content surfaces (menu + panel) invert in dark mode. */

/* ═══════════════════════════ Global search ═══════════════════════════ */
/* eudr-x sidebar.css:378-539 — icon-only → expands on hover/focus/typed text. */
.ct-global-search {
  position: relative;
  height: 32px;
  /* Collapsed: just the magnifier icon button width. */
  width: 32px;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
/* Expand on hover, while focused, or when there's text typed. */
.ct-global-search:hover,
.ct-global-search:focus-within,
.ct-global-search.has-text {
  width: 280px;
}
.ct-global-search__field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 8px 0 8px;
  width: 100%;
  height: 100%;
  transition: background 0.2s, border-color 0.2s, padding 0.2s;
  overflow: hidden;
  cursor: text;
}
.ct-global-search:hover .ct-global-search__field,
.ct-global-search:focus-within .ct-global-search__field,
.ct-global-search.has-text .ct-global-search__field {
  background: #1a2836;
  border-color: var(--sidebar-border);
  padding: 0 12px 0 14px;
}
.ct-global-search:focus-within .ct-global-search__field,
.ct-global-search.has-text .ct-global-search__field {
  border-color: var(--sidebar-active-border);
}
.ct-global-search__icon {
  flex-shrink: 0;
  color: var(--sidebar-text);
  transition: color 0.18s;
}
.ct-global-search:hover .ct-global-search__icon,
.ct-global-search:focus-within .ct-global-search__icon {
  color: var(--sidebar-text-active);
}
.ct-global-search__input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: none;
  outline: none;
  color: var(--sidebar-text-active);
  font-family: inherit;
  font-size: 0.82rem;
  /* Hidden while collapsed, fades in as the wrapper expands. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease 0.05s;
}
.ct-global-search:hover .ct-global-search__input,
.ct-global-search:focus-within .ct-global-search__input,
.ct-global-search.has-text .ct-global-search__input {
  opacity: 1;
  pointer-events: auto;
}
.ct-global-search__input::placeholder {
  color: var(--sidebar-text);
}
.ct-global-search__clear {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text-active);
  border-radius: 50%;
  line-height: 1;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Hidden while collapsed; fades in alongside the input. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease 0.05s;
}
.ct-global-search:hover .ct-global-search__clear,
.ct-global-search:focus-within .ct-global-search__clear,
.ct-global-search.has-text .ct-global-search__clear {
  opacity: 1;
  pointer-events: auto;
}
.ct-global-search__clear:hover {
  background: rgba(255, 255, 255, 0.18);
}
.ct-global-search__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg, #fff);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  box-shadow: 0 12px 28px -8px rgba(12, 25, 37, 0.22), 0 4px 10px -4px rgba(12, 25, 37, 0.14);
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 60;
  max-height: 320px;
  overflow-y: auto;
}
.ct-global-search__hint {
  padding: 6px 10px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.ct-global-search__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  user-select: none;
}
.ct-global-search__option:hover,
.ct-global-search__option.is-active {
  background: rgba(82, 104, 120, 0.12);
}
.ct-global-search__option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ct-global-search__option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ct-global-search__count {
  flex-shrink: 0;
  background: rgba(82, 104, 120, 0.16);
  color: var(--accent, #526878);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

/* ── Global search — dark mode (menu is a content surface, so it flips) ── */
body.dark-mode .ct-global-search__count {
  background: rgba(82, 104, 120, 0.32);
  color: #d1dfe8;
}
body.dark-mode .ct-global-search__menu {
  background: #0d1b2e;
  border-color: rgba(82, 104, 120, 0.3);
  color: var(--text);
}
body.dark-mode .ct-global-search__option:hover,
body.dark-mode .ct-global-search__option.is-active {
  background: rgba(82, 104, 120, 0.22);
}

/* ═══════════════════════════ Notification bell ═══════════════════════════ */
/* eudr-x style.css:506-554 + sidebar.css:744-753 topbar reshape (square hover
 * like the other icon buttons). Merged into one ct-bell-btn rule. */
.ct-bell-container {
  position: relative;
  display: flex;
  align-items: center;
}
.ct-bell-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.ct-bell-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.ct-bell-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 10px;
  pointer-events: none;
  animation: ctBadgePop 0.3s ease;
}
@keyframes ctBadgePop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Panel — eudr-x style.css:556-788. */
.ct-bell-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--card-bg, #ffffff);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(12, 25, 37, 0.14), 0 1px 4px rgba(12, 25, 37, 0.08);
  z-index: 2000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color, #cdd8e2);
}
body.dark-mode .ct-bell-panel {
  background: #122438;
  border-color: #1d3247;
}
.ct-bell-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #cdd8e2);
}
body.dark-mode .ct-bell-panel-header {
  border-color: #1d3247;
}
.ct-bell-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-color, #0e1823);
  opacity: 1;
}
body.dark-mode .ct-bell-panel-header h3 {
  color: #e8ecf2;
}
.ct-bell-mark-all {
  background: none;
  border: none;
  color: var(--accent, #526878);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.ct-bell-mark-all:hover {
  background: rgba(82, 104, 120, 0.12);
}
.ct-bell-panel-body {
  overflow-y: auto;
  flex: 1;
  max-height: 400px;
}
.ct-bell-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--muted-color, #3f5469);
  font-size: 14px;
  gap: 8px;
  text-align: center;
}
.ct-bell-empty svg {
  opacity: 0.3;
}
.ct-bell-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(12, 25, 37, 0.06);
  position: relative;
}
body.dark-mode .ct-bell-item {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}
.ct-bell-item.unread {
  background: rgba(82, 104, 120, 0.08);
}
body.dark-mode .ct-bell-item.unread {
  background: rgba(93, 141, 255, 0.08);
}
.ct-bell-item.clickable {
  cursor: pointer;
}
.ct-bell-item.clickable:hover {
  background: rgba(82, 104, 120, 0.12);
}
body.dark-mode .ct-bell-item.clickable:hover {
  background: rgba(93, 141, 255, 0.14);
}
.ct-bell-arrow {
  flex-shrink: 0;
  align-self: center;
  opacity: 0.3;
  transition: opacity 0.15s, transform 0.15s;
}
.ct-bell-item.clickable:hover .ct-bell-arrow {
  opacity: 0.7;
  transform: translateX(2px);
}
.ct-bell-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(82, 104, 120, 0.12);
  border-radius: 8px;
  margin-top: 2px;
}
.ct-bell-content {
  flex: 1;
  min-width: 0;
}
.ct-bell-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color, #0e1823);
  line-height: 1.3;
}
body.dark-mode .ct-bell-title {
  color: #e8ecf2;
}
.ct-bell-message {
  font-size: 12px;
  color: var(--muted-color, #3f5469);
  line-height: 1.4;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ct-bell-time {
  font-size: 11px;
  color: var(--muted-color, #3f5469);
  margin-top: 4px;
  opacity: 0.8;
}
.ct-bell-dot {
  position: absolute;
  top: 16px;
  right: 12px;
  width: 8px;
  height: 8px;
  background: var(--accent, #526878);
  border-radius: 50%;
  flex-shrink: 0;
}
/* Delete affordance — ported verbatim (eudr-x style.css:1646-1690). Inert in
 * phase 0 (bell.js's read-model has no per-item delete endpoint), present so a
 * future delete feature needs no CSS. */
.ct-bell-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted-color, #3f5469);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  padding: 0;
}
.ct-bell-item:hover .ct-bell-delete-btn {
  opacity: 0.7;
}
.ct-bell-delete-btn:hover {
  opacity: 1 !important;
  background: rgba(178, 49, 39, 0.12);
  color: #b23127;
}
body.dark-mode .ct-bell-delete-btn:hover {
  background: rgba(255, 100, 100, 0.15);
  color: #ff8080;
}
.ct-bell-item:has(.ct-bell-dot) .ct-bell-delete-btn {
  right: 28px;
}

/* Responsive: near-viewport-width panel on phones (eudr-x style.css:783-788). */
@media (max-width: 480px) {
  .ct-bell-panel {
    width: calc(100vw - 20px);
    right: -10px;
  }
}
