/**
 * Drunel Product Grid – Styles
 * v2.2.0
 *
 * Desktop: CSS Grid cards
 * Mobile (table-row mode): Flex row per product
 */

/* ==========================================================================
   Grid container
   ========================================================================== */

.drunel-pgrid {
	--drunel-pgrid-cols: 4;
	--drunel-pgrid-row-gap: 20px;
	--drunel-pgrid-col-gap: 20px;
}

.drunel-pgrid__items {
	display: grid;
	grid-template-columns: repeat(var(--drunel-pgrid-cols), 1fr);
	row-gap: var(--drunel-pgrid-row-gap);
	column-gap: var(--drunel-pgrid-col-gap);
}

/* ==========================================================================
   Card
   ========================================================================== */

.drunel-pgrid__item {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border-radius: 6px;
	transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

/* ==========================================================================
   Image
   ========================================================================== */

.drunel-pgrid__image {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.drunel-pgrid__image a {
	display: flex;
	flex: 1;
	min-height: 0;
}

.drunel-pgrid__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .35s ease, opacity .35s ease;
	border-radius: inherit;
}

/* Hover effects */
.drunel-pgrid--hover-zoom .drunel-pgrid__image:hover img {
	transform: scale(1.08);
}
.drunel-pgrid--hover-opacity .drunel-pgrid__image:hover img {
	opacity: .75;
}

/* ==========================================================================
   Sale badge
   ========================================================================== */

.drunel-pgrid__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	display: inline-block;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	color: #fff;
	background-color: #e53935;
	border-radius: 3px;
}

/* ==========================================================================
   Body
   ========================================================================== */

.drunel-pgrid__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	padding: 12px 16px 16px;
	align-items: stretch;
}

/* Centered button when text-align:center */
.drunel-pgrid__body[style*="text-align: center"] .drunel-pgrid__btn,
.drunel-pgrid__body[style*="text-align:center"] .drunel-pgrid__btn {
	width: auto;
}

/* Category */
.drunel-pgrid__category {
	font-size: 12px;
	color: #999;
	margin-bottom: 4px;
}

.drunel-pgrid__category a {
	color: inherit;
	text-decoration: none;
}

.drunel-pgrid__category a:hover {
	text-decoration: underline;
}

/* Title */
.drunel-pgrid__title {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
}

.drunel-pgrid__title-link {
	color: inherit;
	text-decoration: none;
	transition: color .2s ease;
}

/* Price */
.drunel-pgrid__price {
	font-size: 14px;
	font-weight: 500;
	margin-bottom: 4px;
}

.drunel-pgrid__price del {
	opacity: .55;
	margin-right: 4px;
}

.drunel-pgrid__price ins {
	text-decoration: none;
	font-weight: 700;
}

/* Stock */
.drunel-pgrid__stock {
	font-size: 12px;
	margin-bottom: 6px;
}

.drunel-pgrid__stock--instock {
	color: #43a047;
}

.drunel-pgrid__stock--outofstock {
	color: #e53935;
}

.drunel-pgrid__stock--onbackorder {
	color: #fb8c00;
}

/* ==========================================================================
   Button
   ========================================================================== */

.drunel-pgrid__action {
	margin-top: auto;
	padding-top: 10px;
}

.drunel-pgrid__btn {
	display: inline-block;
	width: 100%;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	color: #fff;
	background-color: #333;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease;
	box-sizing: border-box;
}

.drunel-pgrid__btn:hover {
	background-color: #555;
	color: #fff;
}

.drunel-pgrid__btn.drunel-pgrid__btn--loading {
	pointer-events: none;
	opacity: .65;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.drunel-pgrid__pagination,
.drunel-pgrid__load-more {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px;
	margin-top: var(--drunel-pgrid-row-gap);
}

.drunel-pgrid__page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 10px;
	font-size: 14px;
	font-weight: 500;
	color: #333;
	background: #f5f5f5;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	transition: background .2s, color .2s;
}

.drunel-pgrid__page-btn:hover {
	background: #e0e0e0;
}

.drunel-pgrid__page-btn--active {
	background: #333;
	color: #fff;
	border-color: #333;
}

.drunel-pgrid__load-more-btn {
	padding: 10px 32px;
	font-size: 14px;
	font-weight: 600;
	color: #333;
	background: #f5f5f5;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	transition: background .2s;
}

.drunel-pgrid__load-more-btn:hover {
	background: #e0e0e0;
}

.drunel-pgrid__load-more-btn.drunel-pgrid__btn--loading {
	pointer-events: none;
	opacity: .65;
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.drunel-pgrid__empty {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	text-align: center;
}

.drunel-pgrid__empty-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 14px;
	line-height: 1;
	color: #ccc;
}

.drunel-pgrid__empty-icon svg {
	fill: currentColor;
}

.drunel-pgrid__empty-img {
	margin-bottom: 14px;
	object-fit: contain;
}

.drunel-pgrid__empty-title {
	margin: 0 0 6px;
	font-size: 16px;
	font-weight: 600;
	color: #555;
}

.drunel-pgrid__empty-desc {
	margin: 0;
	font-size: 14px;
	color: #999;
	max-width: 400px;
}

.drunel-pgrid__empty .dashicons {
	font-size: 40px;
	width: 40px;
	height: 40px;
	margin-bottom: 10px;
	color: #ccc;
}

/* ==========================================================================
   AJAX loading overlay
   ========================================================================== */

.drunel-pgrid--loading .drunel-pgrid__items {
	opacity: .45;
	pointer-events: none;
	transition: opacity .2s;
}

/* ==========================================================================
   TABLE-ROW MODE
   Activated by JS class toggle based on viewport + settings.
   ========================================================================== */

.drunel-pgrid--table-row {
	--drunel-trow-cols: 1;
}

.drunel-pgrid--table-row .drunel-pgrid__items {
	display: grid;
	grid-template-columns: repeat(var(--drunel-trow-cols, 1), 1fr);
	row-gap: var(--drunel-pgrid-row-gap, 0px);
}

.drunel-pgrid--table-row .drunel-pgrid__item {
	flex-direction: row;
	align-items: center;
	border-radius: 0;
	border-bottom: 1px solid #eee;
	box-shadow: none !important;
	padding: 10px 12px;
}

/* Thumbnail in row */
.drunel-pgrid--table-row .drunel-pgrid__image {
	width: 60px;
	min-width: 60px;
	border-radius: 4px !important;
	margin-right: 12px;
	flex-shrink: 0;
	box-shadow: none !important;
	padding: 0 !important;
	overflow: hidden;
}

.drunel-pgrid--table-row .drunel-pgrid__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 4px !important;
	box-shadow: none !important;
}

/* Badge repositioned */
.drunel-pgrid--table-row .drunel-pgrid__badge {
	top: 0;
	left: 0;
	font-size: 10px;
	padding: 2px 5px;
	border-radius: 4px 0 4px 0;
}

/* Body takes remaining space */
.drunel-pgrid--table-row .drunel-pgrid__body {
	flex: 1 1 auto;
	padding: 0;
	min-width: 0;
	flex-direction: column;
	justify-content: center;
}

.drunel-pgrid--table-row .drunel-pgrid__title {
	font-size: 14px;
	margin-bottom: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.drunel-pgrid--table-row .drunel-pgrid__price {
	font-size: 13px;
	margin-bottom: 0;
}

/* Compact button in row */
.drunel-pgrid--table-row .drunel-pgrid__action {
	margin-top: 4px;
	padding-top: 0;
}

.drunel-pgrid--table-row .drunel-pgrid__btn {
	padding: 5px 10px;
	font-size: 12px;
	width: auto;
}

/* --- Zebra striping — row-based, adapts to column count --- */
/* 1 column (default) */
.drunel-pgrid--table-row[data-trow-cols="1"] .drunel-pgrid__item:nth-child(even) {
	background-color: #fafafa;
}

/* 2 columns: rows 2,4,6… = items 3-4, 7-8, 11-12… */
.drunel-pgrid--table-row[data-trow-cols="2"] .drunel-pgrid__item:nth-child(4n+3),
.drunel-pgrid--table-row[data-trow-cols="2"] .drunel-pgrid__item:nth-child(4n+4) {
	background-color: #fafafa;
}

/* 3 columns: rows 2,4,6… = items 4-5-6, 10-11-12… */
.drunel-pgrid--table-row[data-trow-cols="3"] .drunel-pgrid__item:nth-child(6n+4),
.drunel-pgrid--table-row[data-trow-cols="3"] .drunel-pgrid__item:nth-child(6n+5),
.drunel-pgrid--table-row[data-trow-cols="3"] .drunel-pgrid__item:nth-child(6n+6) {
	background-color: #fafafa;
}
