/**
 * FlexiDesignX — Shop / Category Page (Shopee-style with sidebar)
 *
 * @package FlexiDesignX
 * @since   1.0.0
 */

/* ==========================================================================
   Shop Layout — Sidebar + Content
   ========================================================================== */

.fdx-shop {
	padding: 0 0 2rem;
	background-color: var(--fdx-grey-50);
	overflow-x: hidden;
}

main.fdx-shop .fdx-shop__layout {
	display: flex;
	gap: 1rem;
	align-items: flex-start;
	max-width: 100%;
}

.fdx-shop__content {
	flex: 1;
	min-width: 0;
	max-width: 100%;
	overflow-x: hidden;
}

/* ==========================================================================
   Mobile Category Pills — Horizontal Scrollable (Shopee-style)
   ========================================================================== */

.fdx-cat-pills {
	display: none; /* Hidden on desktop — sidebar handles categories */
}

@media (max-width: 1024px) {
	.fdx-cat-pills {
		display: flex;
		gap: 8px;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none; /* Firefox */
		padding: 0 1rem 12px;
		margin: 0 -1rem;
	}

	.fdx-cat-pills::-webkit-scrollbar {
		display: none; /* Chrome/Safari */
	}

	.fdx-cat-pills__item {
		flex-shrink: 0;
		padding: 8px 16px;
		border-radius: 20px;
		font-size: 0.82rem;
		font-weight: 600;
		color: #666;
		background: #fff;
		border: 1.5px solid #e5e0dc;
		text-decoration: none;
		white-space: nowrap;
		transition: all 0.15s;
	}

	.fdx-cat-pills__item:hover {
		border-color: var(--fdx-accent);
		color: #1A1A1A;
	}

	.fdx-cat-pills__item--active {
		background: var(--fdx-accent);
		color: #fff;
		border-color: var(--fdx-accent);
	}

	.fdx-cat-pills__item--active:hover {
		background: #333;
		color: #fff;
		border-color: #333;
	}
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

main.fdx-shop .fdx-shop__sidebar {
	flex: 0 0 190px;
	background: var(--fdx-white);
	border-radius: var(--fdx-radius-md);
	box-shadow: var(--fdx-shadow-sm);
	padding: 1rem;
	position: sticky;
	top: 1rem;
}

main.fdx-shop .fdx-shop__content {
	flex: 1;
	min-width: 0;
}

.fdx-sidebar__section {
	margin-bottom: 1.25rem;
	padding-bottom: 1.25rem;
	border-bottom: 1px solid var(--fdx-grey-100);
}

.fdx-sidebar__section:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.fdx-sidebar__title {
	font-size: var(--fdx-font-size-sm);
	font-weight: 700;
	color: var(--fdx-grey-900);
	margin: 0 0 0.75rem;
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.fdx-sidebar__subtitle {
	font-size: var(--fdx-font-size-xs);
	font-weight: 600;
	color: var(--fdx-grey-700);
	margin: 0.75rem 0 0.5rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

/* Category list */
.fdx-sidebar__cat-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.fdx-sidebar__cat-item {
	margin-bottom: 0.125rem;
}

.fdx-sidebar__cat-item a {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.375rem 0;
	font-size: var(--fdx-font-size-sm);
	color: var(--fdx-grey-700);
	text-decoration: none;
	transition: color 0.15s;
}

.fdx-sidebar__cat-item a:hover {
	color: var(--fdx-accent);
}

.fdx-sidebar__cat-item--active > a {
	color: var(--fdx-accent);
	font-weight: 600;
}

.fdx-sidebar__arrow {
	font-size: 0.5rem;
	color: var(--fdx-accent);
}

/* Sub-categories */
.fdx-sidebar__subcat-list {
	list-style: none;
	margin: 0.25rem 0 0;
	padding-left: 1rem;
}

.fdx-sidebar__subcat-list li a {
	padding: 0.25rem 0;
	font-size: var(--fdx-font-size-xs);
	color: var(--fdx-grey-500);
}

.fdx-sidebar__subcat-list li a:hover {
	color: var(--fdx-accent);
}

/* Price filter */
.fdx-sidebar__price-inputs {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	margin-bottom: 0.5rem;
}

.fdx-sidebar__price-input {
	flex: 1;
	padding: 0.375rem 0.5rem;
	border: 1px solid var(--fdx-grey-300);
	border-radius: var(--fdx-radius-sm);
	font-size: var(--fdx-font-size-xs);
	text-align: center;
	outline: none;
	width: 100%;
	min-width: 0;
	-moz-appearance: textfield;
}

.fdx-sidebar__price-input::-webkit-inner-spin-button,
.fdx-sidebar__price-input::-webkit-outer-spin-button {
	-webkit-appearance: none;
}

.fdx-sidebar__price-input:focus {
	border-color: var(--fdx-accent);
}

.fdx-sidebar__price-sep {
	color: var(--fdx-grey-300);
	font-size: var(--fdx-font-size-xs);
}

.fdx-sidebar__apply-btn {
	width: 100%;
	padding: 0.5rem;
	background: var(--fdx-accent);
	color: var(--fdx-white);
	border: none;
	border-radius: var(--fdx-radius-sm);
	font-size: var(--fdx-font-size-xs);
	font-weight: 600;
	cursor: pointer;
	text-transform: uppercase;
	transition: background 0.15s;
}

.fdx-sidebar__apply-btn:hover {
	background: var(--fdx-accent-hover);
}

/* ==========================================================================
   Sort Bar (Shopee-style tabs)
   ========================================================================== */

main.fdx-shop .fdx-sort-bar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: rgba(0, 0, 0, 0.03);
	border-radius: var(--fdx-radius-sm);
	padding: 0.625rem 0.75rem;
	margin-bottom: 0.75rem;
	flex-wrap: wrap;
}

.fdx-sort-bar__label {
	font-size: var(--fdx-font-size-sm);
	color: var(--fdx-grey-500);
	white-space: nowrap;
}

.fdx-sort-bar__tabs {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	flex: 1;
}

.fdx-sort-bar__tab {
	padding: 0.375rem 0.875rem;
	font-size: var(--fdx-font-size-sm);
	font-weight: 500;
	color: var(--fdx-grey-700);
	text-decoration: none;
	border-radius: var(--fdx-radius-sm);
	transition: all 0.15s;
	white-space: nowrap;
}

.fdx-sort-bar__tab:hover {
	color: var(--fdx-grey-900);
	background: var(--fdx-white);
}

.fdx-sort-bar__tab--active {
	background: var(--fdx-accent);
	color: var(--fdx-white);
}

.fdx-sort-bar__tab--active:hover {
	background: var(--fdx-accent-hover);
	color: var(--fdx-white);
}

.fdx-sort-bar__price-select select {
	padding: 0.375rem 1.75rem 0.375rem 0.75rem;
	font-size: var(--fdx-font-size-sm);
	border: 1px solid var(--fdx-grey-200);
	border-radius: var(--fdx-radius-sm);
	background: var(--fdx-white);
	color: var(--fdx-grey-700);
	cursor: pointer;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B7280'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.5rem center;
}

/* Pagination mini in sort bar */
.fdx-sort-bar__pagination {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-left: auto;
}

.fdx-sort-bar__page-info {
	font-size: var(--fdx-font-size-sm);
	color: var(--fdx-accent);
	font-weight: 500;
}

.fdx-sort-bar__page-btn {
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--fdx-white);
	border: 1px solid var(--fdx-grey-200);
	border-radius: var(--fdx-radius-sm);
	text-decoration: none;
	color: var(--fdx-grey-700);
	font-size: var(--fdx-font-size-sm);
	transition: all 0.15s;
}

.fdx-sort-bar__page-btn:hover {
	border-color: var(--fdx-accent);
	color: var(--fdx-accent);
}

.fdx-sort-bar__page-btn--disabled {
	opacity: 0.3;
	cursor: default;
}

/* ==========================================================================
   Product Grid (in sidebar layout)
   ========================================================================== */

.woocommerce ul.products {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
}

.woocommerce ul.products li.product {
	margin: 0;
	padding: 0;
	width: auto;
	float: none;
	list-style: none;
}

/* Override Storefront's default product card styles */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
.woocommerce ul.products li.product h2 {
	font-size: 0.8125rem;
	font-weight: 400;
	padding: 0;
	margin: 0 0 0.375rem;
}

.woocommerce ul.products li.product .price {
	font-size: var(--fdx-font-size-base);
	color: var(--fdx-accent);
	margin-bottom: 0;
}

.woocommerce ul.products li.product .price del {
	font-size: var(--fdx-font-size-xs);
	color: var(--fdx-grey-500);
	opacity: 1;
}

.woocommerce ul.products li.product .price ins {
	text-decoration: none;
	font-weight: 700;
}

/* ==========================================================================
   Shop Pagination (bottom)
   ========================================================================== */

.fdx-shop__pagination {
	margin-top: 1.5rem;
	text-align: center;
}

.fdx-shop__pagination .woocommerce-pagination {
	margin: 0;
}

.fdx-shop__pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	list-style: none;
	padding: 0;
	margin: 0;
}

.fdx-shop__pagination .page-numbers li {
	display: inline-block;
}

.fdx-shop__pagination .page-numbers li a,
.fdx-shop__pagination .page-numbers li span {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 0.5rem;
	border-radius: 10px;
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
	transition: all 0.2s;
}

.fdx-shop__pagination .page-numbers li a {
	background: var(--fdx-white);
	color: var(--fdx-grey-700);
	border: 1.5px solid var(--fdx-grey-200);
}

.fdx-shop__pagination .page-numbers li a:hover {
	border-color: var(--fdx-accent);
	color: var(--fdx-accent);
	background: var(--fdx-accent-light);
	box-shadow: 0 2px 8px rgba(26,26,26,0.12);
}

.fdx-shop__pagination .page-numbers li span.current {
	background: var(--fdx-accent);
	color: var(--fdx-white);
	border: 1.5px solid var(--fdx-accent);
	box-shadow: 0 3px 10px rgba(26,26,26,0.25);
}

.fdx-shop__pagination .page-numbers li .dots {
	border: none;
	color: var(--fdx-grey-400);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.fdx-shop__empty {
	text-align: center;
	padding: 4rem 1rem;
	color: var(--fdx-grey-500);
	background: var(--fdx-white);
	border-radius: var(--fdx-radius-md);
}

.fdx-shop__empty p {
	margin-bottom: 1rem;
}

/* ==========================================================================
   Mobile Filter Toggle Button
   ========================================================================== */

.fdx-filter-toggle {
	display: none;
}

@media (max-width: 1024px) {
	/* Hide filter button on mobile — pills handle categories,
	   price filter available in drawer via long-press or remove entirely */
	.fdx-filter-toggle {
		display: none;
	}
}

/* ==========================================================================
   Mobile Filter Drawer + Overlay
   ========================================================================== */

.fdx-filter-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 1000;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.fdx-filter-drawer {
	position: fixed;
	top: 0;
	left: -300px;
	bottom: 0;
	width: 280px;
	max-width: 85vw;
	background: var(--fdx-white);
	z-index: 1001;
	box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
	transition: left 0.3s ease;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.fdx-filter-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem;
	border-bottom: 1px solid var(--fdx-grey-100);
	flex-shrink: 0;
}

.fdx-filter-drawer__title {
	font-size: 1rem;
	font-weight: 700;
	color: var(--fdx-grey-900);
}

.fdx-filter-drawer__close {
	background: none;
	border: none;
	font-size: 1.5rem;
	line-height: 1;
	color: var(--fdx-grey-500);
	cursor: pointer;
	padding: 0.25rem;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.fdx-filter-drawer__body {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 1rem;
}

/* Drawer category list: vertical layout (not horizontal pills) */
.fdx-filter-drawer .fdx-sidebar__cat-list--drawer {
	display: flex;
	flex-direction: column;
	gap: 0;
	overflow-x: visible;
}

.fdx-filter-drawer .fdx-sidebar__cat-list--drawer .fdx-sidebar__cat-item {
	flex-shrink: unset;
}

.fdx-filter-drawer .fdx-sidebar__cat-list--drawer .fdx-sidebar__cat-item a {
	border: none;
	border-radius: 0;
	padding: 0.5rem 0;
	white-space: normal;
}

.fdx-filter-drawer .fdx-sidebar__subcat-list {
	display: block;
}

/* Show price filter inside drawer */
.fdx-filter-drawer .fdx-sidebar__price-filter,
.fdx-filter-drawer .fdx-sidebar__subtitle {
	display: block;
}

/* Open state — triggered by JS toggling class on body */
body.fdx-filter-open .fdx-filter-overlay {
	display: block;
	opacity: 1;
}

body.fdx-filter-open .fdx-filter-drawer {
	left: 0;
}

/* Hide drawer elements on desktop */
@media (min-width: 1025px) {
	.fdx-filter-overlay,
	.fdx-filter-drawer {
		display: none;
	}
}

/* ==========================================================================
   Mobile — sidebar becomes horizontal filter bar
   ========================================================================== */

@media (max-width: 1024px) {
	/* Hide entire sidebar on mobile/tablet — pills + filter drawer replace it */
	.fdx-shop__sidebar {
		display: none;
	}

	.fdx-shop__layout {
		flex-direction: column;
	}

	/* Sort bar: scroll on small screens */
	.fdx-sort-bar {
		overflow-x: auto;
		flex-wrap: nowrap;
	}

	.fdx-sort-bar__tabs {
		flex-shrink: 0;
	}
}

/* ==========================================================================
   Tablet — 3 columns
   ========================================================================== */

@media (min-width: 768px) {
	.woocommerce ul.products {
		grid-template-columns: repeat(3, 1fr);
		gap: 0.625rem;
	}
}

/* ==========================================================================
   Desktop — 5 columns
   ========================================================================== */

@media (min-width: 1025px) {
	.woocommerce ul.products {
		grid-template-columns: repeat(4, 1fr);
		gap: 0.5rem;
	}

	.fdx-shop__sidebar {
		flex: 0 0 200px;
	}
}
