/**
 * استایل جدول قیمت عمده‌فروشی
 *
 * تمام رنگ‌ها از متغیرهای CSS خوانده می‌شوند تا از صفحه تنظیمات قابل تغییر باشند.
 * همه کلاس‌ها با پیشوند agha-wh- هستند تا با هیچ قالبی تداخل نکنند.
 */

.agha-wh-table {
	--agha-wh-primary: #16462c;
	--agha-wh-button: #0d402f;
	--agha-wh-button-hover: #ce5c37;
	--agha-wh-danger: #b71c1c;
	--agha-wh-border: #e0e0e0;
	--agha-wh-stripe: #f8f9fa;
	--agha-wh-radius: 10px;
	--agha-wh-grid: 1.6fr 1fr 1fr 1.5fr 1.5fr 2fr;

	border: 1px solid var(--agha-wh-border);
	border-radius: var(--agha-wh-radius);
	overflow: hidden;
	margin-bottom: 40px;
	position: relative;
}

/* ---------- سربرگ ---------- */

.agha-wh-table .agha-wh-head {
	display: grid;
	grid-template-columns: var(--agha-wh-grid);
	background-color: var(--agha-wh-primary);
	color: #fff;
	padding: 15px 10px;
	text-align: center;
	font-weight: 700;
	font-size: 0.9rem;
}

/* ---------- ردیف‌ها ---------- */

.agha-wh-table .agha-wh-row {
	display: grid;
	grid-template-columns: var(--agha-wh-grid);
	align-items: center;
	padding: 15px 10px;
	border-bottom: 1px solid var(--agha-wh-border);
	text-align: center;
	font-size: 0.9rem;
	background: var(--agha-wh-stripe);
}

.agha-wh-table .agha-wh-row:nth-child(odd) {
	background: #fff;
}

.agha-wh-table .agha-wh-row:last-child {
	border-bottom: none;
}

.agha-wh-table .agha-wh-col-title {
	text-align: right;
	font-weight: 700;
	line-height: 1.7;
}

.agha-wh-table .agha-wh-row.agha-wh-status-unavailable {
	opacity: 0.75;
}

.agha-wh-table .agha-wh-unavailable,
.agha-wh-table .agha-wh-stock-out {
	color: var(--agha-wh-danger);
	font-weight: 700;
}

.agha-wh-table .agha-wh-inquiry-price {
	color: var(--agha-wh-danger);
	font-weight: 700;
}

.agha-wh-table .agha-wh-dash {
	opacity: 0.5;
}

/* ---------- جعبه تعداد ---------- */

.agha-wh-table .agha-wh-qty {
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #ccc;
	border-radius: 5px;
	overflow: hidden;
	width: 85%;
	margin: 0 auto;
	background: #fff;
}

.agha-wh-table .agha-wh-qty button {
	background: #eee;
	border: none;
	padding: 5px 12px;
	cursor: pointer;
	font-size: 1rem;
	line-height: 1.4;
	color: #333;
	transition: background 0.2s ease;
	flex: 0 0 auto;
}

.agha-wh-table .agha-wh-qty button:hover {
	background: #ddd;
}

.agha-wh-table .agha-wh-qty button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.agha-wh-table .agha-wh-qty input {
	width: 100%;
	min-width: 40px;
	border: none;
	text-align: center;
	padding: 5px 0;
	font-size: 0.9rem;
	background: transparent;
	-moz-appearance: textfield;
	appearance: textfield;
}

.agha-wh-table .agha-wh-qty input::-webkit-outer-spin-button,
.agha-wh-table .agha-wh-qty input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.agha-wh-table .agha-wh-qty input:focus {
	outline: 2px solid var(--agha-wh-primary);
	outline-offset: -2px;
}

/* ---------- دکمه‌ها ---------- */

.agha-wh-table .agha-wh-btn {
	display: inline-block;
	background: var(--agha-wh-button);
	color: #fff;
	padding: 10px 15px;
	border: none;
	border-radius: 5px;
	text-decoration: none;
	transition: background 0.3s ease, opacity 0.2s ease;
	font-size: 0.8rem;
	font-family: inherit;
	width: 80%;
	margin: auto;
	cursor: pointer;
	text-align: center;
}

.agha-wh-table .agha-wh-btn:hover {
	background: var(--agha-wh-button-hover);
	color: #fff;
}

.agha-wh-table .agha-wh-inquiry-btn {
	background: transparent;
	border: 1px solid var(--agha-wh-danger);
	color: var(--agha-wh-danger);
}

.agha-wh-table .agha-wh-inquiry-btn:hover {
	background: var(--agha-wh-danger);
	color: #fff;
}

/* ---------- وضعیت بارگذاری ---------- */

.agha-wh-table .agha-wh-btn.is-loading {
	pointer-events: none;
	opacity: 0.7;
	position: relative;
	color: transparent;
}

.agha-wh-table .agha-wh-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: agha-wh-spin 0.7s linear infinite;
}

.agha-wh-table .agha-wh-btn.is-added {
	background: #2e7d32;
}

@keyframes agha-wh-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.agha-wh-table .agha-wh-btn.is-loading::after {
		animation-duration: 3s;
	}
}

/* ---------- پیام‌ها ---------- */

.agha-wh-table .agha-wh-feedback {
	display: none;
	padding: 12px 15px;
	font-size: 0.9rem;
	text-align: right;
	border-top: 1px solid var(--agha-wh-border);
}

.agha-wh-table .agha-wh-feedback.is-visible {
	display: block;
}

.agha-wh-table .agha-wh-feedback.is-success {
	background: #edf7ed;
	color: #1e4620;
}

.agha-wh-table .agha-wh-feedback.is-error {
	background: #fdecea;
	color: #611a15;
}

.agha-wh-table .agha-wh-feedback a {
	color: inherit;
	font-weight: 700;
	margin-right: 8px;
	text-decoration: underline;
}

/* ---------- نمایش موبایل: تبدیل جدول به کارت ---------- */

@media (max-width: 768px) {
	.agha-wh-table {
		border: none;
		background: transparent;
		overflow: visible;
	}

	.agha-wh-table .agha-wh-head {
		display: none;
	}

	.agha-wh-table .agha-wh-row,
	.agha-wh-table .agha-wh-row:nth-child(odd) {
		display: block;
		background: #fff;
		border: 1px solid var(--agha-wh-border);
		border-radius: 12px;
		margin-bottom: 15px;
		padding: 12px;
		text-align: right;
	}

	.agha-wh-table .agha-wh-td {
		display: flex;
		justify-content: space-between;
		align-items: center;
		gap: 15px;
		padding: 10px 0;
		border-bottom: 1px solid #f0f0f0;
		text-align: right;
	}

	.agha-wh-table .agha-wh-td:last-child {
		border-bottom: none;
		padding-bottom: 0;
	}

	.agha-wh-table .agha-wh-td::before {
		content: attr(data-label);
		font-weight: 700;
		color: var(--agha-wh-primary);
		min-width: 90px;
		flex-shrink: 0;
	}

	.agha-wh-table .agha-wh-col-title {
		font-size: 1rem;
	}

	.agha-wh-table .agha-wh-qty {
		width: 160px;
		margin: 0;
	}

	.agha-wh-table .agha-wh-btn {
		width: auto;
		margin: 0;
		min-width: 140px;
	}

	.agha-wh-table .agha-wh-feedback {
		border: 1px solid var(--agha-wh-border);
		border-radius: 8px;
	}
}
