/*
 * Global search. Loaded on every page by the layout: the header search box (left of the
 * user name, "Search: ctrl + alt + s", square blue magnifier) and the /search results grid.
 * Tokens only.
 */

/* ------------------------------------------------------------ header box */

/* When the bar runs short of room the box gives way first (large flex-shrink), down to 80px. */
.header-search { display: flex; align-self: center; flex: 0 100 auto; min-width: 138px; margin: 0 16px 0 auto; padding-left: 16px; }
.header-search + .user-menu { margin-left: 0; }
.header-search input {
  flex: 1 1 auto;
  width: 185px;
  min-width: 0;
  height: 36px;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text-input);
  background: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-right: 0;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.header-search input::placeholder { color: var(--color-text-muted); opacity: 1; }
.header-search input:focus { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.header-search button {
  flex: none;
  width: 42px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  color: var(--color-on-primary);
  background: var(--color-primary);
  border: 0;
  border-radius: 0;
  cursor: pointer;
}
.header-search button:hover { background: var(--color-primary-hover); }
.header-search button:focus-visible { outline: 2px solid var(--color-topbar-text); outline-offset: -4px; }

/* With the full menu showing, below about 1060px only the magnifier stays (it opens /search). */
@media (max-width: 1059px) and (min-width: 981px) {
  .header-search { min-width: 0; }
  .header-search input { display: none; }
}
@media (max-width: 600px) {
  .header-search { min-width: 0; margin-right: 10px; }
  .header-search input { display: none; }
  .header-search button { width: 38px; }
}

/* ------------------------------------------------------------ results page */

.search-page-form input[type="search"] { width: 760px; }
.search-hint { max-width: 760px; margin: 18px 0 0; font-size: 15px; color: var(--color-text-muted); }
.search-hint kbd {
  display: inline-block;
  padding: 0 5px;
  font-family: inherit;
  font-size: 12px;
  line-height: 18px;
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-chip);
}

.search-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; margin: 22px 0 18px; font-size: 18px; color: var(--color-text); }
.search-summary strong { font-weight: 400; }

.search-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 40px; align-items: start; }
.search-box { min-width: 0; background: var(--color-surface); border: 1px solid var(--color-border); }
.search-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 10px 20px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  box-shadow: inset 5px 0 0 var(--color-th-bar);
}
.search-box-head h2 { margin: 0; overflow: hidden; font-size: 20px; font-weight: 600; line-height: 28px; white-space: nowrap; text-overflow: ellipsis; color: var(--color-text-muted); }
.search-box-count { flex: none; font-size: 14px; color: var(--color-text-muted); }

.search-rows { margin: 0; padding: 0; list-style: none; }
.search-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-height: 60px;
  padding: 10px 14px 10px 17px;
  border-bottom: 1px solid var(--color-border);
  box-shadow: inset 5px 0 0 var(--tone, var(--color-th-bar));
}
.search-tile {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-inverse);
  background: var(--tone, var(--color-th-bar));
}
.search-ring { display: flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px; }
.search-ring .state-icon { width: 36px; height: 36px; }
.search-row-text { min-width: 0; overflow-wrap: break-word; }
.search-row-text a { font-size: 17px; line-height: 22px; }
.search-row-sub { display: block; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--color-text-muted); }
/* Each part stays on one line unless it alone is wider than the box. */
.search-row-sub > span { display: inline-block; max-width: 100%; }
.search-row.is-muted .search-tile { opacity: .55; }
.search-row.is-muted .search-row-text a { color: var(--color-text-muted); }

.search-box-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 10px 20px; font-size: 15px; background: var(--color-surface-alt); }
.search-box-types { font-size: 13px; color: var(--color-text-muted); }
.search-none { margin: 24px 0 0; color: var(--color-text-muted); }

.tone-red { --tone: var(--module-people); }
.tone-cyan { --tone: var(--module-resources); }
.tone-teal { --tone: var(--state-draft); }
.tone-purple { --tone: var(--module-dashboard); }
.tone-blue { --tone: var(--color-primary); }
.tone-green { --tone: var(--color-create); }
.tone-orange { --tone: var(--color-warning); }
.tone-grey { --tone: var(--status-inactive); }
.tone-dark { --tone: var(--item-completed); }
.tone-state-enquiry { --tone: var(--state-enquiry); }
.tone-state-draft { --tone: var(--state-draft); }
.tone-state-quotation { --tone: var(--state-quotation); }
.tone-state-order { --tone: var(--state-order); }

@media (max-width: 1180px) {
  .search-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
}
@media (max-width: 720px) {
  .search-grid { grid-template-columns: minmax(0, 1fr); }
  .search-summary { font-size: 16px; }
}
