/* Busca rápida do cabeçalho: segue a paleta ativa pelos tokens --theme-*. */

.qs-panel {
  --qs-accent: var(--theme-accent, #2563eb);
  --qs-accent-text: var(--theme-accent-text, #ffffff);
  --qs-surface: var(--theme-surface, #ffffff);
  --qs-text: var(--theme-text, #111827);
  --qs-muted: var(--theme-text-muted, #6b7280);
  --qs-border: var(--theme-border, #e5e7eb);
  --qs-soft: color-mix(in srgb, var(--qs-accent) 9%, var(--qs-surface));
  --qs-hover: color-mix(in srgb, var(--qs-text) 5%, var(--qs-surface));

  position: fixed;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--qs-surface);
  color: var(--qs-text);
  border: 1px solid var(--qs-border);
  border-radius: 16px;
  box-shadow: 0 24px 48px -12px rgb(15 23 42 / 0.22), 0 4px 12px -4px rgb(15 23 42 / 0.10);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  animation: qs-in 0.14s ease-out;
}

.qs-panel[hidden] { display: none; }

.qs-panel *, .qs-panel *::before, .qs-panel *::after { box-sizing: border-box; }

.qs-panel ul { list-style: none; margin: 0; padding: 0; }

.qs-panel a { color: inherit; text-decoration: none; }

.qs-panel mark {
  background: color-mix(in srgb, var(--qs-accent) 16%, transparent);
  color: inherit;
  font-weight: 700;
  border-radius: 3px;
  padding: 0 1px;
}

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

/* Barra de progresso fina durante novas buscas */
.qs-progress {
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s;
}

.qs-progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  background: var(--qs-accent);
  border-radius: 2px;
  animation: qs-progress 0.9s ease-in-out infinite;
}

.qs-panel--loading .qs-progress { opacity: 1; }

@keyframes qs-progress {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}

/* Estrutura */
.qs-body,
.qs-idle,
.qs-loading-state {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.qs-panel--wide .qs-body--split {
  display: grid;
  grid-template-columns: minmax(180px, 34%) 1fr;
  gap: 4px;
}

.qs-panel--wide .qs-body--split .qs-aside {
  border-right: 1px solid var(--qs-border);
  padding-right: 4px;
}

.qs-section + .qs-section { margin-top: 6px; }

.qs-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px;
}

.qs-section__head h3 {
  margin: 0;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--qs-muted);
}

.qs-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--qs-accent);
  cursor: pointer;
}

.qs-link:hover { text-decoration: underline; }

.qs-opt { cursor: pointer; transition: background-color 0.12s, color 0.12s; }

.qs-opt.is-active,
.qs-opt:focus-visible {
  background: var(--qs-soft);
  outline: none;
}

/* Categorias e marcas */
.qs-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
}

.qs-link-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--qs-muted);
}

.qs-link-item.is-active i { color: var(--qs-accent); }

.qs-link-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Produtos */
.qs-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
}

.qs-product__img {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--qs-border);
  background: #ffffff;
  color: var(--qs-muted);
}

.qs-product__img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qs-product__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qs-product__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 500;
}

.qs-product__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.qs-product__price strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--qs-accent);
}

.qs-product__price s {
  font-size: 12px;
  color: var(--qs-muted);
}

.qs-badge {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: #16a34a;
  color: #ffffff;
}

.qs-product__go {
  font-size: 11px;
  color: var(--qs-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.12s, transform 0.12s;
}

.qs-product.is-active .qs-product__go {
  opacity: 1;
  transform: none;
  color: var(--qs-accent);
}

/* Ver todos */
.qs-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 13px 18px;
  border-top: 1px solid var(--qs-border);
  font-weight: 600;
  color: var(--qs-accent);
}

.qs-all.is-active {
  background: var(--qs-accent);
  color: var(--qs-accent-text);
}

/* Buscas recentes */
.qs-term {
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.qs-term__link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
}

.qs-term__link i { width: 16px; text-align: center; color: var(--qs-muted); font-size: 13px; }

.qs-term__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qs-term__remove {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-right: 4px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--qs-muted);
  cursor: pointer;
}

.qs-term__remove:hover { background: var(--qs-hover); color: var(--qs-text); }

/* Sem resultado */
.qs-empty {
  padding: 28px 24px 30px;
  text-align: center;
}

.qs-empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--qs-soft);
  color: var(--qs-accent);
  font-size: 18px;
}

.qs-empty p { margin: 0; }

.qs-empty__title { font-weight: 600; font-size: 15px; }

.qs-empty__suggest { margin-top: 8px !important; }

.qs-empty__suggest a {
  border-radius: 4px;
  font-weight: 700;
  color: var(--qs-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.qs-empty__hint { margin-top: 6px !important; font-size: 13px; color: var(--qs-muted); }

/* Skeleton */
.qs-skeleton {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}

.qs-skeleton__img,
.qs-skeleton__lines span {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--qs-hover) 25%, color-mix(in srgb, var(--qs-text) 10%, var(--qs-surface)) 50%, var(--qs-hover) 75%);
  background-size: 200% 100%;
  animation: qs-shimmer 1.2s linear infinite;
}

.qs-skeleton__img { flex: 0 0 56px; height: 56px; border-radius: 10px; }

.qs-skeleton__lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.qs-skeleton__lines span { height: 12px; width: 80%; }

.qs-skeleton__lines span + span { width: 35%; }

@keyframes qs-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 639px) {
  .qs-panel { border-radius: 14px; }
  .qs-product__img { flex-basis: 48px; width: 48px; height: 48px; }
  .qs-product__go { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .qs-panel,
  .qs-progress::after,
  .qs-skeleton__img,
  .qs-skeleton__lines span { animation: none; }
}
