/* История просмотров автомобилей — компактная вкладка и боковая панель. */
.car-history {
  --hist-width: 240px;
  --hist-opacity: 94%;
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.car-history > * { pointer-events: auto; }

.car-history__tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.car-history__tab:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.car-history__tab .icon { color: var(--accent); }
.car-history__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast, #0b1005);
  font-size: 10px;
  font-weight: 800;
}
.car-history__count[hidden] { display: none; }

.car-history__panel {
  width: var(--hist-width);
  max-height: calc(100vh - 220px);
  overflow: hidden auto;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) var(--hist-opacity), transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  scrollbar-width: thin;
}
.car-history__panel[hidden] { display: none; }
.car-history__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.car-history__title { font-size: 12px; font-weight: 750; letter-spacing: -0.01em; }
.car-history__clear {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
}
.car-history__clear:hover { color: var(--accent); }
.car-history__close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}
.car-history__close:hover { color: var(--text); }

.car-history__list { display: grid; gap: 8px; }
.car-history__item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 9px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.car-history__item:hover { border-color: var(--accent); transform: translateX(2px); }
.car-history__thumb {
  width: 52px;
  height: 40px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-2);
}
.car-history__thumb--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}
.car-history__body { min-width: 0; }
.car-history__name {
  display: block;
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.car-history__meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.car-history__price {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}
.car-history__empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}
.car-history__note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

/* Широкие экраны: панель живёт в свободном боковом поле рядом с контентом. */
@media (min-width: 1700px) {
  .car-history { top: 260px; }
  .car-history--right { right: max(16px, calc((100vw - var(--container, 1240px)) / 2 - var(--hist-width) - 24px)); }
  .car-history--left { left: max(16px, calc((100vw - var(--container, 1240px)) / 2 - var(--hist-width) - 24px)); }
  .car-history--left .car-history__tab { align-self: flex-end; }
  .car-history--left .car-history__item { grid-template-columns: minmax(0, 1fr) 52px; }
  .car-history--left .car-history__thumb { grid-column: 2; grid-row: 1; }
  .car-history--left .car-history__body { grid-column: 1; grid-row: 1; }
}

/* Узкие экраны: компактная плавающая вкладка над кнопками связи/чата. */
@media (max-width: 1699px) {
  .car-history { top: auto; }
  .car-history--right { right: 14px; bottom: 154px; align-items: flex-end; }
  .car-history--left { left: 14px; bottom: 124px; align-items: flex-start; }
  .car-history__tab span { display: none; }
  .car-history__panel {
    width: min(340px, calc(100vw - 28px));
    max-height: min(70vh, 560px);
  }
}

@media (max-width: 480px) {
  .car-history__tab { min-height: 36px; padding: 7px 10px; }
}
