/**
 * WooCommerce Brands Directory — Frontend styles
 * Mobile: alphabetical 3-column list
 * Desktop: multi-column grid + alphabet + load more
 */

.wcbd-directory {
	--wcbd-text: #212121;
	--wcbd-muted: #757575;
	--wcbd-border: #e0e0e0;
	--wcbd-line: #eeeeee;
	--wcbd-bg: #ffffff;
	--wcbd-search-bg: #f5f5f5;
	--wcbd-accent: #00a049;
	--wcbd-accent-hover: #008c3f;
	--wcbd-radius: 10px;
	--wcbd-font: "IRANSans", "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;

	box-sizing: border-box;
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
	padding: 8px 12px 32px;
	font-family: var(--wcbd-font);
	color: var(--wcbd-text);
	background: var(--wcbd-bg);
	direction: rtl;
}

.wcbd-directory *,
.wcbd-directory *::before,
.wcbd-directory *::after {
	box-sizing: border-box;
}

/* ---------- Search ---------- */
.wcbd-search-wrap {
	margin-bottom: 16px;
}

.wcbd-search {
	position: relative;
	display: flex;
	align-items: center;
}

.wcbd-search-input {
	width: 100%;
	height: 48px;
	padding: 0 48px 0 16px;
	border: 1px solid var(--wcbd-border);
	border-radius: 24px;
	background: var(--wcbd-search-bg);
	font-family: inherit;
	font-size: 14px;
	color: var(--wcbd-text);
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.wcbd-search-input::placeholder {
	color: #9e9e9e;
}

.wcbd-search-input:focus {
	background: #fff;
	border-color: #bdbdbd;
	box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.wcbd-search-icon {
	position: absolute;
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	color: #9e9e9e;
	pointer-events: none;
}

/* ---------- Alphabet filter (desktop primarily) ---------- */
.wcbd-alphabet {
	margin-bottom: 20px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.wcbd-alphabet-list {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 2px;
	list-style: none;
	margin: 0;
	padding: 0;
	justify-content: flex-start;
}

.wcbd-alphabet-btn {
	min-width: 28px;
	height: 28px;
	padding: 0 6px;
	border: none;
	background: transparent;
	color: var(--wcbd-muted);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	border-radius: 4px;
	transition: color 0.15s ease, background 0.15s ease;
}

.wcbd-alphabet-btn:hover,
.wcbd-alphabet-btn.is-active {
	color: var(--wcbd-accent);
	background: rgba(0, 160, 73, 0.08);
}

/* ---------- Desktop grid ---------- */
.wcbd-grid-view {
	display: none;
}

.wcbd-grid {
	display: grid;
	grid-template-columns: repeat(var(--wcbd-columns, 4), minmax(0, 1fr));
	gap: 8px 24px;
}

.wcbd-grid-item {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 12px;
	padding: 10px 4px;
	text-decoration: none;
	color: inherit;
	border-radius: 6px;
	transition: background 0.15s ease;
	min-height: 52px;
}

.wcbd-grid-item:hover {
	background: #fafafa;
}

.wcbd-grid-item.is-collapsed,
.wcbd-grid-item.is-filtered-out,
.wcbd-brand-row.is-filtered-out,
.wcbd-group.is-filtered-out {
	display: none !important;
}

.wcbd-grid-logo {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.wcbd-grid-logo img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.wcbd-grid-name {
	flex: 1;
	font-size: 13px;
	line-height: 1.4;
	color: var(--wcbd-text);
	text-align: right;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wcbd-logo-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: #f0f0f0;
	color: var(--wcbd-muted);
	font-size: 16px;
	font-weight: 600;
	border-radius: 4px;
}

/* Load more */
.wcbd-load-more {
	display: block;
	width: 100%;
	margin-top: 28px;
	padding: 14px 20px;
	border: none;
	border-radius: 8px;
	background: var(--wcbd-accent);
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.15s ease;
}

.wcbd-load-more:hover {
	background: var(--wcbd-accent-hover);
}

.wcbd-load-more:active {
	transform: scale(0.995);
}

.wcbd-load-more.is-hidden {
	display: none;
}

/* ---------- Mobile list ---------- */
.wcbd-list-view {
	display: block;
}

.wcbd-group {
	margin-bottom: 4px;
}

.wcbd-group-header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 20px 0 8px;
	height: 28px;
}

.wcbd-group-header::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 1px;
	background: var(--wcbd-line);
}

.wcbd-group-letter {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	height: 28px;
	padding: 0 8px;
	background: #fff;
	border: 1px solid var(--wcbd-border);
	border-radius: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--wcbd-text);
	line-height: 1;
}

.wcbd-brand-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wcbd-brand-link {
	/* RTL: first col = right → Logo | Persian | English */
	display: grid;
	grid-template-columns: auto 1fr 1fr;
	align-items: center;
	gap: 12px;
	padding: 14px 4px;
	text-decoration: none;
	color: inherit;
	min-height: 56px;
	transition: background 0.15s ease;
}

.wcbd-brand-link:hover {
	background: #fafafa;
}

.wcbd-col-english {
	font-size: 14px;
	font-weight: 500;
	color: var(--wcbd-text);
	text-align: left;
	direction: ltr;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wcbd-col-persian {
	font-size: 14px;
	color: var(--wcbd-text);
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wcbd-col-logo {
	width: 64px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wcbd-col-logo img {
	max-width: 64px;
	max-height: 40px;
	width: auto;
	height: auto;
	object-fit: contain;
}

.wcbd-col-logo .wcbd-logo-placeholder {
	width: 40px;
	height: 40px;
	font-size: 14px;
}

.wcbd-no-results {
	padding: 40px 16px;
	text-align: center;
	color: var(--wcbd-muted);
	font-size: 14px;
}

.wcbd-empty {
	padding: 24px;
	text-align: center;
	color: var(--wcbd-muted);
}

/* Hide alphabet on mobile list mode (letters are in group headers) */
@media (max-width: 767px) {
	.wcbd-alphabet {
		display: none;
	}

	.wcbd-search-input {
		height: 44px;
		font-size: 13px;
	}
}

/* ---------- Desktop / tablet ---------- */
@media (min-width: 768px) {
	.wcbd-directory {
		padding: 16px 20px 48px;
	}

	.wcbd-list-view {
		display: none;
	}

	.wcbd-grid-view {
		display: block;
	}

	.wcbd-search-wrap {
		/*max-width: 420px;*/
		margin-right: 0;
		margin-left: auto;
		margin-bottom: 12px;
	}

	.wcbd-search-input {
		border-radius: 8px;
		background: #fff;
		height: 42px;
	}

	.wcbd-alphabet {
		margin-bottom: 24px;
		padding-bottom: 4px;
		border-bottom: 1px solid var(--wcbd-line);
	}

	.wcbd-alphabet-list {
		flex-wrap: wrap;
		gap: 2px;
	}
}

@media (min-width: 768px) and (max-width: 1023px) {
	.wcbd-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 6px 16px;
	}
}

@media (min-width: 1024px) {
	.wcbd-grid {
		grid-template-columns: repeat(var(--wcbd-columns, 4), minmax(0, 1fr));
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.wcbd-directory * {
		transition: none !important;
	}
}
