/* Search, the notifications tray and Quick actions (the panel bar's right end).
/* Unlayered, so these win over runeui's layers; on runeui's tokens (appearance.css, docs/theming.md).
/*
/* 2 Search   3 Trays   4 Notifications   5 Quick actions */

/* ======================================================================= 2 Search */

/* The palette (layouts/shared/_search, runeui's ui :command): a little wider than runeui's, its
/* list taller. Runwell's icons and avatars sit in the icon slot; the match is bold. */
.search-palette [data-command-dialog][data-slot="dialog-content"] { width: min(calc(100% - 2rem), 40rem); }
.search-palette [data-slot="command-list"] { max-height: min(28rem, 55dvh); }
.search-palette [data-slot="command-item-icon"] .icon { color: var(--muted-foreground); }
.search-palette [data-slot="command-item"][data-highlighted] [data-slot="command-item-icon"] .icon { color: var(--accent-foreground); }
.search-palette mark { background: none; color: inherit; font-weight: 600; }
.search-palette mark span { display: none; }

/* The results: groups by kind, a rule between them, rows of icon · title over the match · client. */
.search-results { display: block; }
.search-results__empty { padding: 1.5rem .5rem; color: var(--muted-foreground); text-align: center; }
.search-results__group { padding: .25rem; overflow: hidden; }
.search-results__group + .search-results__group { border-top: 1px solid var(--border); }
.search-results__heading { padding: .5rem .5rem .25rem; color: var(--faint-foreground); font-size: var(--ui-text-xs); font-weight: 500; letter-spacing: .04em; line-height: 1rem; text-transform: uppercase; }
.search-results__list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.search-results__result { display: flex; align-items: center; gap: .5rem; padding: 6px .5rem; border-radius: var(--ui-radius-lg); color: var(--foreground); text-decoration: none; user-select: none; }
/* The result under the pointer or keys: the brand's tint, its icon in the brand's colour. */
.search-results__result:is(:hover, :focus-visible) { background: var(--brand-tint); color: var(--foreground); box-shadow: none; }
.search-results__icon { color: var(--muted-foreground); }
.search-results__result:is(:hover, :focus-visible) .search-results__icon { color: var(--primary); }
.search-results__text { display: grid; flex: 1; gap: 2px; min-width: 0; }
.search-results__title, .search-results__excerpt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results__title { font-weight: 500; }
.search-results__excerpt, .search-results__context { color: var(--muted-foreground); font-size: var(--ui-text-xs); }
.search-results__context { flex: 0 0 auto; max-width: 35%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The match: bold in the text's colour, not a highlighter. */
.search-results mark { position: static; background: none; color: var(--foreground); font-weight: 600; white-space: inherit; }
.search-results mark span { display: none; }

/* /search: a field over every result, framed on the page. */
.search-page { display: flex; flex-direction: column; width: min(100%, 42rem); margin: 1rem auto 0; padding: .25rem; overflow: hidden; border: 1px solid var(--border); border-radius: var(--ui-radius-xl); background: var(--background); }
.search-page__form { margin: .25rem .25rem 0; }

/* ======================================================================= 3 Trays */

/* The bell and the quick actions, at the right of the panel bar across from the breadcrumb, each
   opening a popover below it. */
.panel-bar__context:has(.tray) { gap: .25rem; }
.tray { position: relative; z-index: 51; display: flex; flex-direction: column; align-items: flex-end; }

/* The bell and the +: runeui's outline icon buttons, round, the bell with a red dot while
   something is unread. */
.tray__toggle.ui-button { position: relative; border-radius: var(--ui-radius-full); }
.tray__toggle.ui-button[aria-expanded="true"] { background: var(--accent); }
html:not([data-hints]) .tray--notifications:has(.notification--item) .tray__toggle::after {
  content: ""; position: absolute; inset: 0 0 auto auto; width: .625rem; height: .625rem; border: 2px solid var(--background); border-radius: 50%; background: var(--destructive);
}

/* The bell's menu (notifications/_tray, ui :menu): a title, the newest six, then See all and Mark
/* all as read. Wider than a menu of actions, each item a notification's three lines. */
.notifications-menu [data-slot="menu-content"] { width: min(24rem, 100vw - 1.5rem); max-height: min(34rem, 100dvh - 5rem); }
.notifications-menu #notifications { display: block; }
.notifications-menu__empty { padding: 1.5rem 1rem; color: var(--muted-foreground); font-size: var(--ui-text-sm); text-align: center; }
.notifications-menu:has(.notification--item) .notifications-menu__empty { display: none; }
.notifications-menu:not(:has(.notification--item)) [data-slot="menu-link-item"]:has([href*="from_tray"]) { display: none; }
.notifications-menu__new { display: none; }
.notifications-menu:has([data-notifications-more]) .notifications-menu__new { display: inline; }
.notifications-menu:has([data-notifications-more]) .notifications-menu__all { display: none; }

/* The quick actions (quick_actions/_tray, runeui's ui :popover under the +): a label, where it goes
/* (the record picker), then a row per action. */
.quick-actions [data-slot="popover-content"] { width: min(18rem, 100vw - 1.5rem); gap: 0; padding: .25rem; }
.quick-actions__title { padding: .25rem .5rem 0; color: var(--muted-foreground); font-size: var(--ui-text-xs); }
.quick-actions__where { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.quick-actions__on { color: var(--muted-foreground); font-size: var(--ui-text-xs); }
.quick-actions__where [data-slot="combobox"] { flex: 1; min-width: 0; }
.quick-actions__where [data-slot="combobox-trigger"] { width: 100%; }
.quick-actions__list { display: flex; flex-direction: column; }
.quick-actions__item { width: 100%; border: 0; background: none; font: inherit; text-align: start; }
.quick-actions__item .icon { color: var(--muted-foreground); }

/* ======================================================================= 4 Notifications */

/* A notification (the bell's menu and /notifications): who, what and where, and when; on the page
/* an unread dot and the read toggle at the end, a rule between rows. */
.notification__link { display: flex; flex: 1; align-items: flex-start; gap: .75rem; min-width: 0; color: inherit; text-decoration: none; }
.notification__avatar { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--muted-foreground); }
.notification__avatar img { display: block; width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; }
.notification__content { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.notification__title { font-weight: 500; }
.notification__excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted-foreground); }
.notification__context { overflow: hidden; color: var(--faint-foreground); font-size: var(--ui-text-xs); text-overflow: ellipsis; white-space: nowrap; }
.notification__time { display: inline-flex; flex: none; align-items: center; gap: 6px; color: var(--faint-foreground); font-size: var(--ui-text-xs); white-space: nowrap; }
.notification--item .notification__link { padding-block: .25rem; }
.notification--item .notification__time::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--primary); }

/* On /notifications: a row per notification, the link taking the room, the toggle at the end. */
.notifications-list__items .notification { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; }
.notifications-list__items .notification + .notification { border-top: 1px solid var(--border); }
.notifications-list__items .notification[data-keyboard-current] { background: var(--brand-tint); }
.notifications-list__items .notification__link:focus-visible { outline: none; }
.notifications-list__items .notification:has(.notification__link:focus-visible) { background: var(--brand-tint); }
.notifications-list__items .notification.unread .notification__title::after { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-left: 6px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
.notification__toggle-form { display: contents; }

/* Mark read or unread: there on hover, focus or the j / k row, always on touch. */
.notification__toggle { position: relative; opacity: 0; }
.notification:is(:hover, :focus-within, [data-keyboard-current]) .notification__toggle, .notification__toggle:focus-visible { opacity: 1; }
@media (any-hover: none) { .notification__toggle { opacity: 1; } }
.notification__count { position: absolute; inset: -.25rem -.25rem auto auto; min-width: 1rem; padding: 0 4px; border-radius: 99rem; background: var(--primary); color: var(--background); font-size: .625rem; line-height: 1rem; }

/* /notifications: a card of the new over a card of the seen. */
.notifications-page { display: flex; flex-direction: column; gap: 1.5rem; width: min(100%, 42rem); margin-inline: auto; }
.notifications-page__lists { display: contents; }
.notifications-list [data-slot="card-content"] { padding-inline: 0; }
.notifications-list__empty { padding: 2.5rem 1rem; color: var(--muted-foreground); text-align: center; }
.notifications-list:has(.notification) .notifications-list__empty { display: none; }
.notifications-list--read:not(:has(.notification)) { display: none; }

/* ======================================================================= 5 Quick actions */

/* The modal (quick_actions#new, ui :dialog): its title and hint, where it goes, the form. */
.quick-action__body { display: flex; flex-direction: column; gap: 1rem; }
.quick-action__form { display: flex; flex-direction: column; gap: 1rem; }
.quick-action__optional { color: var(--muted-foreground); font-weight: 400; }
[data-slot="dialog-description"] [data-slot="kbd-group"] { vertical-align: baseline; }

/* The picker in the modal: as wide as the field. */
.quick-action__where [data-slot="combobox"], .quick-action__where [data-slot="combobox-trigger"] { width: 100%; }

/* Documents: the drop target fills the form; the file input covers it, unseen, to take the click
/* and the drop. */
.quick-action__upload { position: relative; width: 100%; height: auto; min-height: 6rem; padding: 1rem; border: 1px dashed var(--input); white-space: normal; font-weight: 400; font-size: var(--ui-text-xs); cursor: pointer; }
.quick-action__upload input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.quick-action__upload:has(input[type="file"]:focus-visible) { box-shadow: var(--ui-focus-ring); }

/* The task's quick action (quick_actions/task): where it goes beside what needs doing on the first
/* row, then its rows of fields (two to a row: lead and who else, due and the client switch) full
/* width. Its form takes no box (display: contents) so the title joins the body's grid; it still
/* submits as one. Stacked on a phone. */
.quick-action__single { display: contents; }
.quick-action__row { align-items: end; }
.quick-action__switch { display: flex; align-items: center; min-height: var(--ui-h); }
@media (min-width: 640px) {
  .quick-action__body:has(.quick-action__lead-field) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
  .quick-action__body:has(.quick-action__lead-field) .quick-action__form { display: contents; }
  .quick-action__body:has(.quick-action__lead-field) :is(.quick-action__single > *, .quick-action__row, .form-actions) { grid-column: 1 / -1; }
  .quick-action__body:has(.quick-action__lead-field) .quick-action__where { grid-row: 1; grid-column: 1; }
  .quick-action__body:has(.quick-action__lead-field) .quick-action__single .quick-action__lead-field { grid-row: 1; grid-column: 2; }
}

