/**
 * Filters Sidebar Styles
 *
 * @package MyBestClinicShop
 */

/* Shop Content Layout */
.mbcs-shop-content {
	display: grid !important;
	gap: 40px !important;
	margin: 0 0 40px !important;
	width: 100% !important;
	max-width: 100% !important;
	grid-template-columns: 1fr !important;
}

/* With filters sidebar */
.mbcs-shop-content.has-filters {
	grid-template-columns: 280px 1fr !important;
}

/* Fallback for :has() selector (modern browsers) */
.mbcs-shop-content:has(.mbcs-filters-sidebar) {
	grid-template-columns: 280px 1fr !important;
}

/* Filters Sidebar - Sticky positioning */
.mbcs-filters-sidebar {
	position: sticky;
	top: calc(120px + 75px + 8px); /* Header height + top-bar height + margin */
	height: fit-content;
	max-height: calc(100vh - 120px - 75px - 40px); /* Viewport minus header, top-bar, and spacing */
	overflow-y: auto;
	align-self: flex-start;
}

.mbcs-filters-container {
	padding: 24px;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
}

/* Filters Header */
.mbcs-filters-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 24px;
	padding: 0 0 16px;
	border-bottom: 2px solid #e0e0e0;
}

.mbcs-filters-header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

.mbcs-clear-filters {
	padding: 6px 12px;
	font-size: 13px;
	color: #d63638;
	background: transparent;
	border: 1px solid #d63638;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.3s ease;
}

.mbcs-clear-filters:hover {
	color: #ffffff;
	background: #d63638;
}

/* Filter Groups */
.mbcs-filter-group {
	margin: 0 0 24px;
}

.mbcs-filter-group:last-child {
	margin-bottom: 0;
}

.mbcs-filter-group > label {
	display: block;
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 600;
	color: #333;
}

/* Search Input */
/* Search input wrapper for icon */
.mbcs-search-input-wrapper {
	position: relative;
	width: 100%;
}

.mbcs-search-icon {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: #999;
	pointer-events: none;
	z-index: 1;
}

.mbcs-filter-search input[type="text"] {
	width: 100%;
	padding: 10px 14px 10px 36px;
	font-size: 14px;
	border: 1px solid #ddd;
	border-radius: 4px;
	transition: all 0.3s ease;
}

.mbcs-filter-search input[type="text"]:focus {
	outline: none;
	border-color: #0073aa;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.mbcs-search-hint {
	margin-top: 6px;
	font-size: 11px;
	color: #999;
	font-style: italic;
}

/* Price Inputs */
.mbcs-price-inputs {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mbcs-price-inputs input[type="number"] {
	flex: 1;
	padding: 10px 14px;
	font-size: 14px;
	border: 1px solid #ddd;
	border-radius: 4px;
	transition: border-color 0.3s ease;
}

.mbcs-price-inputs input[type="number"]:focus {
	outline: none;
	border-color: #0073aa;
}

.mbcs-price-inputs span {
	color: #666;
}

/* Filter Options (Checkboxes) */
.mbcs-filter-options {
	max-height: 200px;
	overflow-y: auto;
}

.mbcs-filter-options::-webkit-scrollbar {
	width: 6px;
}

.mbcs-filter-options::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 3px;
}

.mbcs-filter-options::-webkit-scrollbar-thumb {
	background: #ccc;
	border-radius: 3px;
}

.mbcs-filter-options::-webkit-scrollbar-thumb:hover {
	background: #999;
}

.mbcs-checkbox-label {
	display: flex;
	align-items: center;
	margin: 0 0 8px;
	font-size: 14px;
	cursor: pointer;
	transition: color 0.3s ease;
}

.mbcs-checkbox-label:hover {
	color: #0073aa;
}

.mbcs-checkbox-label input[type="checkbox"] {
	margin: 0 8px 0 0;
	cursor: pointer;
}

.mbcs-checkbox-label span {
	flex: 1;
}

/* Apply Filters Button */
.mbcs-apply-filters {
	width: 100%;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 600;
	color: #ffffff;
	background: #0073aa;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.3s ease;
}

.mbcs-apply-filters:hover {
	background: #005a87;
}

/* Filters Bar (Top) */
.mbcs-filters-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 24px;
	padding: 16px 20px;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
}

.mbcs-sort-wrapper {
	display: flex;
	align-items: center;
	gap: 12px;
	white-space: nowrap; /* Prevent line break */
}

.mbcs-sort-wrapper label {
	font-size: 14px;
	font-weight: 600;
	color: #333;
	white-space: nowrap; /* Keep "Sort by:" on one line */
}

.mbcs-sort-wrapper select {
	padding: 8px 32px 8px 12px;
	font-size: 14px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #ffffff;
	cursor: pointer;
	transition: border-color 0.3s ease;
}

.mbcs-sort-wrapper select:focus {
	outline: none;
	border-color: #0073aa;
}

.mbcs-results-count {
	font-size: 14px;
	color: #666;
}

.mbcs-showing-count {
	font-weight: 700;
	color: #333;
}

/* Loading Indicator */
.mbcs-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px;
	margin: 20px 0;
}

.mbcs-spinner {
	width: 40px;
	height: 40px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #0073aa;
	border-radius: 50%;
	animation: mbcs-spin 1s linear infinite;
}

@keyframes mbcs-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.mbcs-no-more-products {
	text-align: center;
	padding: 20px;
	margin: 20px 0;
	font-size: 14px;
	color: #666;
}

/* Responsive */
@media (max-width: 992px) {
	.mbcs-shop-content {
		grid-template-columns: 240px 1fr !important;
		gap: 24px !important;
	}
	
	.mbcs-filters-sidebar {
		top: calc(87px + 60px + 8px); /* Tablet header + top-bar + margin */
		max-height: calc(100vh - 87px - 60px - 40px);
	}

	.mbcs-filters-container {
		padding: 20px;
	}
	
	.mbcs-products-grid {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}

@media (max-width: 768px) {
	/* CRITICAL: Override all desktop grid styles for mobile */
	.mbcs-shop-content,
	.mbcs-shop-content.has-filters,
	.mbcs-shop-content:has(.mbcs-filters-sidebar) {
		grid-template-columns: 1fr !important;
		gap: 0 !important;
		display: block !important;
	}
	
	/* Product archive takes full width */
	.mbcs-product-archive {
		width: 100% !important;
		max-width: 100% !important;
	}

	.mbcs-filters-bar {
		flex-direction: column;
		gap: 12px;
		align-items: stretch;
	}

	.mbcs-results-count {
		text-align: left;
	}
	
	/* Mobile Drawer Styles */
	.mbcs-filters-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		max-width: 320px;
		height: 100vh;
		max-height: 100vh;
		z-index: 9999;
		transform: translateX(-100%);
		transition: transform 0.3s ease-in-out;
		background: #ffffff;
		overflow-y: auto;
		box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
	}
	
	.mbcs-filters-sidebar.is-open {
		transform: translateX(0);
	}
	
	.mbcs-filters-container {
		padding: 20px;
		padding-top: 70px; /* Space for close button */
		border: none;
		border-radius: 0;
		min-height: 100%;
	}
	
	/* Mobile Filter Close Button */
	.mbcs-mobile-filter-close {
		position: absolute;
		top: 16px;
		right: 16px;
		width: 40px;
		height: 40px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #f5f5f5;
		border: none;
		border-radius: 50%;
		cursor: pointer;
		transition: all 0.2s ease;
		z-index: 10;
	}
	
	.mbcs-mobile-filter-close:hover {
		background: #e0e0e0;
	}
	
	.mbcs-mobile-filter-close svg {
		width: 20px;
		height: 20px;
		color: #333;
	}
	
	/* Mobile Filter Overlay */
	.mbcs-filter-overlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		z-index: 9998;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.3s ease, visibility 0.3s ease;
	}
	
	.mbcs-filter-overlay.is-visible {
		opacity: 1;
		visibility: visible;
	}
	
	/* Prevent body scroll when drawer is open */
	body.mbcs-filters-open {
		overflow: hidden;
	}
	
	/* Mobile Apply Filters Button (sticky at bottom of drawer) */
	.mbcs-mobile-apply-wrapper {
		display: block;
		position: sticky;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 16px 20px;
		background: #ffffff;
		border-top: 1px solid #e0e0e0;
		margin: 20px -20px -20px;
	}
	
	.mbcs-mobile-apply-filters {
		width: 100%;
		padding: 14px 24px;
		font-size: 16px;
		font-weight: 600;
		color: #ffffff;
		background: #2563eb;
		border: none;
		border-radius: 8px;
		cursor: pointer;
		transition: background 0.3s ease;
	}
	
	.mbcs-mobile-apply-filters:hover {
		background: #1d4ed8;
	}
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
	.mbcs-mobile-filter-close,
	.mbcs-mobile-apply-wrapper,
	.mbcs-filter-overlay,
	.mbcs-mobile-filter-toggle {
		display: none !important;
	}
}

