/* =============================================
   Shared UI Components — v1.31 design system
   ============================================= */

/* —— Focus visible (accessibility) —— */
.mb-btn:focus-visible,
.mb-link:focus-visible,
.mb-filter-btn:focus-visible,
.mb-nav__link:focus-visible,
.mb-header-v3__link:focus-visible,
.mb-admin-sidebar__link:focus-visible,
.mb-dash-nav__link:focus-visible,
.mb-listing-card__link:focus-visible,
.mb-pagination a:focus-visible,
.mb-checkbox input:focus-visible + span,
.mb-form__group input:focus-visible,
.mb-form__group select:focus-visible,
.mb-form__group textarea:focus-visible,
a.mb-logo:focus-visible {
	outline: var(--mb-focus-ring);
	outline-offset: var(--mb-focus-offset);
}

.mb-btn:focus:not(:focus-visible),
.mb-filter-btn:focus:not(:focus-visible) {
	outline: none;
}

/* —— Extended buttons —— */
.mb-btn--danger {
	background: var(--mb-danger);
	color: #fff;
}
.mb-btn--danger:hover {
	background: var(--mb-danger-dark);
}

.mb-btn--light {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.35);
}
.mb-btn--light:hover {
	background: rgba(255, 255, 255, 0.25);
}

.mb-btn--whatsapp {
	background: #25d366;
	color: #fff;
}
.mb-btn--whatsapp:hover {
	background: #1da851;
}

.mb-btn--block {
	display: flex;
	width: 100%;
}

.mb-btn:disabled,
.mb-btn.is-disabled {
	opacity: 0.55;
	cursor: not-allowed;
	pointer-events: none;
}

.mb-btn.is-loading {
	position: relative;
	color: transparent !important;
	pointer-events: none;
}
.mb-btn.is-loading::after {
	content: '';
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: mb-spin 0.7s linear infinite;
}

@keyframes mb-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.mb-btn.is-loading::after { animation: none; }
}

/* Primary button uses brand glow token */
.mb-btn--primary:hover {
	box-shadow: var(--mb-shadow-brand);
}

/* —— Filter buttons (unified) —— */
.mb-filter-btn {
	padding: var(--mb-space-2) var(--mb-space-4);
	border-radius: var(--mb-radius-full);
	font-size: var(--mb-text-sm);
	font-weight: 600;
	color: var(--mb-text-muted);
	background: var(--mb-surface);
	border: 1px solid var(--mb-border);
	transition: background var(--mb-transition), color var(--mb-transition), border-color var(--mb-transition), box-shadow var(--mb-transition);
}

.mb-filter-btn:hover {
	border-color: var(--mb-brand);
	color: var(--mb-brand);
}

.mb-filter-btn--active {
	background: var(--mb-brand);
	color: var(--mb-text-inverse);
	border-color: var(--mb-brand);
}

/* Homepage segmented filter group */
.mb-listings__filters .mb-filter-btn {
	border-radius: var(--mb-radius-sm);
	border-color: transparent;
	background: transparent;
}

.mb-listings__filters .mb-filter-btn--active {
	background: var(--mb-surface);
	color: var(--mb-brand);
	border-color: transparent;
	box-shadow: var(--mb-shadow-md);
}

/* —— Empty state (single source) —— */
.mb-empty-state {
	text-align: center;
	padding: var(--mb-space-16) var(--mb-space-6);
	background: linear-gradient(180deg, var(--mb-surface-muted) 0%, var(--mb-surface) 100%);
	border: 2px dashed var(--mb-border);
	border-radius: var(--mb-radius-lg);
}

.mb-empty-state--compact {
	padding: var(--mb-space-10) var(--mb-space-5);
}

.mb-empty-state--inline {
	background: transparent;
	border: none;
	padding: var(--mb-space-8) var(--mb-space-4);
}

.mb-empty-state__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 72px;
	margin: 0 auto var(--mb-space-4);
	border-radius: var(--mb-radius-lg);
	background: var(--mb-brand-muted);
	color: var(--mb-brand);
}

.mb-empty-state__icon svg {
	width: 32px;
	height: 32px;
	stroke: currentColor;
	fill: none;
}

.mb-empty-state__title {
	font-family: var(--mb-font-display);
	font-size: var(--mb-text-xl);
	font-weight: 700;
	color: var(--mb-text);
	margin: 0 0 var(--mb-space-2);
}

.mb-empty-state__text {
	margin: 0 0 var(--mb-space-6);
	color: var(--mb-text-muted);
	max-width: 420px;
	margin-left: auto;
	margin-right: auto;
	line-height: var(--mb-leading-relaxed);
	font-size: var(--mb-text-md);
}

.mb-empty-state .mb-btn {
	margin-top: var(--mb-space-2);
}

/* Legacy h3/p inside empty states */
.mb-empty-state h3 {
	font-family: var(--mb-font-display);
	font-size: var(--mb-text-xl);
	font-weight: 700;
	margin: 0 0 var(--mb-space-2);
	color: var(--mb-text);
}

.mb-empty-state p {
	color: var(--mb-text-muted);
	margin-bottom: var(--mb-space-6);
}

/* —— Listing card CTA: visible on touch —— */
@media (hover: none) {
	.mb-listing-card__cta {
		opacity: 1 !important;
		transform: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mb-btn--primary:hover,
	.mb-btn--white:hover,
	.mb-listing-card:hover {
		transform: none !important;
	}
}

/* —— Icon system —— */
.mb-icon {
	display: inline-block;
	vertical-align: middle;
	flex-shrink: 0;
}

.mb-icon--inline {
	width: 1em;
	height: 1em;
}

.mb-empty-state__svg {
	display: block;
}

/* —— Form field system —— */
.mb-field {
	display: flex;
	flex-direction: column;
	gap: var(--mb-space-2);
	margin-bottom: var(--mb-space-4);
}

.mb-field__label {
	font-size: var(--mb-text-sm);
	font-weight: 600;
	color: var(--mb-text);
}

.mb-field__hint {
	font-size: var(--mb-text-xs);
	color: var(--mb-text-muted);
}

.mb-input,
.mb-select,
.mb-textarea {
	width: 100%;
	padding: 12px 14px;
	font-family: var(--mb-font);
	font-size: var(--mb-text-base);
	color: var(--mb-text);
	background: var(--mb-input-bg);
	border: 1px solid var(--mb-input-border);
	border-radius: var(--mb-radius-sm);
	transition: border-color var(--mb-transition), box-shadow var(--mb-transition);
}

.mb-input:focus,
.mb-select:focus,
.mb-textarea:focus {
	outline: none;
	border-color: var(--mb-brand);
	box-shadow: 0 0 0 3px var(--mb-brand-muted);
}

.mb-field--error .mb-input,
.mb-field--error .mb-select,
.mb-field--error .mb-textarea {
	border-color: var(--mb-input-error);
}

.mb-field--error .mb-field__hint {
	color: var(--mb-input-error);
}

.mb-field--success .mb-input {
	border-color: var(--mb-input-success);
}

/* —— Badge system —— */
.mb-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 10px;
	font-size: var(--mb-text-xs);
	font-weight: 700;
	line-height: 1.4;
	border-radius: var(--mb-radius-full);
	white-space: nowrap;
}

.mb-badge--brand {
	background: var(--mb-brand-muted);
	color: var(--mb-brand-dark);
}

.mb-badge--new {
	background: var(--mb-info-muted);
	color: #0369a1;
}

.mb-badge--urgent {
	background: var(--mb-danger-muted);
	color: var(--mb-danger-dark);
}

.mb-badge--featured {
	background: var(--mb-warning-muted);
	color: #b45309;
}

.mb-badge--success {
	background: var(--mb-success-muted);
	color: #047857;
}

.mb-badge--muted {
	background: var(--mb-surface-muted);
	color: var(--mb-text-muted);
	border: 1px solid var(--mb-border);
}

/* —— Toast notifications —— */
.mb-toast-stack {
	position: fixed;
	right: var(--mb-space-4);
	bottom: var(--mb-space-4);
	z-index: var(--mb-z-toast);
	display: flex;
	flex-direction: column;
	gap: var(--mb-space-2);
	max-width: min(360px, calc(100vw - 32px));
	pointer-events: none;
}

.mb-toast {
	padding: 14px 18px;
	font-size: var(--mb-text-sm);
	font-weight: 600;
	color: var(--mb-text-inverse);
	background: var(--mb-surface-inverse);
	border-radius: var(--mb-radius-md);
	box-shadow: var(--mb-shadow-lg);
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.28s var(--mb-ease-out), transform 0.28s var(--mb-ease-out);
}

.mb-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.mb-toast--success { background: #065f46; }
.mb-toast--error { background: var(--mb-danger-dark); }
.mb-toast--warning { background: #b45309; }
.mb-toast--info { background: #0369a1; }

/* —— Pagination —— */
.mb-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--mb-space-2);
	margin-top: var(--mb-space-8);
}

.mb-pagination a,
.mb-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	font-size: var(--mb-text-sm);
	font-weight: 600;
	color: var(--mb-text-muted);
	text-decoration: none;
	background: var(--mb-surface);
	border: 1px solid var(--mb-border);
	border-radius: var(--mb-radius-sm);
	transition: background var(--mb-transition), color var(--mb-transition), border-color var(--mb-transition);
}

.mb-pagination a:hover {
	border-color: var(--mb-brand);
	color: var(--mb-brand);
}

.mb-pagination .current {
	background: var(--mb-brand);
	border-color: var(--mb-brand);
	color: var(--mb-text-inverse);
}

/* —— Section header —— */
.mb-section-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--mb-space-4);
	flex-wrap: wrap;
	margin-bottom: var(--mb-space-6);
}

.mb-section-head__title {
	font-family: var(--mb-font-display);
	font-size: var(--mb-text-2xl);
	font-weight: 800;
	color: var(--mb-text);
	margin: 0 0 var(--mb-space-1);
}

.mb-section-head__sub {
	margin: 0;
	font-size: var(--mb-text-sm);
	color: var(--mb-text-muted);
}

.mb-section-head__actions {
	display: flex;
	gap: var(--mb-space-2);
	flex-shrink: 0;
}

/* —— Loading shimmer —— */
.mb-shimmer {
	background: linear-gradient(90deg, var(--mb-border) 25%, #f1f5f9 50%, var(--mb-border) 75%);
	background-size: 200% 100%;
	animation: mb-shimmer 1.2s ease-in-out infinite;
	border-radius: var(--mb-radius-sm);
}

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

@media (prefers-reduced-motion: reduce) {
	.mb-shimmer { animation: none; background: var(--mb-border); }
	.mb-toast { transition: none; }
}
