/* ===== Product comparison: /Compare page + floating compare bar ===== */

/* ---------- Page header ---------- */
.cmp-page { padding-top: 32px; }

.cmp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 24px;
}

.cmp-head__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 180, 216, 0.1);
  color: var(--accent, #00b4d8);
  font-size: 0.82rem;
  font-weight: 700;
}

.cmp-head__title {
  margin: 12px 0 6px;
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 800;
  color: var(--text-primary, #0f172a);
}

.cmp-head__sub {
  margin: 0;
  color: var(--text-secondary, #64748b);
}

/* "Differences only" switch */
.cmp-diff-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  background: var(--bg-card, #fff);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  user-select: none;
}

.cmp-diff-toggle input { position: absolute; opacity: 0; pointer-events: none; }

.cmp-diff-toggle__track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border, #cbd5e1);
  transition: background 0.2s ease;
}

.cmp-diff-toggle__track span {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.cmp-diff-toggle input:checked + .cmp-diff-toggle__track { background: var(--accent, #00b4d8); }
.cmp-diff-toggle input:checked + .cmp-diff-toggle__track span { transform: translateX(16px); }
[dir="rtl"] .cmp-diff-toggle input:checked + .cmp-diff-toggle__track span { transform: translateX(-16px); }
.cmp-diff-toggle input:focus-visible + .cmp-diff-toggle__track { outline: 2px solid var(--accent, #00b4d8); outline-offset: 2px; }

/* ---------- Table ---------- */
.cmp-scroll {
  overflow-x: auto;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 20px;
  background: var(--bg-card, #fff);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  -webkit-overflow-scrolling: touch;
}

.cmp-table {
  width: 100%;
  min-width: calc(180px + var(--cmp-cols, 2) * 220px);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.cmp-table th,
.cmp-table td {
  padding: 14px 18px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--border, #eef2f6);
}

.cmp-table td + td,
.cmp-table th + td { border-inline-start: 1px solid var(--border, #eef2f6); }

/* Sticky label column so names stay visible while scrolling sideways on phones. */
.cmp-label {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  width: 180px;
  background: var(--bg-secondary, #f8fafc);
  color: var(--text-secondary, #475569);
  font-size: 0.86rem;
  font-weight: 700;
}

.cmp-label i { width: 18px; color: var(--accent, #00b4d8); }

.cmp-label--corner {
  vertical-align: middle;
  text-align: center;
  color: var(--text-primary, #0f172a);
}

.cmp-count {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.cmp-add-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px dashed var(--accent, #00b4d8);
  border-radius: 10px;
  color: var(--accent, #00b4d8);
  font-size: 0.82rem;
  text-decoration: none;
}

.cmp-add-more:hover { background: rgba(0, 180, 216, 0.08); }

/* Product header cells */
.cmp-product {
  position: relative;
  text-align: center !important;
  vertical-align: bottom !important;
  padding-top: 22px !important;
}

.cmp-product__remove {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--bg-secondary, #f1f5f9);
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.cmp-product__remove:hover { background: #fee2e2; color: #dc2626; }

.cmp-product__media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: #fff;
  color: var(--text-secondary, #94a3b8);
  font-size: 2rem;
}

.cmp-product__media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.cmp-product__media:hover img { transform: scale(1.04); }

.cmp-product__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary, #0f172a);
  text-decoration: none;
}

.cmp-product__name:hover { color: var(--accent, #00b4d8); }

.cmp-product__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
  margin: 8px 0 12px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent, #00b4d8);
}

.cmp-product__was {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-decoration: line-through;
}

.cmp-product__cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
}

/* Section rows */
.cmp-section th {
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(0, 180, 216, 0.1), transparent);
  color: var(--text-primary, #0f172a);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: start;
}

[dir="rtl"] .cmp-section th { background: linear-gradient(270deg, rgba(0, 180, 216, 0.1), transparent); }

.cmp-cell {
  color: var(--text-primary, #0f172a);
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.cmp-cell--empty { color: var(--text-secondary, #cbd5e1); }
.cmp-cell--text { color: var(--text-secondary, #475569); font-size: 0.86rem; }

.cmp-row:hover .cmp-cell { background: rgba(0, 180, 216, 0.04); }
.cmp-row[data-differs="true"] .cmp-label::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-start: 6px;
  vertical-align: middle;
  border-radius: 50%;
  background: #f59e0b;
}

.cmp-table--diff-only .cmp-row[data-differs="false"] { display: none; }

.cmp-note {
  margin: 12px 4px 0;
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
}

/* Empty state */
.cmp-empty {
  max-width: 520px;
  margin: 24px auto;
  padding: 40px 24px;
  border: 1px dashed var(--border, #cbd5e1);
  border-radius: 24px;
  background: var(--bg-card, #fff);
  text-align: center;
}

.cmp-empty__icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: rgba(0, 180, 216, 0.1);
  color: var(--accent, #00b4d8);
  font-size: 2rem;
}

.cmp-empty h2 { margin: 0 0 8px; font-size: 1.3rem; }
.cmp-empty p { margin: 0 0 20px; color: var(--text-secondary, #64748b); }

/* ---------- Floating compare bar ---------- */
.cmp-bar {
  position: fixed;
  z-index: 940;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(720px, calc(100% - 32px));
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  background: var(--bg-card, #fff);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
  animation: cmp-bar-in 0.3s ease;
}

.cmp-bar__info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary, #0f172a);
  font-size: 0.92rem;
  white-space: nowrap;
}

.cmp-bar__info > i {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(0, 180, 216, 0.12);
  color: var(--accent, #00b4d8);
}

.cmp-bar__count { color: var(--text-secondary, #64748b); font-weight: 600; }

.cmp-bar__slots {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: center;
}

.cmp-bar__slot {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  color: var(--text-secondary, #94a3b8);
}

.cmp-bar__slot img { max-width: 40px; max-height: 40px; object-fit: contain; }
.cmp-bar__slot--empty { border-style: dashed; background: transparent; font-size: 0.8rem; }

.cmp-bar__x {
  position: absolute;
  top: -7px;
  inset-inline-end: -7px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  font-size: 0.65rem;
  cursor: pointer;
}

.cmp-bar__actions { display: flex; align-items: center; gap: 8px; }

.cmp-bar__clear {
  border: none;
  background: transparent;
  color: var(--text-secondary, #64748b);
  font-weight: 600;
  cursor: pointer;
}

.cmp-bar__clear:hover { color: #dc2626; }

.cmp-bar__go { white-space: nowrap; padding: 10px 18px; }
.cmp-bar__go.is-disabled { opacity: 0.55; }

@keyframes cmp-bar-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
  .cmp-bar { gap: 10px; padding: 8px 10px; bottom: 10px; }
  .cmp-bar__info span { display: none; }
  .cmp-bar__slot { width: 40px; height: 40px; }
  .cmp-bar__slot img { max-width: 32px; max-height: 32px; }
  .cmp-bar__clear { display: none; }
  .cmp-label { width: 120px; font-size: 0.8rem; }
  .cmp-table { min-width: calc(120px + var(--cmp-cols, 2) * 180px); }
  .cmp-table th, .cmp-table td { padding: 12px; }
  .cmp-product__media { height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-bar { animation: none; }
}

/* ---------- Dark mode ---------- */
[data-theme="dark"] .cmp-product__media,
[data-theme="dark"] .cmp-bar__slot:not(.cmp-bar__slot--empty) { background: #fff; }
[data-theme="dark"] .cmp-bar__x { background: #f8fafc; color: #0f172a; }
[data-theme="dark"] .cmp-product__remove:hover { background: rgba(220, 38, 38, 0.2); }
