/* WooProductTable front-end styles. RTL-first, fully responsive. */

.wpt-wrap {
	--wpt-header-bg: #0073aa;
	--wpt-header-text: #fff;
	--wpt-row-bg: #fff;
	--wpt-row-alt-bg: #f6f7f7;
	--wpt-row-text: #333;
	--wpt-border: #e0e0e0;
	--wpt-accent: #0073aa;
	position: relative;
	margin: 1.5em 0;
	direction: rtl;
}

/* Toolbar: search + category filter */
.wpt-toolbar {
	display: flex;
	gap: 12px;
	align-items: stretch;
	flex-wrap: wrap;
	margin-bottom: 14px;
}

.wpt-search-input,
.wpt-cat-filter {
	box-sizing: border-box;
	margin: 0;
	padding: 13px 16px;
	border: 1px solid var(--wpt-border);
	border-radius: 10px;
	font-size: 15px;
	font-family: inherit;
	line-height: 1.4;
	height: auto;
	-webkit-appearance: none;
	appearance: none;
	background: var(--wpt-row-bg);
	color: var(--wpt-row-text);
	transition: border-color .15s ease, box-shadow .15s ease;
}

/* Kill the iOS search input default look that breaks alignment */
.wpt-search-input::-webkit-search-decoration,
.wpt-search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.wpt-search-input {
	flex: 1 1 280px;
	min-width: 0;
}

.wpt-search-input:focus,
.wpt-cat-filter:focus {
	outline: none;
	border-color: var(--wpt-accent);
	box-shadow: 0 0 0 3px color-mix( in srgb, var(--wpt-accent) 20%, transparent );
}

.wpt-cat-filter {
	flex: 0 0 240px;
	cursor: pointer;
	/* native arrow on the left side for RTL */
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding-left: 40px;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8 0 0h12z'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: left 16px center;
}

.wpt-table-scroll {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--wpt-border);
	border-radius: 10px;
}

.wpt-table {
	width: 100%;
	border-collapse: collapse;
	background: var(--wpt-row-bg);
	color: var(--wpt-row-text);
	font-size: 15px;
	margin: 0;
}

.wpt-table thead th {
	background: var(--wpt-header-bg);
	color: var(--wpt-header-text);
	text-align: right;
	padding: 14px 12px;
	font-weight: 700;
	white-space: nowrap;
	position: sticky;
	top: 0;
	z-index: 2;
}

.wpt-table tbody td {
	padding: 12px;
	border-top: 1px solid var(--wpt-border);
	vertical-align: middle;
	text-align: right;
}

.wpt-table tbody tr:nth-child(even) {
	background: var(--wpt-row-alt-bg);
}

.wpt-table tbody tr:hover {
	background: color-mix( in srgb, var(--wpt-accent) 8%, transparent );
}

/* Default: every column centered & shrink-to-content */
.wpt-table thead th,
.wpt-table tbody td {
	text-align: center;
	white-space: nowrap;
}

/* Name column absorbs free space, stays right-aligned */
.wpt-col-name {
	text-align: right;
	white-space: normal;
	width: auto;
	min-width: 220px;
}

/* Image: fixed, centered, with breathing room from the edge */
.wpt-col-image {
	width: 96px;
	text-align: center;
	padding-inline-start: 16px;
}

.wpt-col-cart {
	width: 120px;
}

/* Attribute / price / coop / stock: comfortable fixed-ish width */
.wpt-col-price,
.wpt-col-coop,
.wpt-col-sku,
.wpt-col-stock {
	width: 140px;
}

.wpt-thumb img,
.wpt-table img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 8px;
	display: block;
}

.wpt-na {
	color: #999;
}

.wpt-in-stock {
	color: #2e7d32;
	font-weight: 600;
}

.wpt-out-stock {
	color: #c62828;
	font-weight: 600;
}

.wpt-empty {
	text-align: center !important;
	padding: 32px 12px;
	color: #777;
}

.wpt-table .button,
.wpt-add-cart,
.wpt-view {
	display: inline-block;
	background: var(--wpt-accent);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 8px 16px;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
	text-decoration: none;
	transition: filter .15s ease;
	white-space: nowrap;
}

.wpt-table .button:hover {
	filter: brightness( 0.92 );
	color: #fff;
}

/* Pagination */
.wpt-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 16px;
	flex-wrap: wrap;
}

.wpt-pagination:empty {
	display: none;
}

.wpt-page-btn {
	background: var(--wpt-accent);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 9px 20px;
	font-size: 14px;
	cursor: pointer;
	transition: filter .15s ease, opacity .15s ease;
}

.wpt-page-btn:hover:not([disabled]) {
	filter: brightness( 0.92 );
}

.wpt-page-btn[disabled] {
	opacity: .45;
	cursor: default;
}

.wpt-page-info {
	font-size: 14px;
	color: var(--wpt-row-text);
}

/* Loading overlay */
.wpt-loading[hidden] {
	display: none;
}

.wpt-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 80px;
	background: rgba( 255, 255, 255, .55 );
	border-radius: 10px;
}

.wpt-spinner {
	width: 36px;
	height: 36px;
	border: 4px solid var(--wpt-border);
	border-top-color: var(--wpt-accent);
	border-radius: 50%;
	animation: wpt-spin .8s linear infinite;
}

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

.wpt-is-loading .wpt-table {
	opacity: .5;
}

/* ---------- Responsive: stacked cards on small screens ---------- */
@media ( max-width: 782px ) {
	.wpt-toolbar {
		align-items: stretch;
	}

	.wpt-search-input,
	.wpt-cat-filter {
		flex: 1 1 100%;
		width: 100%;
		padding: 16px;
		font-size: 16px; /* prevents iOS zoom-on-focus */
	}

	.wpt-table-scroll {
		overflow-x: visible;
		border: none;
		border-radius: 0;
	}

	.wpt-table thead {
		display: none;
	}

	.wpt-table,
	.wpt-table tbody,
	.wpt-table tr,
	.wpt-table td {
		display: block;
		width: 100%;
	}

	.wpt-table tbody tr {
		border: 1px solid var(--wpt-border);
		border-radius: 10px;
		margin-bottom: 14px;
		padding: 6px 0;
		background: var(--wpt-row-bg);
		box-shadow: 0 1px 4px rgba( 0, 0, 0, .05 );
	}

	.wpt-table tbody tr:nth-child(even) {
		background: var(--wpt-row-bg);
	}

	.wpt-table tbody td {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 14px;
		border-top: none;
		border-bottom: 1px solid var(--wpt-border);
		padding: 10px 14px;
		text-align: left;
		white-space: normal;
		width: 100%;
	}

	.wpt-table tbody td:last-child {
		border-bottom: none;
	}

	.wpt-table tbody td::before {
		content: attr( data-label );
		font-weight: 700;
		color: var(--wpt-header-bg);
		flex: 0 0 auto;
		text-align: right;
	}

	.wpt-col-image,
	.wpt-col-cart {
		width: 100%;
		white-space: normal;
	}

	.wpt-col-image::before {
		display: none;
	}

	.wpt-col-image {
		justify-content: center;
	}

	.wpt-thumb img,
	.wpt-table img {
		width: 96px;
		height: 96px;
	}

	.wpt-table .button {
		width: 100%;
		text-align: center;
		padding: 12px;
	}
}

@media ( max-width: 420px ) {
	.wpt-page-btn {
		padding: 9px 14px;
	}
}
