/* ==========================================================================
   Advanced Filter Share — Frontend Styles (v2.2.0)
   ========================================================================== */

/* --- CSS Variables --- */
:root {
	--afs-primary: #001630;
	--afs-primary-hover: #002855;
	--afs-bg: #0f172a;
	--afs-card-bg: rgba(255, 255, 255, 0.03);
	--afs-text-main: #0f172a;
	--afs-text-muted: rgba(255, 255, 255, 0.6);
	--afs-border: rgba(255, 255, 255, 0.1);
	--afs-border-hover: rgba(255, 255, 255, 0.2);
	--afs-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.2);
	--afs-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
	--afs-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
	--afs-radius: 8px;
	--afs-radius-lg: 24px;
	--afs-gap: 24px;
	--afs-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	--afs-sidebar-width: 320px;
}

/* --- Container & Reset --- */
.afs-wrap {
	/* Important: direction set by HTML attribute, but we reinforce it */
	direction: rtl;
	text-align: right;
	color: var(--afs-text-main);
	width: 100%;
	max-width: 100%;
	margin: 2rem auto;
	box-sizing: border-box;
}

.afs-wrap *,
.afs-wrap *::before,
.afs-wrap *::after {
	box-sizing: border-box;
}

.afs-error {
	color: #ef4444;
	background: #fef2f2;
	border: 1px solid #fecaca;
	padding: 1rem;
	border-radius: var(--afs-radius);
	font-weight: 500;
}

.afs-secure-notice {
	background-color: #ecfdf5;
	color: #065f46;
	border: 1px solid #6ee7b7;
	padding: 1rem;
	border-radius: var(--afs-radius);
	margin-bottom: var(--afs-gap);
	font-weight: 500;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.afs-share-msg {
	margin: 1rem 0;
	padding: 0.75rem 1rem;
	border-radius: var(--afs-radius);
	font-size: 0.875rem;
	font-weight: 500;
	display: none;
	/* align-items: center; */
	gap: 0.5rem;
}

/* --- Select Panel Header --- */
.afs-select-panel-header {
	margin-bottom: 2rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--afs-border);
}

.afs-select-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: white;
	margin: 0 0 0.5rem 0;
}

.afs-select-hint {
	font-size: 0.9375rem;
	color: var(--afs-text-muted);
	margin: 0;
}

/* --- Two-Column Layout --- */
.afs-layout {
	display: flex;
	gap: 2rem;
	align-items: flex-start;
}

/* Sidebar (Right side in RTL) */
.afs-sidebar {
	flex: 0 0 var(--afs-sidebar-width);
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius-lg);
	padding: 1.5rem;
	box-shadow: var(--afs-shadow-sm);
	position: sticky;
	top: 2rem;
	backdrop-filter: blur(10px);
}

/* Main Content Area (Left side in RTL) */
.afs-main {
	flex: 1;
	min-width: 0;
	/* Prevent flex overflow */
}

/* Mobile Filter Toggle (hidden on desktop) */
.afs-mobile-toggle {
	display: none;
	width: 100%;
	padding: 0.75rem;
	background: var(--afs-card-bg);
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
	font-weight: 600;
	color: var(--afs-text-main);
	margin-bottom: 1rem;
	cursor: pointer;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
}

.afs-sidebar-close {
	display: none;
	background: none;
	border: none;
	font-size: 1.5rem;
	color: var(--afs-text-muted);
	cursor: pointer;
	padding: 0.5rem;
	margin-bottom: 1rem;
	align-self: flex-end;
}

@media (max-width: 768px) {
	.afs-mobile-toggle {
		display: flex;
	}

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

	.afs-layout {
		flex-direction: column;
	}

	/* Drawer implementation */
	.afs-sidebar {
		position: fixed;
		top: 0;
		right: -100%;
		/* Hidden off-screen in RTL */
		width: 320px;
		max-width: 90vw;
		height: 100vh;
		z-index: 1000;
		box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
		transition: right 0.3s ease-in-out;
		overflow-y: auto;
		border-radius: 0;
		/* flat edges on drawer */
		margin: 0;
		display: flex;
		flex-direction: column;
		/* Add padding to account for safe areas and scrollbar */
		padding: 1.5rem;
		background: var(--afs-bg);
	}

	.afs-sidebar.afs-sidebar--open {
		right: 0;
	}

	/* Add a backdrop overlay when drawer is open */
	.afs-sidebar-backdrop {
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 999;
		display: none;
	}

	.afs-sidebar-backdrop.afs-sidebar--open {
		display: block;
	}
}

/* --- Filter Sidebar Controls --- */
.afs-filterbar .afs-fb-group {
	margin-bottom: 1.25rem;
}

.afs-filterbar .afs-fb-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: white;
	margin-bottom: 0.5rem;
}

.afs-multi-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.75rem;
	background: #fbbf24;
	color: #78350f;
	padding: 0.125rem 0.375rem;
	border-radius: 4px;
	font-weight: 600;
	margin-right: 0.25rem;
}

.afs-search,
.afs-filter {
	width: 100%;
	padding: 0.625rem 0.875rem;
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
	font-size: 0.9375rem;
	color: var(--afs-text-main);
	background: #fff;
	transition: border-color var(--afs-transition), box-shadow var(--afs-transition);
	appearance: none;
}

.afs-filter--taxonomy,
.afs-filter--sort {
	background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%208l5%205%205-5%22%20fill%3D%22none%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
	background-repeat: no-repeat;
	background-position: left 0.75rem center;
	/* Left arrow in RTL */
	background-size: 1rem;
	padding-left: 2.25rem;
	/* Room for arrow */
}

/* Multi-select dropdowns */
.afs-filter--multi {
	min-height: 44px;
	padding: 0.375rem 0.625rem;
	background-image: none !important;
	padding-left: 0.875rem;
}

.afs-filter--multi option {
	padding: 0.375rem 0.5rem;
	border-radius: 4px;
	margin: 2px 0;
}

.afs-filter--multi option:checked {
	background: var(--afs-primary) !important;
	color: white !important;
	font-weight: 600;
}

/* Custom styling for better multi-select UX */
.afs-filter--multi:focus {
	min-height: 120px;
	transition: min-height 0.2s ease;
}

.afs-search:focus,
.afs-filter:focus {
	outline: none;
	border-color: var(--afs-primary);
	box-shadow: 0 0 0 3px rgba(0, 22, 48, 0.2);
}

.afs-search::placeholder,
.afs-filter::placeholder {
	color: #94a3b8;
}

/* Filter Actions (Buttons inside Sidebar) */
.afs-fb-actions {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin-top: 1.5rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--afs-border);
}

/* --- Buttons --- */
.afs-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.625rem 1.25rem;
	font-size: 0.9375rem;
	font-weight: 600;
	border: none;
	border-radius: var(--afs-radius);
	cursor: pointer;
	transition: all var(--afs-transition);
	background: var(--afs-card-bg);
	color: white;
	box-shadow: var(--afs-shadow-sm), inset 0 0 0 1px var(--afs-border);
	min-height: 44px;
	/* Touch target */
}

.afs-btn:hover {
	background: var(--afs-bg);
	box-shadow: var(--afs-shadow-sm), inset 0 0 0 1px var(--afs-border-hover);
}

.afs-btn:focus-visible,
.afs-pagination-btn:focus-visible {
	outline: 2px solid var(--afs-primary);
	outline-offset: 2px;
}

.afs-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.afs-btn--secure,
.afs-btn--select-all {
	background: var(--afs-primary);
	color: #fff;
	box-shadow: var(--afs-shadow-sm);
}

.afs-btn--secure:hover,
.afs-btn--select-all:hover {
	background: var(--afs-primary-hover);
	box-shadow: var(--afs-shadow-md);
}

.afs-btn--reset {
	color: #dc2626;
}

.afs-btn--reset:hover {
	background: #fef2f2;
}

.afs-icon {
	flex-shrink: 0;
}

/* --- Active Filter Chips --- */
.afs-active-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 1.5rem;
}

.afs-active-filters:empty {
	display: none;
}

.afs-chip {
	display: inline-flex;
	align-items: center;
	background: #e6ebf0;
	/* Soft dark-blue-tinted gray */
	color: #001630;
	padding: 0.25rem 0.75rem;
	border-radius: 9999px;
	font-size: 0.8125rem;
	font-weight: 500;
	gap: 0.5rem;
	border: 1px solid #cbd5e1;
}

.afs-chip__remove {
	background: transparent;
	border: none;
	color: #001630;
	cursor: pointer;
	padding: 2px;
	display: inline-flex;
	align-items: center;
	border-radius: 50%;
	transition: background 0.15s, color 0.15s;
}

.afs-chip__remove:hover {
	background: #cbd5e1;
	color: #000;
}

.afs-chip__remove:focus-visible {
	outline: 2px solid #001630;
	outline-offset: 1px;
}

/* --- Status & Loading --- */
.afs-status {
	min-height: 1.5rem;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	color: var(--afs-text-muted);
}

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

.afs-no-results {
	padding: 2rem;
	background: var(--afs-card-bg);
	border: 1px dashed var(--afs-border);
	border-radius: var(--afs-radius-lg);
	text-align: center;
	color: var(--afs-text-muted);
	font-size: 1.125rem;
	width: 100%;
}

/* --- Results Grid (Flex) --- */
.afs-results {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	width: 100%;
	direction: rtl;
}

/* Card Flex Basis calculations for responsiveness */
.afs-card,
.afs-skeleton {
	flex: 0 0 calc(50% - 16px);
	/* Default 3 columns */
	display: flex;
	flex-direction: column;
}

@media (max-width: 1200px) {
	.afs-card,
	.afs-skeleton {
		flex: 0 0 calc(50% - 12px);
		/* 2 columns on smaller desktop */
	}
}

@media (max-width: 768px) {
	.afs-card,
	.afs-skeleton {
		flex: 0 0 calc(50% - 12px);
		/* 2 columns on tablet */
	}
}

@media (max-width: 480px) {
	.afs-card,
	.afs-skeleton {
		flex: 0 0 100%;
		/* 1 column on mobile */
	}
}

/* --- Post Card (Modern Design) --- */
.afs-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	padding: 18px;
	border-radius: 24px;
	background: rgba(255, 255, 255, 0.03);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	overflow: visible;
}

.afs-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
	background: rgba(255, 255, 255, 0.05);
}

/* Selection State */
.afs-card--selectable {
	cursor: pointer;
}

.afs-card--selectable::after {
	content: '';
	position: absolute;
	inset: 0;
	border: 2px solid transparent;
	border-radius: 24px;
	pointer-events: none;
	transition: border-color 0.2s;
}

.afs-card--selected::after {
	border-color: var(--afs-primary);
}

/* Card Link Wrapper */
.afs-card__link {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	flex: 1;
}

/* Checkbox Select Overlay */
.afs-card__select-label {
	position: absolute;
	top: 1.5rem;
	right: 1.5rem; /* RTL: right corner */
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	margin: 0;
}

.afs-card__checkbox {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.afs-card__check-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	background: rgba(255, 255, 255, 0.95);
	border: 2px solid var(--afs-border);
	border-radius: 6px;
	transition: all 0.2s;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.afs-card__check-icon::after {
	content: '';
	width: 10px;
	height: 10px;
	background: var(--afs-primary);
	border-radius: 2px;
	opacity: 0;
	transform: scale(0.3);
	transition: all 0.2s;
}

.afs-card__checkbox:checked + .afs-card__check-icon {
	background: var(--afs-primary);
	border-color: var(--afs-primary);
}

.afs-card__checkbox:checked + .afs-card__check-icon::after {
	opacity: 1;
	transform: scale(1);
	background: white;
}

.afs-card__select-label:hover .afs-card__check-icon {
	border-color: var(--afs-primary);
	transform: scale(1.08);
}

.afs-card__checkbox:focus-visible + .afs-card__check-icon {
	outline: 2px solid var(--afs-primary);
	outline-offset: 2px;
}

/* Image Container */
.afs-card__img {
	height: 220px;
	border-radius: 18px;
	overflow: hidden;
	position: relative;
	margin-bottom: 14px;
	background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.afs-card__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	background: white;
	transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.afs-card:hover .afs-card__img img {
	transform: scale(1.05);
}

.afs-card__img-placeholder {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Private Badge (inside image) */
.afs-card__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 6px 14px;
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(8px);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	border-radius: 20px;
	z-index: 10;
}

/* Meta Container (Date + Title) */
.afs-card__meta {
	display: flex;
	flex-direction: column;
	gap: 8px;
	text-align: right;
	direction: rtl;
}

.afs-card__date {
	font-size: 0.8125rem;
	color: rgba(255, 255, 255, 0.5);
	font-weight: 400;
}

.afs-card__title {
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.4;
	color: #fff;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* --- Skeleton Loader (Matches New Card Design) --- */
.afs-skeleton {
	padding: 18px;
	border-radius: 24px;
	background: rgba(255, 255, 255, 0.03);
	animation: afsPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes afsPulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

.afs-skeleton__thumb {
	height: 220px;
	border-radius: 18px;
	background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.05) 75%);
	background-size: 200% 100%;
	animation: shimmer 2s infinite;
	margin-bottom: 14px;
}

@keyframes shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

.afs-skeleton__body {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.afs-skeleton__line {
	height: 1rem;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 6px;
}

.afs-skeleton__line--short {
	width: 30%;
	height: 0.875rem;
}

.afs-skeleton__line--med {
	width: 85%;
	height: 1.125rem;
}

/* --- Pagination --- */
.afs-pagination {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-top: 2rem;
	width: 100%;
}

.afs-page-btn {
	padding: 0.5rem 0.875rem;
	background: #fff;
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
	cursor: pointer;
	color: var(--afs-primary);
	font-weight: 500;
	transition: all 0.2s;
	min-width: 40px;
}

.afs-page-btn:hover {
	background: var(--afs-bg);
	border-color: var(--afs-border-hover);
}

.afs-page--current {
	background: var(--afs-primary);
	color: #fff;
	border-color: var(--afs-primary);
	pointer-events: none;
}

/* --- Sticky Share Toolbar (Pill shape, Docked on Mobile) --- */
.afs-share-toolbar {
	position: fixed;
	bottom: 2rem;
	left: 50%;
	transform: translateX(-50%) translateY(150%);
	background: #1e293b;
	color: #fff;
	padding: 0.75rem 1rem;
	border-radius: 9999px;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
	display: flex;
	align-items: center;
	gap: 1rem;
	z-index: 100;
	opacity: 0;
	transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
	pointer-events: none;
	width: max-content;
	max-width: 90vw;
	/* RTL ordering inside flex */
	direction: rtl;
}

.afs-share-toolbar--visible {
	transform: translateX(-50%) translateY(0);
	opacity: 1;
	pointer-events: auto;
}

.afs-share-toolbar__count {
	font-weight: 500;
	font-size: 0.9375rem;
	white-space: nowrap;
}

.afs-share-toolbar__num {
	background: #3b82f6;
	padding: 0.125rem 0.5rem;
	border-radius: 9999px;
	margin-right: 0.25rem;
}

.afs-share-toolbar .afs-btn {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	border: none;
	box-shadow: none;
	min-height: 38px;
}

.afs-share-toolbar .afs-btn:hover {
	background: rgba(255, 255, 255, 0.2);
}

.afs-share-toolbar .afs-btn--secure {
	background: #3b82f6;
}

.afs-share-toolbar .afs-btn--secure:hover {
	background: #2563eb;
}

/* Mobile Toolbar - Full width dock */
@media (max-width: 767px) {
	.afs-share-toolbar {
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-width: 100%;
		transform: translateY(100%);
		border-radius: 16px 16px 0 0;
		flex-direction: column;
		padding: 1rem;
		gap: 0.75rem;
	}

	.afs-share-toolbar--visible {
		transform: translateY(0);
	}

	.afs-share-toolbar .afs-btn {
		width: 100%;
		min-height: 44px;
		/* Touch target */
	}
}
/* ============================================================
   v2.3.0 Additions
   ============================================================ */

/* Include filters toggle in share toolbar */
.afs-include-filters-wrap {
	display: flex;
	align-items: center;
}

.afs-include-filters-label {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.8125rem;
	color: rgba(255, 255, 255, 0.75);
	cursor: pointer;
	white-space: nowrap;
}

.afs-include-filters-toggle {
	width: 14px;
	height: 14px;
	cursor: pointer;
	accent-color: var(--afs-primary);
}