/* ============================================================
   SEARCH PANEL
   ------------------------------------------------------------
   The floating results dropdown attached to any search input.
   Uses fixed positioning so the panel is not clipped by
   overflow-hidden ancestors (header chrome, hero sections).

   Reads semantic tokens that flip with the theme.
   ============================================================ */

.search-panel {
  position: fixed;
  z-index: var(--z-modal);
  display: none;
  flex-direction: column;
  pointer-events: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 22px 55px rgba(7, 25, 43, 0.20);
  isolation: isolate;
  overflow: hidden;
}

html[data-theme="dark"] .search-panel {
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.72);
}

.search-panel[data-open="true"] {
  display: flex;
  animation: searchPanelEnter var(--dur-base) var(--ease);
}

@keyframes searchPanelEnter {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-panel-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

/* ---------- Tabs ---------- */

.search-panel-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-2) 0;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.search-panel-tabs::-webkit-scrollbar { display: none; }

.search-panel-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color            var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.search-panel-tab:hover { color: var(--heading); background: var(--surface-soft); }

.search-panel-tab[aria-selected="true"] {
  color: var(--heading);
  background: var(--surface-soft);
}

.search-panel-tab:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.search-panel-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: var(--fw-extrabold);
  font-variant-numeric: tabular-nums;
}

.search-panel-tab[aria-selected="true"] .search-panel-tab-count {
  background: var(--chrome-bg);
  color: var(--chrome-text);
}

/* ---------- Body ---------- */

.search-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2);
  scrollbar-width: thin;
}

.search-panel-body::-webkit-scrollbar { width: 6px; }
.search-panel-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

/* ---------- Groups ---------- */

.search-panel-group { margin-bottom: var(--space-3); }
.search-panel-group:last-child { margin-bottom: 0; }

.search-panel-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 6px 8px 4px;
}

.search-panel-group-title {
  color: var(--text-light);
  font-size: 10px;
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  line-height: 1;
}

html[lang="ar"] .search-panel-group-title { letter-spacing: 0; }

.search-panel-group-seeall {
  background: none;
  border: none;
  padding: 0;
  color: var(--blue-600);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  cursor: pointer;
  white-space: nowrap;
}

html[data-theme="dark"] .search-panel-group-seeall { color: var(--blue-400); }
.search-panel-group-seeall:hover { text-decoration: underline; text-underline-offset: 3px; }
.search-panel-group-seeall:focus-visible {
  outline: var(--focus-outline); outline-offset: 2px; border-radius: var(--radius-sm);
}

/* ---------- List ---------- */

.search-panel-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-panel-item { list-style: none; }

.search-panel-item-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}

.search-panel-item-link:hover,
.search-panel-item-link[data-highlighted="true"] {
  background: var(--surface-soft);
}

.search-panel-item-link:focus-visible {
  outline: var(--focus-outline);
  outline-offset: -2px;
}

/* ---------- Media icon ---------- */

.search-panel-item-media {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  overflow: hidden;
}

.search-panel-item-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.search-panel-item-media[data-type="task"] {
  background: var(--blue-50); color: var(--blue-600);
}
.search-panel-item-media[data-type="service"] {
  background: var(--success-soft); color: var(--success);
}
.search-panel-item-media[data-type="job"] {
  background: var(--warning-soft); color: var(--warning);
}
.search-panel-item-media[data-type="organization"] {
  background: var(--accent); color: var(--accent-ink);
}

html[data-theme="dark"] .search-panel-item-media[data-type="task"] {
  background: rgba(96, 165, 250, 0.14);
  color: var(--blue-400);
}

/* ---------- Text ---------- */

.search-panel-item-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-panel-item-title {
  color: var(--heading);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-panel-item-sub {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-panel-item-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
  flex-shrink: 0;
}

html[lang="ar"] .search-panel-item-type { letter-spacing: 0; }

/* ---------- States ---------- */

.search-panel-prompt,
.search-panel-empty,
.search-panel-loading {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.search-panel-prompt-icon,
.search-panel-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-3);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-circle);
  color: var(--text-light);
}

.search-panel-prompt-text,
.search-panel-empty p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.55;
  max-width: 320px;
  margin-inline: auto;
}

.search-panel-skeleton {
  height: 44px;
  margin-bottom: 6px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(90deg,
      var(--surface-muted) 0%,
      var(--surface-soft) 50%,
      var(--surface-muted) 100%);
  background-size: 200% 100%;
  animation: searchPanelShimmer 1.4s ease-in-out infinite;
}

@keyframes searchPanelShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.search-panel-more {
  padding: var(--space-3) var(--space-4) var(--space-2);
  text-align: center;
  color: var(--text-light);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* ---------- Foot ---------- */

.search-panel-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: 6px var(--space-3);
  border-top: 1px solid var(--border-soft);
  background: var(--surface-sunken);
}

.search-panel-foot-hint {
  color: var(--text-light);
  font-size: 10px;
  font-weight: var(--fw-medium);
}

.search-panel-foot-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-soft);
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  .search-panel {
    border-radius: var(--radius-lg);
  }
  .search-panel-tab { font-size: 11px; padding: 0 8px; }
  .search-panel-item-link { padding: 8px var(--space-2); gap: var(--space-2); }
  .search-panel-item-media { width: 28px; height: 28px; flex-basis: 28px; }
  .search-panel-item-title { font-size: var(--fs-xs); }
  .search-panel-item-sub { font-size: 10px; }
  .search-panel-item-type { padding: 2px 6px; font-size: 8px; }
  .search-panel-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .search-panel,
  .search-panel-item-link,
  .search-panel-tab,
  .search-panel-group-seeall { transition: none !important; }

  .search-panel[data-open="true"] { animation: none !important; }
  .search-panel-skeleton { animation: none !important; background: var(--surface-muted); }
}

@media print {
  .search-panel { display: none !important; }
}

/* No-result suggestions */
.search-panel-empty-hint { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.search-panel-empty-links { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0 0; }
