/* ==========================================================================
   Compare — toggle buttons, floating bar, compare page table.
   ========================================================================== */

.cmp-btn {
  display: inline-grid; place-items: center; gap: var(--sp-1); grid-auto-flow: column;
  min-width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: rgb(255 255 255 / .9); color: var(--c-text-2); box-shadow: var(--shadow-sm);
}
.cmp-btn:hover, .cmp-btn[aria-pressed="true"] { color: var(--c-primary); }
.cmp-btn[aria-pressed="true"] { background: var(--c-primary-soft); }
.cmp-btn .icon { width: 18px; height: 18px; }
.cmp-btn:has(.cmp-btn__label) { border-radius: var(--radius); padding: 0 var(--sp-3); box-shadow: none; border: 1px solid var(--c-border); }

/* Injected into listing cards, under the favorite button */
.p-card__cmp { position: absolute; top: calc(var(--sp-4) + 42px); inset-inline-end: var(--sp-4); z-index: 1; }
@media (hover: hover) {
  .p-card__cmp:not([aria-pressed="true"]) { opacity: 0; transition: opacity .15s; }
  .p-card:hover .p-card__cmp, .p-card__cmp:focus-visible { opacity: 1; }
}

/* ---------- Floating bar ---------- */
.cmp-bar {
  position: fixed; z-index: calc(var(--z-drawer) - 2); inset-inline: 0;
  bottom: env(safe-area-inset-bottom);
  background: var(--c-surface); border-top: 1px solid var(--c-border); box-shadow: 0 -6px 20px rgb(15 23 42 / .08);
  animation: bzr-cmp-in .2s var(--ease);
}
@media (max-width: 991px) { .cmp-bar { bottom: calc(64px + env(safe-area-inset-bottom)); } }
@keyframes bzr-cmp-in { from { transform: translateY(100%); } }
.cmp-bar__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding-block: var(--sp-2); }
.cmp-bar__items { display: flex; gap: var(--sp-2); list-style: none; margin: 0; padding: 0; overflow-x: auto; }
.cmp-bar__item { position: relative; flex: none; width: 52px; height: 52px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); }
.cmp-bar__item.is-empty { border-style: dashed; background: var(--c-bg); }
.cmp-bar__item img { width: 100%; height: 100%; object-fit: contain; border-radius: var(--radius); }
.cmp-bar__x {
  position: absolute; top: -6px; inset-inline-end: -6px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: var(--c-text); color: #fff; font-size: 14px; line-height: 20px;
}
.cmp-bar__actions { display: flex; gap: var(--sp-2); flex: none; }
.cmp-bar__go.is-disabled { opacity: .5; pointer-events: none; }
body.has-cmp-bar { padding-bottom: 72px; }
@media (max-width: 991px) { .cmp-bar__item.is-empty { display: none; } }

/* ---------- Compare page ---------- */
.cmp-page { min-height: 240px; }
.cmp-page.is-loading { opacity: .6; }
.cmp-page__loading { padding: var(--sp-6); text-align: center; }
.cmp-table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); }
.cmp-table { min-width: calc(140px + var(--cmp-cols, 2) * 200px); table-layout: fixed; font-size: var(--fs-sm); }
.cmp-table th, .cmp-table td { padding: var(--sp-3); border-bottom: 1px solid var(--c-border); text-align: center; vertical-align: top; }
.cmp-table tbody tr:nth-child(even) { background: var(--c-bg); }
.cmp-table tr > :first-child {
  position: sticky; inset-inline-start: 0; z-index: 1; width: 140px; text-align: start;
  background: var(--c-bg-2); color: var(--c-text-2); font-weight: 700;
}
.cmp-table__product { position: relative; font-weight: 400; }
.cmp-table__remove { position: absolute; top: var(--sp-2); inset-inline-end: var(--sp-2); min-height: 32px; width: 32px; }
.cmp-table__media { display: block; width: 140px; max-width: 100%; aspect-ratio: 1; margin: 0 auto var(--sp-2); }
.cmp-table__media img { width: 100%; height: 100%; object-fit: contain; }
.cmp-table__title { display: block; font-weight: 700; line-height: 1.8; }
.cmp-table__desc { text-align: start; }
.cmp-table__desc p { margin: 0; }
.cmp-rating { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.cmp-rating .icon { width: 16px; height: 16px; color: #f59e0b; fill: currentColor; }
.cmp-stock.is-in { color: var(--c-success); font-weight: 700; }
.cmp-stock.is-out { color: var(--c-muted); }
@media (max-width: 767px) {
  .cmp-table { min-width: calc(96px + var(--cmp-cols, 2) * 150px); }
  .cmp-table tr > :first-child { width: 96px; }
}
