/* ==========================================================================
   Bilexpert – sökhistoriken

   Egna klasser med prefixet sokhist-, eftersom blocket visas både på
   Sök-fliken och på sin egen sida – och eftersom .chip, .plate och .card
   redan betyder olika saker i app.css och fordon.css.

   Färgerna kommer ur tokens.css (--sh-*). Raden har tre delar: länken med
   skylt och bilnamn, en dämpad rad med färg, tidpunkt och källa, och menyn
   med fler val längst till höger.
   ========================================================================== */

.sokhist {
  background: var(--sh-paper);
  border: 1px solid var(--sh-line);
  border-radius: var(--sh-radius);
  color: var(--sh-ink);
  padding: 6px 20px 8px;
  text-align: left;
  font: 15px/1.48 var(--b, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
}

/* --------------------------------------------------------------- rubrikrad */
.sokhist-topp {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px 16px; padding: 12px 0;
  border-bottom: 1px solid var(--sh-line);
}
.sokhist h2.sokhist-rubrik {
  margin: 0; font: 600 17px/1.3 var(--b, Inter, sans-serif); letter-spacing: -.01em; color: var(--sh-ink);
}
.sokhist-antal { margin-left: 6px; color: var(--sh-muted); font-size: 14px; font-weight: 400; }
.sokhist-alla { color: var(--sh-blue); font-weight: 600; font-size: 14px; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.sokhist-alla:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ filter */
.sokhist-filter {
  display: flex; gap: 6px; align-items: center;
  background: var(--sh-paper); border: 1px solid var(--bv-line-falt, #858e9a); border-radius: 10px;
  padding: 4px 4px 4px 12px; width: min(360px, 100%);
}
.sokhist-filter:focus-within { border-color: var(--sh-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sh-blue) 22%, transparent); }
.sokhist-filter input {
  min-width: 0; flex: 1; border: 0; background: transparent; outline: none;
  font: inherit; color: var(--sh-ink); padding: 6px 0;
}
.sokhist-filter input::placeholder { color: var(--sh-muted); opacity: 1; }
.sokhist-filter button {
  border: 0; border-radius: 7px; background: var(--sh-canvas); color: var(--sh-ink);
  padding: 8px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sokhist-filter button:hover { background: var(--sh-line); }

/* ------------------------------------------------------------------ listan */
.sokhist-lista { margin: 0; padding: 0; list-style: none; }

.sokhist-rad {
  display: grid; align-items: center; gap: 4px 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "lank meny" "meta meny";
  padding: 14px 0; border-top: 1px solid var(--bv-line-ljus, #eceef1);
}
.sokhist-rad:first-child { border-top: 0; }

.sokhist-lank {
  grid-area: lank; display: flex; align-items: center; gap: 14px; min-width: 0;
  color: inherit; text-decoration: none; border-radius: 6px;
}
.sokhist-lank:hover .sokhist-bil { color: var(--sh-blue); }

/* Regnummerrutan. Egen skylt – .plate är redan taget i båda stilmallarna. */
.sokhist-skylt {
  display: inline-flex; align-items: stretch; flex: none; width: 104px; height: 32px;
  border: 1px solid var(--bv-line-mork, #c6cbd3); border-radius: 6px; overflow: hidden;
  background: var(--sh-paper);
}
.sokhist-skylt i {
  flex: none; display: flex; align-items: flex-end; justify-content: center; width: 18px; padding-bottom: 4px;
  font: 700 10px/1 var(--h, sans-serif); font-style: normal; background: var(--band, #245e91); color: var(--tm-tx-ffffff, #fff);
}
.sokhist-skylt b {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font: 700 15px/1 var(--h, sans-serif); letter-spacing: .08em; white-space: nowrap;
}

.sokhist-bil { min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }

/* Färg, tidpunkt och källa: en dämpad rad under bilnamnet, i linje med det. */
.sokhist-meta {
  grid-area: meta; padding-left: 118px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  font-size: 13px; color: var(--sh-muted);
}
.sokhist-farg { display: inline-flex; align-items: center; gap: 6px; }
.sokhist-prick {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 1px solid rgba(16, 22, 29, .25);
}
.sokhist-tid { white-space: nowrap; }
.sokhist-kalla { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
/* Källetiketten: samma färg och form som överallt, bara mindre. */
.sokhist-kalla .chip { padding: 0 7px; font-size: 11px; }
.sokhist-kalla .fakta-k { font-size: 13px; color: var(--sh-muted); }

/* --------------------------------------------------------------- fler val */
/* <details> i stället för en meny i JavaScript: fungerar med tangentbord
   och utan skript, precis som resten av sajtens dragspel. */
.sokhist-meny { grid-area: meny; position: relative; flex: none; align-self: center; }
.sokhist-meny > summary {
  list-style: none; cursor: pointer; width: 40px; height: 40px;
  display: grid; place-items: center; border: 1px solid transparent;
  border-radius: 8px; background: transparent; color: var(--sh-muted);
}
.sokhist-meny > summary::-webkit-details-marker { display: none; }
.sokhist-meny > summary:hover { background: var(--sh-canvas); color: var(--sh-ink); }
.sokhist-meny[open] > summary { background: var(--sh-canvas); border-color: var(--sh-line); color: var(--sh-ink); }

.sokhist-val {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5;
  min-width: 200px; padding: 6px; display: grid; gap: 2px;
  background: var(--sh-paper); border: 1px solid var(--sh-line); border-radius: 10px;
  box-shadow: var(--bv-shadow-sva, 0 12px 32px rgba(16, 22, 29, .14));
}
.sokhist-val a, .sokhist-val button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 11px; border-radius: 7px; font: inherit; font-size: 14px;
  font-weight: 500; color: var(--sh-ink); text-decoration: none; cursor: pointer;
}
.sokhist-val a:hover, .sokhist-val button:hover { background: var(--sh-canvas); color: var(--sh-ink); }
.sokhist-val button.sokhist-bort { color: var(--bv-red, #b3372b); }
.sokhist-val button.sokhist-bort:hover { background: var(--bv-red-mjuk, #fbefed); color: var(--bv-red, #b3372b); }
.sokhist-val form { margin: 0; }

/* ------------------------------------------------------------------- fot */
.sokhist-fot {
  display: flex; align-items: center; justify-content: flex-end;
  flex-wrap: wrap; gap: 10px; padding: 12px 0 6px; border-top: 1px solid var(--sh-line);
}
.sokhist-fot form { margin: 0; }
.sokhist-rensa {
  border: 1px solid var(--bv-line-mork, #c6cbd3); background: var(--sh-paper); border-radius: 10px;
  min-height: 40px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--sh-ink); cursor: pointer;
}
.sokhist-rensa:hover { border-color: var(--bv-red, #b3372b); background: var(--bv-red-mjuk, #fbefed); color: var(--bv-red, #b3372b); }

.sokhist-tom { margin: 0; padding: 18px 0 14px; color: var(--sh-muted); font-size: 15px; }
.sokhist-tom a { color: var(--sh-blue); font-weight: 600; }
.sokhist-notis {
  margin: 0; padding: 14px 0 12px; border-top: 1px solid var(--sh-line);
  color: var(--sh-muted); font-size: 13px; line-height: 1.55;
}
.sokhist-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.sokhist a:focus-visible, .sokhist button:focus-visible,
.sokhist input:focus-visible, .sokhist summary:focus-visible {
  outline: 2px solid var(--sh-blue); outline-offset: 2px;
}
.sokhist-filter input:focus-visible { outline: none; }

/* Kort variant (Sök-fliken): ingen ram runt blocket, bara rubrik och rader. */
.sokhist-kort { border: 0; border-radius: 0; padding: 0; background: transparent; }

/* ------------------------------------------------------------------ mobil */
@media (max-width: 640px) {
  .sokhist { padding: 4px 14px 6px; }
  .sokhist-kort { padding: 0; }
  .sokhist-lank { flex-wrap: wrap; gap: 6px 12px; }
  .sokhist-bil { flex: 1 1 100%; font-size: 15px; }
  .sokhist-meta { padding-left: 0; gap: 2px 12px; }
  .sokhist-meny { align-self: start; }
  .sokhist-filter { width: 100%; }
}
