/* ============================================================
   HomeCenter — Header Search Autosuggest
   ============================================================
   Adaptado de plugins/hc_autosuggest/assets/autosuggest.css.
   Tokens --fs-* originais mapeados para tokens HomeCenter --cc-*.
   Scope: .cc-search (form do header) — sem .dweb wrapper.
   ============================================================ */

/* Container do form precisa ser relativo pro panel ancorar */
.cc-search { position: relative; }

/* Panel — desktop */
#header-search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--cc-border-subtle);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1100;
  font-size: 13px;
}
#header-search-suggest[hidden] { display: none; }

/* Loading state — barra fina animada no topo */
#header-search-suggest.loading::before {
  content: '';
  position: sticky;
  top: 0; left: 0; right: 0;
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cc-color-red-500), transparent);
  background-size: 200% 100%;
  animation: as-loading 1.1s ease-in-out infinite;
  z-index: 1;
}
@keyframes as-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Section */
.as-section {
  padding: 8px 0;
  border-top: 1px solid var(--cc-color-gray-100);
}
.as-section:first-child { border-top: none; }
.as-section h6 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cc-text-tertiary);
  margin: 4px 14px 6px;
}

/* Item base */
.as-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 48px;
  text-decoration: none;
  color: var(--cc-text-primary);
  cursor: pointer;
  transition: background 100ms ease;
}
.as-item:hover,
.as-item.active { background: var(--cc-surface-section); }

.as-item .as-name {
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.as-item mark {
  background: #FFD60A;
  color: var(--cc-text-primary);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Categoria / Marca icons */
.as-cat-icon,
.as-mfg-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--cc-surface-section);
  border-radius: 6px;
  font-size: 16px;
  color: var(--cc-text-tertiary);
  flex-shrink: 0;
}
.as-mfg-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--cc-color-gray-100);
  border-radius: 6px;
  flex-shrink: 0;
  padding: 2px;
}

/* Cat/Mfg name takes remaining space */
.as-cat .as-name,
.as-mfg .as-name { flex: 1; min-width: 0; -webkit-line-clamp: 1; }

.as-count {
  font-size: 11px;
  color: var(--cc-text-tertiary);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Produto */
.as-prod img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--cc-color-gray-100);
  border-radius: 6px;
  padding: 2px;
}
.as-prod-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.as-prod-meta .as-brand {
  font-size: 10px;
  color: var(--cc-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.as-price {
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}
.as-price .num { color: var(--cc-color-red-500); }
.as-price s { font-weight: 400; color: var(--cc-text-tertiary); margin-right: 4px; font-size: 11px; }

/* Footer "Ver todos" */
.as-footer {
  display: block;
  padding: 14px;
  text-align: center;
  background: var(--cc-surface-section);
  color: var(--cc-color-red-500);
  font-weight: 600;
  font-size: 13px;
  border-top: 1px solid var(--cc-color-gray-100);
  text-decoration: none;
  position: sticky;
  bottom: 0;
}
.as-footer:hover,
.as-footer.active { background: var(--cc-color-gray-100); }
.as-footer b { color: var(--cc-text-primary); }

/* Empty */
.as-empty {
  padding: 28px 24px;
  text-align: center;
  color: var(--cc-text-tertiary);
  font-size: 14px;
}
.as-empty b { color: var(--cc-text-primary); }

/* MOBILE — full-width fora do form */
@media (max-width: 599px) {
  #header-search-suggest {
    border-radius: 0;
    left: -16px;
    right: -16px;
    border-left: none;
    border-right: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    max-height: 80vh;
  }
  .as-item { min-height: 52px; }  /* touch-friendly */
}
