/* search.css — clear button personalitzat per inputs de cerca.
 *
 * Usat per shared/js/search.js: `SharedSearch.attachClear(input)` afegeix
 * dinàmicament un `<button class="search-clear-x">` dins el parent de
 * l'input. Aquest CSS estilitza el botó + amaga la X nativa de WebKit
 * (que no es mostra a mòbil).
 *
 * Markup generat (automàtic):
 *   <parent style="position: relative">
 *     <input type="search" style="padding-right: 36px">
 *     <button class="search-clear-x [visible]">…svg…</button>
 *   </parent>
 *
 * Variables esperades (de tokens.css):
 *   --ink-2, --ink-3
 */

.search-clear-x {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--ink-3);
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  z-index: 3;
}

.search-clear-x.visible {
  display: flex;
}

.search-clear-x:hover {
  background: var(--ink-2);
}

.search-clear-x svg {
  width: 12px;
  height: 12px;
  display: block;
}

/* Oculta la X nativa de WebKit i Firefox — fem la nostra de pròpia,
 * consistent entre desktop i mòbil. */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

/* ─── Autocomplete dropdown (SharedSearch.attachAutocomplete) ───
   Norma transversal: tot cercador d'agregació o de context ampli ha de
   tenir un desplegable amb suggeriments. Estandarditza UX i tecles. */
.shared-autocomplete {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg, #fff);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  z-index: 1000;
}
.shared-autocomplete[data-placement="above"] { top: auto; bottom: calc(100% + 4px); }
html.dark .shared-autocomplete { border-color: rgba(255,255,255,0.12); background: var(--bg, #1a1a1a); }

.shared-ac-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  text-align: left;
  cursor: pointer;
  color: var(--ink, #111);
  font: inherit;
}
.shared-ac-row:last-child { border-bottom: none; }
.shared-ac-row:hover, .shared-ac-row.active { background: rgba(0,0,0,0.04); }
html.dark .shared-ac-row { color: var(--ink, #f0f0f5); border-bottom-color: rgba(255,255,255,0.05); }
html.dark .shared-ac-row:hover, html.dark .shared-ac-row.active { background: rgba(255,255,255,0.05); }

.shared-ac-ico {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ac-color, #999);
  color: #fff;
  font-weight: 700; font-size: 0.62rem;
  letter-spacing: -0.02em;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.shared-ac-info { flex: 1; min-width: 0; }
.shared-ac-nom { font-size: 0.84rem; font-weight: 600; line-height: 1.2; display: block; }
.shared-ac-meta { font-size: 0.72rem; color: var(--ink-3, #777); margin-top: 1px; display: block; }
.shared-ac-row mark.hl, .shared-autocomplete mark.hl {
  background: rgba(220, 38, 38, 0.18);
  color: inherit;
  padding: 0 2px; border-radius: 2px;
}
