/* ==========================================================================
   Global search — scoped tokens + shared atoms
   --------------------------------------------------------------------------
   The .search-dialog wrapper owns a full set of --sd-* tokens for the modal
   UI (added in phase B). The shared atoms below — .entity-glyph, .entity-dot,
   and .status-chip — also appear outside the dialog elsewhere in the app, so
   their required palette lives on :root with the sd_ prefix so we don't
   collide with app-level tokens.
   ========================================================================== */

:root {
  /* Entity palette (used by .entity-glyph and .entity-dot) */
  --sd-entity-events:    #5C7691;
  --sd-entity-tickets:   #B67A1E;
  --sd-entity-customers: #6B4C8A;
  --sd-entity-invoices:  #4B6B3E;
  --sd-entity-vehicles:  #8F6B3E;

  /* Status palette (used by .status-chip) */
  --sd-status-held-bg:       #F5EBD6;
  --sd-status-held-fg:       #B67A1E;
  --sd-status-invoiced-bg:   #E8EEDB;
  --sd-status-invoiced-fg:   #4B6B3E;
  --sd-status-stopped-bg:    #F4F1EA;
  --sd-status-stopped-fg:    #8F8778;
  --sd-status-processing-bg: #E2E8EF;
  --sd-status-processing-fg: #5C7691;
  --sd-status-rejected-bg:   #F2DFD9;
  --sd-status-rejected-fg:   #9B3B32;
  --sd-status-open-bg:       #F4F1EA;
  --sd-status-open-fg:       #3C3830;
  --sd-status-paid-bg:       #E8EEDB;
  --sd-status-paid-fg:       #4B6B3E;
  --sd-status-unpaid-bg:     #F5EBD6;
  --sd-status-unpaid-fg:     #B67A1E;
  --sd-status-overdue-bg:    #F2DFD9;
  --sd-status-overdue-fg:    #9B3B32;
}

/* ==========================================================================
   EntityGlyph — 26x26 colored rounded square with a white mono letter
   ========================================================================== */

.entity-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #FFFFFF;
  line-height: 1;
}

.entity-glyph--events    { background: var(--sd-entity-events); }
.entity-glyph--tickets   { background: var(--sd-entity-tickets); }
.entity-glyph--customers { background: var(--sd-entity-customers); }
.entity-glyph--invoices  { background: var(--sd-entity-invoices); }
.entity-glyph--vehicles  { background: var(--sd-entity-vehicles); }

/* ==========================================================================
   EntityDot — 8x8 circle
   ========================================================================== */

.entity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.entity-dot--events    { background: var(--sd-entity-events); }
.entity-dot--tickets   { background: var(--sd-entity-tickets); }
.entity-dot--customers { background: var(--sd-entity-customers); }
.entity-dot--invoices  { background: var(--sd-entity-invoices); }
.entity-dot--vehicles  { background: var(--sd-entity-vehicles); }

/* ==========================================================================
   StatusChip — small status pill on tickets and invoices
   ========================================================================== */

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-family: "DM Sans", -apple-system, system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.4;
  white-space: nowrap;
}

.status-chip--held       { background: var(--sd-status-held-bg);       color: var(--sd-status-held-fg); }
.status-chip--invoiced   { background: var(--sd-status-invoiced-bg);   color: var(--sd-status-invoiced-fg); }
.status-chip--stopped    { background: var(--sd-status-stopped-bg);    color: var(--sd-status-stopped-fg); }
.status-chip--processing { background: var(--sd-status-processing-bg); color: var(--sd-status-processing-fg); }
.status-chip--rejected   { background: var(--sd-status-rejected-bg);   color: var(--sd-status-rejected-fg); }
.status-chip--open       { background: var(--sd-status-open-bg);       color: var(--sd-status-open-fg); }
.status-chip--paid       { background: var(--sd-status-paid-bg);       color: var(--sd-status-paid-fg); }
.status-chip--unpaid     { background: var(--sd-status-unpaid-bg);     color: var(--sd-status-unpaid-fg); }
.status-chip--overdue    { background: var(--sd-status-overdue-bg);    color: var(--sd-status-overdue-fg); }

/* ==========================================================================
   .search-dialog — full set of design tokens for the modal UI (phase B/C)
   Scoped so they don't leak to the rest of the app.
   ========================================================================== */

.search-dialog {
  --sd-bg:          #FAF8F3;
  --sd-bg-elev:     #FFFFFF;
  --sd-bg-sunk:     #F4F1EA;
  --sd-ink:         #1C1A15;
  --sd-ink-2:       #3C3830;
  --sd-ink-3:       #6B6557;
  --sd-ink-4:       #8F8778;
  --sd-rule:        #E8E3D3;
  --sd-rule-strong: #D9D3BF;

  --sd-accent-hold:        #B67A1E;
  --sd-accent-hold-bg:     #F5EBD6;
  --sd-accent-invoiced:    #4B6B3E;
  --sd-accent-invoiced-bg: #E8EEDB;
  --sd-accent-stopped:     #8F8778;
  --sd-accent-processing:  #5C7691;
  --sd-accent-processing-bg: #E2E8EF;
  --sd-accent-reject:      #9B3B32;
  --sd-accent-reject-bg:   #F2DFD9;

  --sd-accent-event:    #5C7691;
  --sd-accent-customer: #6B4C8A;
  --sd-accent-vehicle:  #8F6B3E;

  --sd-serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sd-sans:  "DM Sans", -apple-system, system-ui, sans-serif;
  --sd-mono:  "JetBrains Mono", ui-monospace, Menlo, monospace;

  --sd-radius:    6px;
  --sd-radius-lg: 10px;

  --sd-shadow-sm: 0 1px 2px rgba(28,26,21,.05);
  --sd-shadow-md: 0 2px 12px rgba(28,26,21,.08), 0 1px 3px rgba(28,26,21,.06);
  --sd-shadow-lg: 0 32px 80px -20px rgba(28,26,21,.28), 0 4px 12px rgba(28,26,21,.08);
}

/* ==========================================================================
   SearchTrigger — topbar button that opens the dialog
   ========================================================================== */

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  padding: 7px 11px;
  border-radius: 6px;
  background: #F4F1EA;
  border: 1px solid #E8E3D3;
  color: #6B6557;
  font-family: "DM Sans", -apple-system, system-ui, sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}

.search-trigger:hover {
  background: #FFFFFF;
  border-color: #D9D3BF;
}

.search-trigger:focus-visible {
  outline: 2px solid #1C1A15;
  outline-offset: 2px;
}

.search-trigger__icon {
  color: #8F8778;
  flex: 0 0 auto;
}

.search-trigger__placeholder {
  flex: 1;
  text-align: left;
  color: #6B6557;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-trigger__kbd {
  display: inline-flex;
  gap: 3px;
  flex: 0 0 auto;
}

.search-trigger__kbd kbd {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  padding: 1px 5px 0;
  background: #FFFFFF;
  border: 1px solid #D9D3BF;
  border-radius: 3px;
  color: #8F8778;
  line-height: 1.4;
}

/* ==========================================================================
   SearchDialog — centered modal shell
   ========================================================================== */

.search-dialog {
  position: fixed;
  inset: 0;
  z-index: 110;
}

.search-dialog[hidden] {
  display: none;
}

.search-dialog__dim {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 21, .32);
  z-index: 100;
}

.search-dialog__panel {
  position: fixed;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 100vw - 32px);
  max-height: 76vh;
  background: var(--sd-bg-elev);
  border: 1px solid var(--sd-rule-strong);
  border-radius: var(--sd-radius-lg);
  box-shadow: var(--sd-shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 110;
}

.search-dialog[data-motion="full"] .search-dialog__panel {
  animation: sd-open 140ms ease-out;
}

.search-dialog[data-motion="fade"] .search-dialog__panel {
  animation: sd-fade 140ms ease-out;
}

@keyframes sd-open {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes sd-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Input row */

.search-dialog__input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sd-rule);
}

.search-dialog__input-icon {
  color: var(--sd-ink-3);
  flex: 0 0 auto;
}

.search-dialog__input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--sd-sans);
  font-size: 17px;
  color: var(--sd-ink);
  min-width: 0;
  padding: 0;
}

.search-dialog__input::placeholder {
  color: var(--sd-ink-4);
}

.search-dialog__esc {
  flex: 0 0 auto;
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-4);
}

/* Filter tokens — committed chips rendered inline in the input row */

.search-dialog__tokens {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.search-dialog__tokens:empty {
  display: none;
}

.search-dialog__token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--sd-bg-sunk);
  border: 1px solid var(--sd-rule);
  font-family: var(--sd-mono);
  font-size: 11px;
  line-height: 1.4;
}

.search-dialog__token-k {
  color: var(--sd-ink-4);
}

.search-dialog__token-v {
  color: var(--sd-ink);
  font-weight: 500;
}

.search-dialog__token-x {
  background: none;
  border: 0;
  padding: 0 0 0 2px;
  margin: 0;
  color: var(--sd-ink-4);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.search-dialog__token-x:hover {
  color: var(--sd-ink);
}

/* FilterSuggestRow — suggestion strip below the input */

.search-dialog__suggest {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 18px;
  background: var(--sd-bg-sunk);
  border-bottom: 1px solid var(--sd-rule);
}

.search-dialog__suggest-label {
  font-family: var(--sd-sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sd-ink-4);
}

.search-dialog__suggest-chip {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--sd-bg-elev);
  border: 1px solid var(--sd-rule);
  font-family: var(--sd-mono);
  font-size: 10.5px;
  color: var(--sd-ink-3);
  cursor: pointer;
  line-height: 1.5;
}

.search-dialog__suggest-chip:hover {
  border-color: var(--sd-ink);
  color: var(--sd-ink);
}

.search-dialog__esc kbd {
  font-family: var(--sd-mono);
  font-size: 10.5px;
  padding: 1px 5px 0;
  background: var(--sd-bg-sunk);
  border: 1px solid var(--sd-rule-strong);
  border-radius: 3px;
  color: var(--sd-ink-4);
  line-height: 1.4;
}

/* Results region */

.search-dialog__results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 10px;
}

/* Footer */

.search-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--sd-bg-sunk);
  border-top: 1px solid var(--sd-rule);
  font-family: var(--sd-sans);
  font-size: 11px;
  color: var(--sd-ink-4);
}

.search-dialog__hints {
  display: inline-flex;
  gap: 14px;
  flex-wrap: wrap;
}

.search-dialog__hints span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.search-dialog__hints kbd,
.search-dialog__footer kbd {
  font-family: var(--sd-mono);
  font-size: 10.5px;
  padding: 1px 5px 0;
  background: var(--sd-bg-sunk);
  border: 1px solid var(--sd-rule-strong);
  border-radius: 3px;
  color: var(--sd-ink-4);
  line-height: 1.4;
}

.search-dialog__brand {
  color: var(--sd-ink-4);
}

/* ==========================================================================
   ResultsList — groups, rows, empty states (phase C)
   ========================================================================== */

.search-dialog .sd-jump-header {
  padding: 14px 18px 4px;
}

.search-dialog .sd-jump-header__title {
  margin: 0;
  font-family: var(--sd-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sd-ink-3);
}

.search-dialog .sd-jump-header__sub {
  margin: 2px 0 0;
  font-family: var(--sd-sans);
  font-size: 12.5px;
  color: var(--sd-ink-4);
}

.search-dialog .sd-empty {
  padding: 24px 18px;
  color: var(--sd-ink-4);
  font-family: var(--sd-sans);
  font-size: 13px;
  text-align: center;
}

.search-dialog .sd-group {
  padding: 0;
  margin: 0;
}

.search-dialog .sd-group__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px 6px;
  font-family: var(--sd-sans);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sd-ink-4);
}

.search-dialog .sd-group__label {
  margin: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-weight: inherit;
}

.search-dialog .sd-group__count {
  margin-left: auto;
  font-family: var(--sd-mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--sd-ink-3);
}

.search-dialog .sd-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-dialog .sd-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 8px 18px;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.search-dialog .sd-row:hover {
  background: var(--sd-bg-sunk);
}

.search-dialog .sd-row[aria-selected="true"] {
  background: var(--sd-bg-sunk);
  border-left-color: var(--sd-ink);
  padding-left: 16px;
}

.search-dialog .sd-row__body {
  min-width: 0;
}

.search-dialog .sd-row__title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--sd-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sd-ink);
  line-height: 1.3;
}

.search-dialog .sd-row__title .mono {
  font-family: var(--sd-mono);
  font-weight: 600;
}

.search-dialog .sd-row__arrow {
  font-family: var(--sd-mono);
  color: var(--sd-ink-3);
}

.search-dialog .sd-row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
  font-family: var(--sd-sans);
  font-size: 11.5px;
  color: var(--sd-ink-4);
}

.search-dialog .sd-row__meta .mono {
  font-family: var(--sd-mono);
}

.search-dialog .sd-row__sep {
  color: var(--sd-rule-strong);
}

.search-dialog .sd-row__accessory {
  justify-self: end;
  font-family: var(--sd-mono);
  font-size: 11.5px;
  color: var(--sd-ink-3);
  white-space: nowrap;
}

/* Neutral chip used where no status variant applies (e.g. vehicle class). */
.search-dialog .sd-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--sd-bg-sunk);
  color: var(--sd-ink-3);
  font-family: var(--sd-sans);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.4;
}

.search-dialog mark {
  background: #F5EBD6;
  color: #B67A1E;
  padding: 0 2px;
  border-radius: 2px;
}

.search-dialog .sd-empty__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--sd-ink-4);
}

.search-dialog .sd-row--view-all {
  display: block;
  padding: 0;
  cursor: default;
  border-left-color: transparent;
}

.search-dialog .sd-row--view-all:hover {
  background: transparent;
}

.search-dialog .sd-row__view-all-link {
  display: flex;
  align-items: center;
  padding: 8px 18px;
  font-family: var(--sd-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--sd-ink-3);
  text-decoration: none;
}

.search-dialog .sd-row__view-all-link:hover {
  background: var(--sd-bg-sunk);
}

.search-dialog .sd-row__view-all-arrow {
  margin-left: auto;
  font-family: var(--sd-mono);
}

