/* 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-).
 * 2. Notification bell + panel — ported from eudr-x style.css:506-788 +
 *    sidebar.css:744-753 (gt-topbar reshape), renamed ct-bell-*.
 *
 * Geometry, clamps, transitions, z-indices and keyframes are kept verbatim.
 * Colour: the parts that sit ON the bar (search field, bell button, badge)
 * use the --chrome-* tokens, which are Storm in both themes. The two surfaces
 * that open FROM the bar (results menu, notification panel) are solid content
 * surfaces (--surface-raised + --glass-shadow) and flip with the theme through
 * their tokens alone, so this file carries no body.dark-mode blocks. */

/* ═══════════════════════════ 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: var(--chrome-bg-2);
  border-color: var(--chrome-line);
  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(--chrome-active-ink);
}
.ct-global-search__icon {
  flex-shrink: 0;
  color: var(--chrome-dim);
  transition: color 0.18s;
}
.ct-global-search:hover .ct-global-search__icon,
.ct-global-search:focus-within .ct-global-search__icon {
  color: var(--chrome-ink);
}
.ct-global-search__input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: none;
  outline: none;
  color: var(--chrome-ink);
  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(--chrome-dim);
}
.ct-global-search__clear {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  background: var(--storm-lift-2);
  color: var(--chrome-ink);
  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: var(--storm-lift-3);
}
.ct-global-search__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--glass-shadow);
  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: var(--primary-soft);
}
.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;
  /* --surface-3, not the cyan wash: the hovered row already uses that. */
  background: var(--surface-3);
  color: var(--link);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

/* ═══════════════════════════ 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(--chrome-dim);
  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(--chrome-hover);
  color: var(--chrome-ink);
}
/* Unread count: cyan fill + Storm ink, same as the sidebar badges. The bar is
   Storm in both themes; the status reds flip to a light tone in dark mode, so
   a red fill would need a second, different-looking dark variant. */
.ct-bell-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--highlight);
  color: var(--highlight-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 10px;
  pointer-events: none;
}
/* Pops when the count grows (bell.js adds .is-new), not on every poll. */
.ct-bell-badge.is-new {
  animation: ctBadgePop 0.3s ease;
}
.ct-bell-badge[hidden] {
  display: none;
}
@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(--surface-raised);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  z-index: 2000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.ct-bell-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.ct-bell-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  opacity: 1;
}
.ct-bell-mark-all {
  background: none;
  border: none;
  color: var(--link);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.ct-bell-mark-all:hover {
  background: var(--primary-soft);
}
.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(--text-muted);
  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 var(--border);
  position: relative;
}
/* Cyan washes by alpha read on both the white and the dark raised surface,
   so unread and hover need no dark-mode variants. */
.ct-bell-item.unread {
  background: rgb(var(--cyan-rgb) / 0.07);
}
.ct-bell-item:hover {
  background: rgb(var(--cyan-rgb) / 0.14);
}
/* The row is not a control: this button covers it (EUDR .gt-row-main), so
   the whole row opens the item and keyboard focus draws on the row. */
.ct-bell-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.ct-bell-content::after {
  content: "";
  position: absolute;
  inset: 0;
}
.ct-bell-content:focus-visible {
  outline: none;
}
.ct-bell-content:focus-visible::after {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.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);
}
/* One plain dot per item, never an icon (EUDR, features doc #44): green
   while unread, grey once read. */
.ct-bell-icon {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}
.ct-bell-item.unread .ct-bell-icon {
  background: var(--accent);
}
.ct-bell-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
/* Read: quieter by colour and weight, never by opacity. */
.ct-bell-item.read .ct-bell-title {
  font-weight: 500;
  color: var(--text-muted);
}
.ct-bell-message {
  font-size: 12px;
  color: var(--text-muted);
  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;
  /* --text-subtle instead of 0.8 opacity on --text-muted, which put 11px
     text under 4.5:1. */
  color: var(--text-subtle);
  margin-top: 4px;
}
/* "Unread", for screen readers only (the dot is decoration). */
.ct-bell-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* The phone's sheet rows (core/phone.js phRow): the same dot, first. */
.ct-bell-ph-dot {
  order: -1;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}
.ct-bell-ph-dot.is-unread {
  background: var(--accent);
}
.ct-bell-ph-row:not(.is-unread) .ph-row-title {
  font-weight: 500;
  color: var(--text-muted);
}
/* Delete affordance — ported verbatim (eudr-x style.css:1646-1690). Inert:
 * the audit feed has no per-item delete endpoint; present so a future delete
 * needs no CSS (it would sit above .ct-bell-content's covering ::after). */
.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(--text-muted);
  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: var(--danger-hover-bg);
  color: var(--confirmed);
}

/* 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;
  }
}
