/* ShopLens · Phase 2 — shared sidebar deltas.
   Loaded LAST in <head>, after each page's inline <style>, so these rules win
   over the per-page copies without forcing a risky wholesale CSS refactor.
   Everything here exists for one reason: controls that are reachable by keyboard
   and announced correctly. */

.sa-side { box-sizing: border-box; }

/* New chat is an <a> on /saved and /product, a <button> on /app. */
a.sa-new { text-decoration: none; }

/* History row = wrapper div + a real open button + a real delete button.
   The old markup put a delete glyph in a hover-only <span> with a click
   handler — not focusable, not announced, and display:none removed it from the
   tab order entirely, so chats could not be deleted without a mouse. */
.sa-hist-item {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.sa-hist-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 10px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
}

.sa-hist-open .t {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sa-hist-del {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-right: 6px;
  padding: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sa-sub, #9AA3B2);
  cursor: pointer;
  /* Kept in flow at all times — `display:none` would remove it from the tab
     order, which is the exact bug this replaces. Reveal with opacity. */
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}

.sa-hist-item:hover .sa-hist-del,
.sa-hist-item:focus-within .sa-hist-del {
  opacity: 1;
}

/* Keyboard users never hover, so focus-within above reveals it — but a row can
   also hold focus while the pointer is elsewhere. Keep it visible whenever
   anything inside has focus, and never let it be the only affordance. */
.sa-hist-del:focus-visible {
  opacity: 1;
  outline: 2px solid #A5B4FC;
  outline-offset: 2px;
}

.sa-hist-del:hover {
  background: rgba(239, 68, 68, .18);
  color: #FCA5A5;
  opacity: 1;
}

/* Touch devices have no hover: always show delete there. */
@media (hover: none) {
  .sa-hist-del { opacity: 1; }
}

/* The wrapper carries the hover/active surface, not the button. */
.sa-hist-item { background: transparent; border-color: transparent; }
.sa-hist-item:hover { background: rgba(255, 255, 255, .07); }
html[data-theme="light"] .sa-hist-item:hover { background: rgba(15, 20, 35, .07); }
.sa-hist-item.active { background: rgba(91, 91, 240, .16); border-color: rgba(129, 140, 248, .35); }
.sa-hist-item.active .sa-hist-open { color: #fff; }

/* Safety net for engines without inert support: the off-canvas sidebar must not
   be clickable or tabbable either way. */
.sa-side[inert] { pointer-events: none; }
.sa-side[inert] * { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .sa-hist-del { transition: none; }
}