/* ==========================================================================
   MDM Medicine Filter — Layout, Sidebar, Pills, Pagination
   ========================================================================== */

/* ── Top bar (count + mobile toggle) ── */
.mdm-filter-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
	gap: 12px;
	flex-wrap: wrap;
}

.mdm-filter-topcount {
	margin: 0;
	font-size: 14px;
	color: #64748b;
}

.mdm-filter-toggle {
	display: none;   /* shown only on mobile via media query */
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.mdm-filter-toggle:hover { background: #1d4ed8; }

/* ── Two-column layout ── */
.mdm-filter-layout {
	display: grid;
	grid-template-columns: 260px 1fr;
	gap: 28px;
	align-items: start;
	position: relative;
}

/* ── Mobile overlay backdrop ── */
.mdm-filter-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.45 );
	z-index: 9998;
}

.mdm-filter-backdrop.mdm-backdrop-visible { display: block; }

/* ==========================================================================
   Sidebar
   ========================================================================== */
.mdm-filter-sidebar {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	overflow: hidden;
	position: sticky;
	top: 24px;
	max-height: calc( 100vh - 48px );
	overflow-y: auto;
}

.mdm-sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	border-bottom: 1px solid #e2e8f0;
	background: #f8fafc;
	position: sticky;
	top: 0;
	z-index: 1;
}

.mdm-sidebar-title {
	font-size: 15px;
	font-weight: 700;
	color: #1e3a8a;
	margin: 0;
}

.mdm-sidebar-close {
	display: none;   /* shown on mobile */
	background: none;
	border: none;
	font-size: 18px;
	cursor: pointer;
	color: #64748b;
	padding: 2px 6px;
	border-radius: 4px;
	line-height: 1;
}

.mdm-sidebar-close:hover { background: #f1f5f9; color: #1a202c; }

/* ── Filter form ── */
.mdm-filter-form {
	padding: 0 0 12px;
}

.mdm-filter-section {
	padding: 14px 18px;
	border-bottom: 1px solid #f1f5f9;
}

.mdm-filter-section:last-child { border-bottom: none; }

.mdm-filter-section-title {
	display: block;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #94a3b8;
	margin-bottom: 10px;
}

/* ── Options list (checkboxes) ── */
.mdm-filter-options {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.mdm-filter-options-scroll {
	max-height: 180px;
	overflow-y: auto;
	padding-right: 4px;
}

.mdm-filter-options-scroll::-webkit-scrollbar       { width: 4px; }
.mdm-filter-options-scroll::-webkit-scrollbar-track { background: #f8fafc; }
.mdm-filter-options-scroll::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

.mdm-filter-checkbox {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 13px;
	color: #374151;
	padding: 3px 0;
}

.mdm-filter-checkbox input[type="checkbox"] {
	width: 15px;
	height: 15px;
	accent-color: #2563eb;
	cursor: pointer;
	flex-shrink: 0;
}

.mdm-checkbox-label { line-height: 1.3; }

/* ── Inputs (keyword + price) ── */
.mdm-filter-input {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #cbd5e0;
	border-radius: 7px;
	font-size: 13px;
	color: #1a202c;
	outline: none;
	transition: border-color 0.2s;
}

.mdm-filter-input:focus { border-color: #2563eb; }

.mdm-filter-search-row { position: relative; }

/* ── Price range ── */
.mdm-price-range-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mdm-price-input { flex: 1; min-width: 0; }

.mdm-price-sep {
	font-size: 14px;
	color: #94a3b8;
	flex-shrink: 0;
}

.mdm-price-hint {
	margin: 6px 0 0;
	font-size: 11px;
	color: #94a3b8;
}

/* ── Company + Sort selects ── */
.mdm-filter-select {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #cbd5e0;
	border-radius: 7px;
	font-size: 13px;
	color: #1a202c;
	background: #fff;
	outline: none;
	cursor: pointer;
	transition: border-color 0.2s;
	appearance: auto;
}

.mdm-filter-select:focus { border-color: #2563eb; }

/* ── Actions ── */
.mdm-filter-actions {
	padding: 14px 18px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mdm-filter-apply-btn { width: 100%; text-align: center; }
.mdm-filter-clear-btn { width: 100%; text-align: center; font-size: 13px; padding: 8px 16px; }

/* ==========================================================================
   Results panel
   ========================================================================== */
.mdm-filter-results {
	min-height: 300px;
	position: relative;
}

/* Loading overlay */
.mdm-filter-loading-overlay {
	display: none;
	position: absolute;
	inset: 0;
	z-index: 10;
	background: rgba( 255, 255, 255, 0.82 );
	align-items: center;
	justify-content: center;
	gap: 10px;
	font-size: 14px;
	color: #64748b;
	border-radius: 12px;
	backdrop-filter: blur( 2px );
}

.mdm-filter-loading-overlay.mdm-loading-visible {
	display: flex;
}

.mdm-results-loading { opacity: 0.5; pointer-events: none; }

/* Result header */
.mdm-filter-result-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	flex-wrap: wrap;
	gap: 8px;
}

.mdm-filter-count-text {
	margin: 0;
	font-size: 14px;
	color: #64748b;
}

.mdm-count-page {
	font-size: 12px;
	color: #94a3b8;
}

/* ==========================================================================
   Active Filter Pills
   ========================================================================== */
.mdm-filter-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
}

.mdm-filter-pill {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 12px;
	background: #eff6ff;
	color: #1e40af;
	border: 1px solid #bfdbfe;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s;
	cursor: pointer;
}

.mdm-filter-pill:hover {
	background: #dbeafe;
	border-color: #93c5fd;
	color: #1e3a8a;
	text-decoration: none;
}

.mdm-pill-cat  { opacity: 0.65; font-weight: 500; }
.mdm-pill-x    { font-size: 10px; opacity: 0.7; margin-left: 2px; }

.mdm-pill-clear-all {
	background: #fef2f2;
	color: #dc2626;
	border-color: #fecaca;
}

.mdm-pill-clear-all:hover {
	background: #fee2e2;
	border-color: #fca5a5;
	color: #b91c1c;
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.mdm-filter-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 28px;
}

.mdm-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 10px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	color: #374151;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	cursor: pointer;
}

.mdm-page-btn:hover {
	background: #eff6ff;
	border-color: #bfdbfe;
	color: #1e40af;
	text-decoration: none;
}

.mdm-page-active,
.mdm-page-active:hover {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
	font-weight: 700;
	cursor: default;
}

.mdm-page-gap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	color: #94a3b8;
	font-size: 14px;
}

.mdm-page-prev, .mdm-page-next { font-size: 16px; }

/* ==========================================================================
   Skeleton Loading Cards
   ========================================================================== */

@keyframes mdm-shimmer {
	0%   { background-position: -600px 0; }
	100% { background-position:  600px 0; }
}

.mdm-skeleton-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 300px, 1fr ) );
	gap: 20px;
	margin-top: 4px;
}

.mdm-skeleton-card {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 22px;
	overflow: hidden;
}

.mdm-skeleton-line {
	height: 13px;
	border-radius: 6px;
	background: linear-gradient( 90deg, #f0f0f0 25%, #e4e4e4 50%, #f0f0f0 75% );
	background-size: 600px 100%;
	animation: mdm-shimmer 1.4s ease-in-out infinite;
	margin-bottom: 10px;
}

.mdm-skeleton-line-title  { width: 60%; height: 16px; margin-bottom: 8px; }
.mdm-skeleton-line-sub    { width: 40%; height: 11px; margin-bottom: 14px; }
.mdm-skeleton-badge-row   { display: flex; gap: 8px; margin-bottom: 14px; }
.mdm-skeleton-badge       { width: 60px; height: 20px; border-radius: 20px; background: linear-gradient( 90deg, #f0f0f0 25%, #e4e4e4 50%, #f0f0f0 75% ); background-size: 600px 100%; animation: mdm-shimmer 1.4s ease-in-out infinite; }
.mdm-skeleton-footer      { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid #f1f5f9; }
.mdm-skeleton-company     { width: 80px; }
.mdm-skeleton-btn         { width: 90px; height: 30px; border-radius: 6px; }

/* Stagger animation delay for a wave effect */
.mdm-skeleton-card:nth-child(2) .mdm-skeleton-line { animation-delay: 0.1s; }
.mdm-skeleton-card:nth-child(3) .mdm-skeleton-line { animation-delay: 0.2s; }
.mdm-skeleton-card:nth-child(4) .mdm-skeleton-line { animation-delay: 0.3s; }
.mdm-skeleton-card:nth-child(5) .mdm-skeleton-line { animation-delay: 0.4s; }
.mdm-skeleton-card:nth-child(6) .mdm-skeleton-line { animation-delay: 0.5s; }

/* Hide real content while skeleton is showing */
.mdm-filter-results.mdm-skeleton-active > *:not( .mdm-skeleton-grid ) {
	visibility: hidden;
	height: 0;
	overflow: hidden;
	margin: 0;
	padding: 0;
}

/* ==========================================================================
   Responsive — Mobile
   ========================================================================== */
@media ( max-width: 768px ) {
	/* Switch to single column */
	.mdm-filter-layout {
		grid-template-columns: 1fr;
	}

	/* Show mobile toggle button */
	.mdm-filter-toggle {
		display: inline-flex;
	}

	/* Sidebar becomes a fixed slide-in panel */
	.mdm-filter-sidebar {
		position: fixed;
		top: 0;
		left: -320px;
		width: 300px;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		z-index: 9999;
		box-shadow: 4px 0 24px rgba( 0, 0, 0, 0.15 );
		transition: left 0.28s ease;
	}

	.mdm-filter-sidebar.mdm-sidebar-open {
		left: 0;
	}

	.mdm-sidebar-close { display: block; }

	/* Loading overlay full-screen on mobile */
	.mdm-filter-loading-overlay {
		position: fixed;
		border-radius: 0;
	}

	/* Compact pills on mobile */
	.mdm-filter-pill {
		font-size: 11px;
		padding: 3px 10px;
	}

	/* Compact pagination */
	.mdm-page-btn {
		min-width: 34px;
		height: 34px;
		font-size: 13px;
	}
}

@media ( max-width: 480px ) {
	.mdm-filter-topbar { flex-direction: column; align-items: flex-start; }
	.mdm-filter-toggle { width: 100%; justify-content: center; }
}
