/* =============================================================
   Nikmehr — Product comparison
   A slim side drawer (the "compare cart") plus a full-screen
   comparison-table modal. Reuses the .nik-cart-locked scroll-lock
   class and the design tokens from main.css. RTL via logical props.
   ============================================================= */

/* ---------- Shared overlay (drawer + can be reused) ---------- */
.nik-compare-overlay {
	position: fixed; inset: 0; z-index: 140;
	background: rgba(11,28,69,.5);
	opacity: 0; transition: opacity .3s ease;
}
.nik-compare-overlay.is-open { opacity: 1; }

/* =============================================================
   Drawer ("سبد مقایسه")
   ============================================================= */
.nik-compare-drawer {
	position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 150;
	width: min(92vw, 360px);
	display: flex; flex-direction: column;
	background: #fff; color: var(--nik-text);
	box-shadow: 0 0 60px -10px rgba(11,28,69,.4);
	/* Parked off-screen toward the inline-start edge until opened. `translateX`
	   isn't direction-aware, so we park it with a 100% translation toward the
	   start edge — positive in RTL (start = right), negative in LTR. The default
	   below is the RTL value; the LTR override follows. */
	transform: translateX(100%);
	visibility: hidden;
	transition: transform .32s cubic-bezier(.22,1,.36,1), visibility .32s;
}
[dir="ltr"] .nik-compare-drawer { transform: translateX(-100%); }
.nik-compare-drawer.is-open { transform: translateX(0); visibility: visible; }

.nik-compare-drawer__head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 18px; border-bottom: 1px solid var(--nik-border); flex-shrink: 0;
}
.nik-compare-drawer__title {
	margin: 0; display: inline-flex; align-items: center; gap: 8px;
	font-size: 16px; font-weight: 800; color: var(--nik-primary);
}
.nik-compare-drawer__count {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 22px; height: 22px; padding: 0 6px;
	font-size: 12px; font-weight: 800; line-height: 1;
	color: #1a1a1a; background: var(--nik-accent); border-radius: 999px;
}
.nik-compare-drawer__close {
	display: inline-flex; padding: 4px; background: none; border: 0; cursor: pointer;
	color: var(--nik-text-soft); transition: color .15s ease;
}
.nik-compare-drawer__close:hover { color: var(--nik-accent-600); }

/* "Added" confirmation toast inside the drawer. */
.nik-compare-drawer__toast {
	display: flex; align-items: center; gap: 8px;
	margin: 0; padding: 11px 18px;
	font-size: 13px; font-weight: 700;
	color: var(--nik-success); background: var(--nik-success-bg);
}
.nik-compare-drawer__toast svg { flex-shrink: 0; }

/* The list of compared products. */
.nik-compare-drawer__list {
	flex: 1 1 auto; min-height: 0;
	overflow-y: auto; overscroll-behavior: contain;
	padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.nik-compare-drawer__empty {
	margin: 0; padding: 28px 18px; text-align: center;
	font-size: 13.5px; font-weight: 600; color: var(--nik-text-faint);
}

.nik-compare-item {
	display: flex; align-items: center; gap: 11px;
	padding: 9px; border: 1px solid var(--nik-border); border-radius: var(--nik-radius);
	background: #fff;
}
.nik-compare-item__thumb {
	flex-shrink: 0; width: 52px; height: 52px;
	display: flex; align-items: center; justify-content: center;
	background: var(--nik-bg-soft); border-radius: var(--nik-radius-sm); overflow: hidden;
}
.nik-compare-item__thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.nik-compare-item__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.nik-compare-item__name {
	font-size: 12.5px; font-weight: 700; line-height: 1.6; color: var(--nik-text);
	text-decoration: none;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nik-compare-item__name:hover { color: var(--nik-accent-600); }
.nik-compare-item__price { font-size: 12px; font-weight: 700; color: var(--nik-primary); }
.nik-compare-item__price del { color: var(--nik-text-faint); font-weight: 500; margin-inline-start: 4px; }
.nik-compare-item__remove {
	flex-shrink: 0; display: inline-flex; padding: 5px;
	background: none; border: 0; cursor: pointer;
	color: var(--nik-text-faint); transition: color .15s ease;
}
.nik-compare-item__remove:hover { color: #c0392b; }

/* ---------- In-drawer search ---------- */
.nik-compare-search { flex-shrink: 0; padding: 12px 14px; border-top: 1px solid var(--nik-border); }
.nik-compare-search__box { position: relative; display: flex; align-items: center; }
.nik-compare-search__icon {
	position: absolute; inset-inline-start: 11px; color: var(--nik-text-faint); pointer-events: none;
}
.nik-compare-search__input {
	width: 100%; padding: 10px 12px; padding-inline-start: 36px;
	font-family: var(--nik-font); font-size: 13.5px; color: var(--nik-text);
	background: var(--nik-bg-soft);
	border: 1px solid var(--nik-border); border-radius: var(--nik-radius-sm);
	transition: border-color .15s ease, background .15s ease;
}
.nik-compare-search__input:focus { outline: none; border-color: var(--nik-accent); background: #fff; }
.nik-compare-search__input::placeholder { color: var(--nik-text-faint); }

.nik-compare-search__results {
	margin-top: 8px; max-height: 230px; overflow-y: auto; overscroll-behavior: contain;
	display: flex; flex-direction: column; gap: 6px;
}
.nik-compare-search__msg {
	margin: 0; padding: 10px 4px; text-align: center;
	font-size: 12.5px; font-weight: 600; color: var(--nik-text-faint);
}
.nik-compare-result {
	display: flex; align-items: center; gap: 9px;
	padding: 7px; border: 1px solid var(--nik-border); border-radius: var(--nik-radius-sm);
}
.nik-compare-result__thumb {
	flex-shrink: 0; width: 38px; height: 38px;
	display: flex; align-items: center; justify-content: center;
	background: var(--nik-bg-soft); border-radius: 5px; overflow: hidden;
}
.nik-compare-result__thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.nik-compare-result__name {
	flex: 1 1 auto; min-width: 0;
	font-size: 12px; font-weight: 600; line-height: 1.5; color: var(--nik-text);
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nik-compare-result__add {
	flex-shrink: 0; padding: 6px 12px; cursor: pointer;
	font-family: var(--nik-font); font-size: 12px; font-weight: 800;
	color: var(--nik-accent-600); background: rgba(255,153,0,.1);
	border: 1px solid var(--nik-accent); border-radius: 999px;
	transition: background .15s ease, color .15s ease;
}
.nik-compare-result__add:hover { background: var(--nik-accent); color: #1a1a1a; }
.nik-compare-result__add:disabled {
	color: var(--nik-text-faint); background: var(--nik-bg-soft);
	border-color: var(--nik-border); cursor: default;
}

/* ---------- «مقایسه کن» CTA ---------- */
.nik-compare-drawer__go {
	flex-shrink: 0; margin: 0 14px 14px; padding: 13px 16px; cursor: pointer;
	font-family: var(--nik-font); font-size: 15px; font-weight: 800;
	color: #1a1a1a; background: var(--nik-accent);
	border: 0; border-radius: var(--nik-radius-sm);
	transition: background .15s ease, opacity .15s ease;
}
.nik-compare-drawer__go:hover:not(:disabled) { background: var(--nik-accent-600); }
.nik-compare-drawer__go:disabled { opacity: .45; cursor: default; }

/* =============================================================
   Comparison modal (full-screen)
   ============================================================= */
.nik-compare-modal {
	position: fixed; inset: 0; z-index: 160;
	display: flex; align-items: center; justify-content: center;
	padding: 24px;
	background: rgba(11,28,69,.55);
	opacity: 0; visibility: hidden;
	transition: opacity .25s ease, visibility .25s;
}
.nik-compare-modal.is-open { opacity: 1; visibility: visible; }

.nik-compare-modal__panel {
	width: min(96vw, 1100px); max-height: 92vh;
	display: flex; flex-direction: column;
	background: #fff; color: var(--nik-text);
	border-radius: var(--nik-radius);
	box-shadow: 0 24px 70px -16px rgba(11,28,69,.55);
	transform: translateY(14px) scale(.97);
	transition: transform .25s cubic-bezier(.22,1,.36,1);
}
.nik-compare-modal.is-open .nik-compare-modal__panel { transform: translateY(0) scale(1); }

.nik-compare-modal__head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 20px; border-bottom: 1px solid var(--nik-border); flex-shrink: 0;
}
.nik-compare-modal__title { margin: 0; font-size: 17px; font-weight: 800; color: var(--nik-primary); }
.nik-compare-modal__close {
	display: inline-flex; padding: 4px; background: none; border: 0; cursor: pointer;
	color: var(--nik-text-soft); transition: color .15s ease;
}
.nik-compare-modal__close:hover { color: var(--nik-accent-600); }

.nik-compare-modal__body {
	flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
	padding: 4px;
}

/* ---------- The table itself ---------- */
.nik-compare-table__scroll { overflow-x: auto; }
.nik-compare-table {
	width: 100%; border-collapse: collapse;
	font-size: 13px;
}
.nik-compare-table th,
.nik-compare-table td {
	padding: 12px 14px; text-align: center; vertical-align: middle;
	border-bottom: 1px solid var(--nik-border);
}
/* Sticky attribute-label column (inline-start), so it stays put while the
   product columns scroll horizontally on small screens. */
.nik-compare-table__corner,
.nik-compare-table__label {
	position: sticky; inset-inline-start: 0; z-index: 2;
	background: var(--nik-bg-soft);
	text-align: start; font-weight: 700; color: var(--nik-text-soft);
	min-width: 110px;
}
.nik-compare-table__corner { background: #fff; }

.nik-compare-table__product {
	position: relative; min-width: 170px; vertical-align: top;
	background: #fff;
}
.nik-compare-table__remove {
	position: absolute; inset-block-start: 4px; inset-inline-end: 4px;
	display: inline-flex; padding: 4px; background: none; border: 0; cursor: pointer;
	color: var(--nik-text-faint); transition: color .15s ease;
}
.nik-compare-table__remove:hover { color: #c0392b; }
.nik-compare-table__thumb {
	display: flex; align-items: center; justify-content: center;
	height: 110px; margin-bottom: 8px;
}
.nik-compare-table__thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.nik-compare-table__name {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	font-size: 13px; font-weight: 700; line-height: 1.6; color: var(--nik-text); text-decoration: none;
}
.nik-compare-table__name:hover { color: var(--nik-accent-600); }

.nik-compare-table__cell--price { font-weight: 800; color: var(--nik-primary); }
.nik-compare-table__cell--price del { display: block; font-weight: 500; color: var(--nik-text-faint); font-size: 12px; }
.nik-compare-table__empty { color: var(--nik-text-faint); }
.nik-compare__price-out { color: #c0392b; font-weight: 700; }
.nik-compare__price-call { color: var(--nik-accent-600); font-weight: 700; }

.nik-compare-table__view {
	display: inline-block; padding: 9px 16px;
	font-size: 12.5px; font-weight: 800; text-decoration: none;
	color: var(--nik-accent-600); background: rgba(255,153,0,.1);
	border: 1px solid var(--nik-accent); border-radius: var(--nik-radius-sm);
	transition: background .15s ease, color .15s ease;
}
.nik-compare-table__view:hover { background: var(--nik-accent); color: #1a1a1a; }

/* Star rating (percentage-width overlay, mirrors the PDP stars). */
.nik-compare-stars { position: relative; display: inline-block; line-height: 1; font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.nik-compare-stars__off { color: var(--nik-border); }
.nik-compare-stars__on {
	position: absolute; inset-block-start: 0; inset-inline-start: 0;
	overflow: hidden; color: var(--nik-accent); white-space: nowrap;
}

/* =============================================================
   Product-card compare control
   Quiet by default; lit up only when the product is in the cart.
   ============================================================= */
.nik-product { position: relative; }
.nik-product__compare {
	position: absolute; inset-block-start: 50px; inset-inline-start: 10px; z-index: 3;
	display: inline-flex; align-items: center; justify-content: center;
	width: 34px; height: 34px; cursor: pointer;
	color: var(--nik-text-soft); background: rgba(255,255,255,.92);
	border: 1px solid var(--nik-border); border-radius: 50%;
	box-shadow: 0 2px 8px -2px rgba(11,28,69,.18);
	transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.nik-product__compare:hover { color: var(--nik-accent-600); border-color: var(--nik-accent); }
.nik-product__compare.is-active {
	color: #1a1a1a; background: var(--nik-accent); border-color: var(--nik-accent);
}

/* PDP «مقایسه» button active state (compare.js drives it now). */
.nik-pdp-tool.is-active {
	color: var(--nik-accent-600); border-color: var(--nik-accent); background: rgba(255,153,0,.06);
}

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 600px) {
	.nik-compare-drawer { width: 100vw; }
	.nik-compare-modal { padding: 0; }
	.nik-compare-modal__panel { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
	.nik-compare-table__label, .nik-compare-table__corner { min-width: 92px; }
	.nik-compare-table__product { min-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
	.nik-compare-drawer,
	.nik-compare-overlay,
	.nik-compare-modal,
	.nik-compare-modal__panel { transition: opacity .2s ease, visibility .2s; }
	.nik-compare-drawer { transform: none; }
	.nik-compare-modal__panel { transform: none; }
}
