/**
 * Kaveh — Premium compare page (kcp-*)
 */

:root {
  --kcp-bg: #f4f5f7;
  --kcp-card: #ffffff;
  --kcp-text: #23254e;
  --kcp-muted: #81858b;
  --kcp-border: #e8e8eb;
  --kcp-primary: #ef4056;
  --kcp-secondary: #19bfd3;
  --kcp-radius: 14px;
  --kcp-shadow: 0 4px 24px rgba(35, 37, 78, 0.06);
}

body.kaveh-compare-page {
  background: var(--kcp-bg);
}

body.kcp-search-open {
  overflow: hidden;
}

body.kcp-is-loading {
  cursor: wait;
  opacity: 0.92;
}

/* ── PDP button ── */
.kdk-compare-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--kcp-border);
  border-radius: 10px;
  background: var(--kcp-card);
  color: var(--kcp-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s ease;
}

.kdk-compare-btn:hover {
  border-color: var(--kcp-secondary);
  color: var(--kcp-secondary);
}

.kdk-compare-btn.is-active {
  border-color: var(--kcp-primary);
  background: #fff5f6;
  color: var(--kcp-primary);
}

.kdk-compare-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--kcp-secondary);
  text-decoration: none;
  margin-inline-start: 6px;
}

.kcp-toast,
.kdk-compare-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 100100;
  padding: 12px 22px;
  background: var(--kcp-text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.kcp-toast.is-visible,
.kdk-compare-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Page shell ── */
.kaveh-compare-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.kcp {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Hero */
.kcp-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px;
  background: linear-gradient(135deg, #fff 0%, #fafbff 100%);
  border: 1px solid var(--kcp-border);
  border-radius: calc(var(--kcp-radius) + 4px);
  box-shadow: var(--kcp-shadow);
}

.kcp-hero__title {
  margin: 0 0 6px;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  color: var(--kcp-text);
  letter-spacing: -0.02em;
}

.kcp-hero__desc {
  margin: 0;
  color: var(--kcp-muted);
  font-size: 14px;
  line-height: 1.7;
  max-width: 520px;
}

.kcp-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kcp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s ease;
}

.kcp-btn--primary {
  background: var(--kcp-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 64, 86, 0.28);
}

.kcp-btn--primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.kcp-btn--ghost {
  background: transparent;
  color: var(--kcp-muted);
  border: 1px solid var(--kcp-border);
}

.kcp-btn--lg {
  padding: 14px 28px;
  font-size: 15px;
}

.kcp-link {
  background: none;
  border: none;
  color: var(--kcp-secondary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* Slots */
.kcp-slots-section {
  padding: 0 4px;
}

.kcp-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.kcp-slot {
  position: relative;
  background: var(--kcp-card);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
  overflow: hidden;
  transition: 0.2s ease;
}

.kcp-slot--filled:hover {
  box-shadow: var(--kcp-shadow);
  border-color: #d8d8de;
}

.kcp-slot--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  border-style: dashed;
  border-color: #c8cad0;
  background: #fafbfc;
  cursor: pointer;
  font-family: inherit;
}

.kcp-slot--empty:hover {
  border-color: var(--kcp-secondary);
  background: #f0fbfd;
}

.kcp-slot__plus {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #eef0f4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--kcp-muted);
}

.kcp-slot--empty:hover .kcp-slot__plus {
  background: var(--kcp-secondary);
  color: #fff;
}

.kcp-slot__hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--kcp-muted);
}

.kcp-slot__remove {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--kcp-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.kcp-slot__remove:hover {
  color: var(--kcp-primary);
}

.kcp-slot__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 14px 16px;
  text-decoration: none;
  color: inherit;
}

.kcp-slot__img img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 10px;
}

.kcp-slot__name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kcp-slot__price {
  font-size: 13px;
  font-weight: 800;
  color: var(--kcp-primary);
}

/* Matrix */
.kcp-matrix-section {
  background: var(--kcp-card);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
  box-shadow: var(--kcp-shadow);
  overflow: hidden;
}

.kcp-matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--kcp-border);
  background: #fafbfc;
}

.kcp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--kcp-text);
  cursor: pointer;
}

.kcp-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--kcp-primary);
}

.kcp-matrix-count {
  font-size: 12px;
  color: var(--kcp-muted);
  font-weight: 600;
}

.kcp-matrix-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.kcp-matrix {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}

.kcp-matrix th,
.kcp-matrix td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--kcp-border);
  text-align: right;
  vertical-align: middle;
}

.kcp-matrix__group th {
  background: #f0f6fc;
  font-weight: 800;
  font-size: 14px;
  color: var(--kcp-text);
  padding: 12px 16px;
}

.kcp-matrix__head th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  vertical-align: bottom;
  padding: 0;
  border-bottom: 2px solid var(--kcp-border);
}

.kcp-matrix__corner {
  width: 22%;
  min-width: 120px;
  padding: 14px 16px !important;
  font-weight: 800;
  color: var(--kcp-muted);
  background: #fafafa !important;
  z-index: 4;
}

.kcp-matrix__col {
  min-width: 150px;
  border-top: 3px solid var(--kcp-secondary);
  background: #fff;
}

.kcp-matrix__col--1 { border-top-color: #ef4056; }
.kcp-matrix__col--2 { border-top-color: #19bfd3; }
.kcp-matrix__col--3 { border-top-color: #7b61ff; }
.kcp-matrix__col--4 { border-top-color: #00a049; }

.kcp-matrix__product {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px 12px;
  text-decoration: none;
  color: inherit;
}

.kcp-matrix__col-badge {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--kcp-text);
  padding: 3px 10px;
  border-radius: 999px;
}

.kcp-matrix__col--1 .kcp-matrix__col-badge { background: #ef4056; }
.kcp-matrix__col--2 .kcp-matrix__col-badge { background: #19bfd3; }
.kcp-matrix__col--3 .kcp-matrix__col-badge { background: #7b61ff; }
.kcp-matrix__col--4 .kcp-matrix__col-badge { background: #00a049; }

.kcp-matrix__col-img img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--kcp-border);
  background: #fafafa;
}

.kcp-matrix__col-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 140px;
}

.kcp-matrix__col-price {
  font-size: 12px;
  font-weight: 800;
  color: var(--kcp-primary);
}

.kcp-matrix__cell {
  border-right: 1px solid var(--kcp-border);
  text-align: center;
  vertical-align: middle;
}

.kcp-matrix__cell--1 { border-right: 2px solid rgba(239, 64, 86, 0.15); }
.kcp-matrix__cell--2 { border-right: 2px solid rgba(25, 191, 211, 0.15); }
.kcp-matrix__cell--3 { border-right: 2px solid rgba(123, 97, 255, 0.15); }
.kcp-matrix__cell--4 { border-right: 2px solid rgba(0, 160, 73, 0.15); }

.kcp-matrix__cell-label {
  display: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--kcp-muted);
  margin-bottom: 4px;
}

.kcp-matrix__cell-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--kcp-text);
  font-variant-numeric: tabular-nums;
}

.kcp-matrix__row th[scope="row"] {
  text-align: right;
}

@media (max-width: 767px) {
  .kcp-matrix__cell-label {
    display: block;
  }

  .kcp-matrix__head {
    display: none;
  }

  .kcp-matrix__row {
    display: block;
    border-bottom: 1px solid var(--kcp-border);
    padding: 12px 0;
  }

  .kcp-matrix__row th[scope="row"] {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: #f4f5f7;
    border: none;
    position: static;
  }

  .kcp-matrix__row td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border: none;
    text-align: right;
  }

  .kcp-matrix__group th {
    display: block;
    padding: 12px 16px;
  }
}

.kcp-matrix__row th[scope="row"] {
  width: 28%;
  min-width: 140px;
  background: #fafafa;
  font-weight: 600;
  color: var(--kcp-muted);
  position: sticky;
  right: 0;
  z-index: 1;
}

.kcp-matrix__row.is-diff td.is-highlight {
  background: #fffbf5;
  font-weight: 700;
}

.kcp-matrix__row.is-hidden {
  display: none;
}

.kcp-matrix td.is-unknown {
  color: #a8abb0;
  font-style: italic;
}

/* Product grid cards */
.kcp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.kcp-card {
  display: flex;
  flex-direction: column;
  background: var(--kcp-card);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
  overflow: hidden;
  transition: 0.2s ease;
}

.kcp-card:hover {
  box-shadow: var(--kcp-shadow);
  transform: translateY(-2px);
}

.kcp-card.is-in-compare {
  border-color: var(--kcp-primary);
  box-shadow: 0 0 0 1px var(--kcp-primary);
}

.kcp-card__media {
  position: relative;
  display: block;
  aspect-ratio: 1;
  padding: 16px;
  background: #fafafa;
}

.kcp-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.kcp-card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.kcp-card__badge--sale {
  background: var(--kcp-primary);
  color: #fff;
}

.kcp-card__badge--stock {
  background: #eee;
  color: var(--kcp-muted);
}

.kcp-card__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
  flex: 1;
}

.kcp-card__cat {
  font-size: 11px;
  font-weight: 600;
  color: var(--kcp-secondary);
}

.kcp-card__title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kcp-card__title a {
  color: var(--kcp-text);
  text-decoration: none;
}

.kcp-card__price {
  font-size: 13px;
  font-weight: 800;
  color: var(--kcp-primary);
  margin-top: auto;
}

.kcp-card__action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: #f4f5f7;
  color: var(--kcp-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s ease;
}

.kcp-card__action:hover {
  background: var(--kcp-secondary);
  color: #fff;
}

.kcp-card__action--added {
  background: #fff0f2;
  color: var(--kcp-primary);
  cursor: default;
}

.kcp-card__action--disabled {
  background: #f0f0f0;
  color: #aaa;
  cursor: not-allowed;
}

.kcp-card__body--center {
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 180px;
}

.kcp-card__view-all-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--kcp-secondary);
}

.kcp-empty-grid {
  text-align: center;
  padding: 32px;
  color: var(--kcp-muted);
  font-size: 14px;
}

/* Suggestions section */
.kcp-suggest-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kcp-suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kcp-suggest-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--kcp-text);
}

.kcp-empty-hero,
.kcp-alert {
  text-align: center;
  padding: 48px 24px;
  background: var(--kcp-card);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
}

.kcp-empty-hero__icon {
  font-size: 48px;
  color: var(--kcp-secondary);
  margin-bottom: 12px;
}

.kcp-alert--warn {
  background: #fffbeb;
  border-color: #f0d060;
}

/* ── Fullscreen search ── */
.kcp-search {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.kcp-search[hidden] {
  display: none !important;
}

.kcp-search.is-open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto;
  opacity: 1;
}

body.kcp-search-open .top-header-four-search,
body.kcp-search-open #seeebox,
body.kaveh-premium-search-active .top-header-four-search {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Header fields are launchers only — typing happens in the overlay */
body.kaveh-premium-search-active .kaveh-search-widget input.maninpu,
body.kaveh-premium-search-active .kaveh-search-widget input[type="search"],
body.kaveh-premium-search-active input[data-kcp-launcher="1"] {
  cursor: pointer;
  caret-color: transparent;
}

.kcp-search.is-open .kcp-search__panel,
.kcp-search.is-open .kcp-search__input,
.kcp-search.is-open .kcp-search__input-wrap {
  pointer-events: auto;
}

.kcp-search__input {
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
  caret-color: auto;
  touch-action: manipulation;
  min-height: 28px;
  width: 100%;
  position: relative;
  z-index: 2;
}

.kcp-search__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(18, 20, 38, 0.55);
  backdrop-filter: blur(4px);
}

.kcp-search__panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  animation: kcpSlideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes kcpSlideUp {
  from { transform: translateY(12px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.kcp-search__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--kcp-border);
  flex-shrink: 0;
}

.kcp-search__input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #f4f5f7;
  border-radius: 14px;
}

.kcp-search__input-wrap i {
  font-size: 22px;
  color: var(--kcp-muted);
}

.kcp-search .kcp-search__input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 600;
  color: var(--kcp-text);
  outline: none;
  font-family: inherit;
}

.kcp-search__input::placeholder {
  color: #a8abb0;
  font-weight: 500;
}

.kcp-search__close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: #f4f5f7;
  color: var(--kcp-muted);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kcp-search__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.kcp-search__status {
  font-size: 13px;
  color: var(--kcp-muted);
  margin-bottom: 12px;
  min-height: 20px;
}

.kcp-search__section-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--kcp-text);
}

.kcp-search__hint {
  text-align: center;
  color: var(--kcp-muted);
  padding: 40px 16px;
  font-size: 14px;
}

.kcp-search__cats {
  flex-shrink: 0;
  padding: 16px 20px 24px;
  border-top: 1px solid var(--kcp-border);
  background: #fafbfc;
}

.kcp-search__cats-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--kcp-muted);
}

.kcp-search__cats-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.kcp-search__cats-scroll::-webkit-scrollbar {
  display: none;
}

.kcp-cat-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--kcp-border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--kcp-text);
  cursor: pointer;
  font-family: inherit;
  transition: 0.2s ease;
}

.kcp-cat-chip.is-active,
.kcp-cat-chip:hover {
  border-color: var(--kcp-secondary);
  background: #eefafd;
  color: var(--kcp-secondary);
}

.kcp-cat-chip__count {
  font-size: 11px;
  color: var(--kcp-muted);
  background: #f0f0f2;
  padding: 2px 7px;
  border-radius: 999px;
}

.kcp-hero__text {
  flex: 1;
  min-width: 200px;
}

.kcp-card--view-all {
  border-style: dashed;
  background: #fafbfc;
}

.kcp-card--view-all:hover {
  border-color: var(--kcp-secondary);
}

.kcp-search.is-open {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.kcp-search.is-open .kcp-search__panel {
  width: 100%;
  height: 100%;
}

.kcp-search .kcp-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kcp-empty-grid {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--kcp-muted);
  padding: 48px 16px;
  font-size: 14px;
}

@media (min-width: 576px) {
  .kcp-search .kcp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 768px) {
  .kaveh-compare-shell {
    padding: 32px 24px 80px;
  }

  .kcp-search .kcp-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }

  .kcp-search__head {
    padding: 20px 28px;
  }

  .kcp-search__body {
    padding: 24px 28px;
  }
}

@media (min-width: 1200px) {
  .kcp-search .kcp-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (min-width: 1400px) {
  .kcp-search .kcp-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* LWAI specs on PDP (unchanged helpers) */
.kdk-lwai-specs { display: flex; flex-direction: column; gap: 20px; }
.kdk-lwai-specs__group-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: #23254e;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--kcp-secondary, #19bfd3);
}
.kdk-spec-row.is-unknown .kdk-spec-value { color: var(--kcp-muted); font-style: italic; font-weight: 500; }
