/* =========================================================
   جدول‌های زیبا و گرافیکی (مطالب، برگه‌ها، مشخصات خودرو)
   کلاس‌ها توسط inc/tables.php به‌صورت خودکار اضافه می‌شوند.
   ========================================================= */

.kc-table-wrap {
	--kc-t-accent: var(--khodro-primary);
	position: relative;
	margin: 28px 0;
	border-radius: var(--khodro-radius);
	border: 1px solid var(--khodro-border);
	background: var(--khodro-glass);
	-webkit-backdrop-filter: blur(var(--khodro-blur)) saturate(150%);
	backdrop-filter: blur(var(--khodro-blur)) saturate(150%);
	box-shadow: var(--khodro-shadow);
	overflow: hidden;
	max-width: 100%;
}
/* نوار رنگی بالای جدول */
.kc-table-wrap::before {
	content: '';
	display: block;
	height: 4px;
	background: linear-gradient(90deg, var(--kc-t-accent), color-mix(in srgb, var(--kc-t-accent) 35%, #4f7cff) 60%, color-mix(in srgb, #4f7cff 50%, transparent));
}

/* عنوان جدول (caption) */
.kc-table-title {
	display: flex; align-items: center; gap: 10px;
	padding: 13px 18px;
	font-weight: 800; font-size: 15.5px; line-height: 1.6;
	border-bottom: 1px solid var(--khodro-border);
	background: color-mix(in srgb, var(--kc-t-accent) 8%, transparent);
}
.kc-table-ico {
	flex: 0 0 30px; width: 30px; height: 30px; border-radius: 10px;
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='17' height='15' rx='2.5'/%3E%3Cpath d='M3.5 10h17M9.5 10v9.5'/%3E%3C/svg%3E") center / 18px no-repeat,
		linear-gradient(135deg, var(--kc-t-accent), color-mix(in srgb, var(--kc-t-accent) 45%, #4f7cff));
	box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--kc-t-accent) 70%, transparent);
}

/* ناحیه‌ی اسکرول افقی + سایه‌ی راهنما */
.kc-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--kc-t-accent) 50%, transparent) transparent; }
.kc-table-scroll:focus-visible { outline: 2px solid var(--kc-t-accent); outline-offset: -2px; }
.kc-table-scroll::-webkit-scrollbar { height: 7px; }
.kc-table-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--kc-t-accent) 50%, transparent); border-radius: 99px; }
.kc-table-wrap.is-scrollable::after {
	content: ''; position: absolute; top: 4px; bottom: 0; left: 0; width: 34px; pointer-events: none;
	background: linear-gradient(90deg, color-mix(in srgb, var(--khodro-bg) 80%, transparent), transparent);
	opacity: 1; transition: opacity .2s;
}
.kc-table-wrap.is-scrollable.at-end::after { opacity: 0; }

/* پایه‌ی جدول */
.khodro-single-content .kc-table,
.kc-table {
	width: 100%; min-width: 100%;
	border-collapse: separate; border-spacing: 0;
	margin: 0; border: 0;
	font-size: 14.5px; line-height: 1.75;
	background: transparent; table-layout: auto;
}
.kc-table th, .kc-table td {
	padding: 12px 18px;
	text-align: right; vertical-align: middle;
	border: 0; border-bottom: 1px solid var(--khodro-border);
	background: transparent; color: var(--khodro-text);
}
.kc-table [data-align="center"] { text-align: center; }
.kc-table [data-align="left"] { text-align: left; }
.kc-table tr:last-child > th, .kc-table tr:last-child > td { border-bottom: 0; }
.kc-table p { margin: 0; }
.kc-table td img { margin: 4px auto; border-radius: 8px; max-height: 120px; width: auto; }
.kc-table a { font-weight: 700; }

/* ردیف عنوان (thead یا ردیف اول پررنگ) */
.kc-table thead th,
.kc-table thead td,
.kc-table--hrow tbody tr:first-child > td,
.kc-table--hrow tbody tr:first-child > th,
.kc-table--hrow > tr:first-child > td {
	background: linear-gradient(180deg, color-mix(in srgb, var(--kc-t-accent) 26%, transparent), color-mix(in srgb, var(--kc-t-accent) 11%, transparent));
	color: var(--khodro-text);
	font-weight: 800; font-size: 13.5px;
	white-space: nowrap;
	border-bottom: 2px solid color-mix(in srgb, var(--kc-t-accent) 60%, transparent);
}
.kc-table--hrow tbody tr:first-child > td strong,
.kc-table--hrow tbody tr:first-child > td b { font-weight: 800; }

/* ردیف‌های راه‌راه و هاور */
.kc-table tbody tr:nth-child(even) > td,
.kc-table tbody tr:nth-child(even) > th { background: color-mix(in srgb, var(--khodro-text) 4.5%, transparent); }
.kc-table tbody tr { transition: background .15s ease; }
.kc-table tbody tr:hover > td,
.kc-table tbody tr:hover > th { background: color-mix(in srgb, var(--kc-t-accent) 10%, transparent); }
.kc-table--hrow tbody tr:first-child:hover > td { background: linear-gradient(180deg, color-mix(in srgb, var(--kc-t-accent) 26%, transparent), color-mix(in srgb, var(--kc-t-accent) 11%, transparent)); }

/* ستون اول به‌صورت برچسب (th داخل tbody یا جدول مشخصات) */
.kc-table tbody th,
.kc-table--data td:first-child,
.kc-table--data th:first-child { font-weight: 700; }
.kc-table tbody th {
	background: color-mix(in srgb, var(--kc-t-accent) 7%, transparent);
	border-right: 3px solid var(--kc-t-accent);
}

/* اعداد و قیمت‌ها */
.kc-table td.kc-num {
	font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
	font-weight: 800; color: var(--kc-digit, var(--kc-t-accent));
	white-space: nowrap;
}
.kc-table--data td.kc-num { text-align: center; }
html:not([data-khodro-theme="light"]) .kc-table td.kc-num { text-shadow: 0 0 12px color-mix(in srgb, var(--kc-digit, #ffb224) 35%, transparent); }

/* ===== جدول مشخصات (دو ستونه): هر ردیف یک «کارت برچسب-مقدار» ===== */
.kc-table--spec td:first-child {
	width: 38%; min-width: 120px;
	font-weight: 700; color: var(--khodro-muted); font-size: 14px;
	background: color-mix(in srgb, var(--kc-t-accent) 7%, transparent);
	border-right: 3px solid color-mix(in srgb, var(--kc-t-accent) 70%, transparent);
	position: relative;
}
.kc-table--spec tbody tr:nth-child(even) > td:first-child { background: color-mix(in srgb, var(--kc-t-accent) 11%, transparent); }
.kc-table--spec tr:hover > td:first-child { color: var(--khodro-text); border-right-color: var(--kc-t-accent); }
.kc-table--spec td:last-child { font-weight: 600; }
.kc-table--spec td.kc-num { text-align: right; }

/* جدول بدون سطر عنوان و چندستونه: ساده‌تر و خوانا */
.kc-table--plain td:first-child { font-weight: 700; }

/* جدول‌های عریض: ستون اول چسبیده هنگام اسکرول */
.kc-table--wide { min-width: 640px; }
.kc-table--wide tr > :first-child {
	position: sticky; right: 0; z-index: 1;
	background: color-mix(in srgb, var(--khodro-bg) 88%, var(--kc-t-accent) 6%);
	-webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
	box-shadow: -8px 0 12px -10px rgba(0,0,0,.35);
}
.kc-table--wide thead tr > :first-child { z-index: 2; }

/* ===== جدول‌های بلوک گوتنبرگ و ویرایشگر کلاسیک ===== */
.wp-block-table { margin: 0; overflow: visible; }
.wp-block-table > table { width: 100%; }
.wp-block-table figcaption { margin-top: 8px; }

/* ===== لیست مشخصات فنی خودرو (dl.kc-spec): ظاهر گرافیکی‌تر ===== */
.kc-box .kc-h {
	display: flex; align-items: center; gap: 10px;
}
.kc-box .kc-h::before {
	content: ''; width: 5px; height: 22px; border-radius: 99px;
	background: linear-gradient(180deg, var(--khodro-primary), color-mix(in srgb, var(--khodro-primary) 30%, #4f7cff));
}
.kc-sub-h {
	display: flex; align-items: center; gap: 8px;
	margin: 22px 0 10px !important; padding: 8px 12px;
	border-radius: 10px;
	background: color-mix(in srgb, var(--khodro-primary) 10%, transparent);
	color: var(--khodro-text) !important; font-weight: 800;
}
.kc-sub-h::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--khodro-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--khodro-primary) 25%, transparent); }
.kc-spec { gap: 8px 14px !important; }
.kc-spec > div {
	align-items: center;
	padding: 10px 14px !important;
	border: 1px solid var(--khodro-border); border-bottom: 1px solid var(--khodro-border) !important;
	border-radius: 12px;
	background: color-mix(in srgb, var(--khodro-text) 3.5%, transparent);
	transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.kc-spec > div:hover {
	transform: translateY(-2px);
	border-color: color-mix(in srgb, var(--khodro-primary) 50%, var(--khodro-border));
	background: color-mix(in srgb, var(--khodro-primary) 8%, transparent);
}
.kc-spec dt { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kc-spec dt::before { content: ''; flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--khodro-primary); opacity: .75; }
.kc-spec dd { font-weight: 800 !important; font-variant-numeric: tabular-nums; }

/* ===== ریسپانسیو ===== */
@media (max-width: 640px) {
	.kc-table-wrap { margin: 22px -4px; border-radius: 14px; }
	.kc-table th, .kc-table td { padding: 10px 12px; }
	.kc-table { font-size: 13.5px; }
	.kc-table-title { padding: 11px 14px; font-size: 14.5px; }
	.kc-table--spec td:first-child { width: 42%; }
	.kc-spec { gap: 6px 0 !important; }
}
@media print {
	.kc-table-wrap { box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; break-inside: avoid; }
	.kc-table-wrap.is-scrollable::after { display: none; }
}
