/**
 * Match Me frontend styles.
 *
 * Circle + badge display styles, confidence indicator, lazy loading.
 */

/* ── Base ── */
.matchme-display {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Color classes ── */
.matchme-high .matchme-circle-progress { stroke: var(--matchme-color-high, #10B981); }
.matchme-medium .matchme-circle-progress { stroke: var(--matchme-color-medium, #2563EB); }
.matchme-low .matchme-circle-progress { stroke: var(--matchme-color-low, #EF4444); }

.matchme-high .matchme-badge-pill { background: var(--matchme-color-high, #10B981); }
.matchme-medium .matchme-badge-pill { background: var(--matchme-color-medium, #2563EB); }
.matchme-low .matchme-badge-pill { background: var(--matchme-color-low, #EF4444); }

/* ── Circle progress ── */
.matchme-svg {
	display: block;
	filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.18));
}

.matchme-circle-bg {
	stroke: #94A3B8;
	paint-order: stroke;
	filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.7));
}

.matchme-circle-progress {
	transition: stroke-dashoffset 0.8s ease-in-out;
}

.matchme-circle-text {
	font-size: 14px;
	font-weight: 700;
	fill: #1E293B;
}

/* ── Badge / pill ── */
.matchme-badge-pill {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 9999px;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	white-space: nowrap;
}

/* ── Confidence indicator ── */
.matchme-confidence {
	font-size: 11px;
	color: #64748B;
	font-weight: 500;
}

.matchme-confidence-low {
	color: #94A3B8;
	font-style: italic;
}

/* ── Lazy loading placeholder ── */
.matchme-lazy {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* Hide spinner entirely in directory cards. */
.matchme-lazy .matchme-loading {
	display: none;
}

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

/* ── BuddyBoss/BuddyPress directory: top-left card overlay ── */
#members-dir-list .list-wrap,
.members .list-wrap {
	position: relative;
}

/* Always absolute so it never pushes content down. Hidden until loaded. */
.list-wrap > .matchme-lazy {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 3;
	margin: 0;
	visibility: hidden;
}

.list-wrap > .matchme-lazy.matchme-loaded {
	visibility: visible;
}

.list-wrap > .matchme-lazy .matchme-display {
	gap: 0;
}

.list-wrap > .matchme-lazy .matchme-svg {
	width: 48px;
	height: 48px;
}

.list-wrap > .matchme-lazy .matchme-circle-bg {
	stroke: #CBD5E1;
	stroke-width: 7;
}

.list-wrap > .matchme-lazy .matchme-circle-progress {
	stroke-width: 7;
}

.list-wrap > .matchme-lazy .matchme-circle-text {
	font-size: 12px;
	font-weight: 800;
	fill: #1E293B;
}

.list-wrap > .matchme-lazy .matchme-confidence {
	display: none;
}

/* Badge style in directory overlay. */
.list-wrap > .matchme-lazy .matchme-badge {
	gap: 0;
}

.list-wrap > .matchme-lazy .matchme-badge-pill {
	font-size: 11px;
	padding: 4px 10px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ── Standard BuddyPress directory: top-left card overlay ── */
#members-list > li {
	position: relative;
}

#members-list > li > .matchme-lazy {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 3;
	margin: 0;
	visibility: hidden;
}

#members-list > li > .matchme-lazy.matchme-loaded {
	visibility: visible;
}

#members-list > li > .matchme-lazy .matchme-display {
	gap: 0;
}

#members-list > li > .matchme-lazy .matchme-svg {
	width: 48px;
	height: 48px;
}

#members-list > li > .matchme-lazy .matchme-circle-bg {
	stroke: #CBD5E1;
	stroke-width: 7;
}

#members-list > li > .matchme-lazy .matchme-circle-progress {
	stroke-width: 7;
}

#members-list > li > .matchme-lazy .matchme-circle-text {
	font-size: 12px;
	font-weight: 800;
	fill: #1E293B;
}

#members-list > li > .matchme-lazy .matchme-confidence {
	display: none;
}

#members-list > li > .matchme-lazy .matchme-badge {
	gap: 0;
}

#members-list > li > .matchme-lazy .matchme-badge-pill {
	font-size: 11px;
	padding: 4px 10px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ── Grid view: slightly larger badge ── */
.members-list.grid .list-wrap > .matchme-lazy .matchme-svg {
	width: 52px;
	height: 52px;
}

.members-list.grid .list-wrap > .matchme-lazy .matchme-circle-text {
	font-size: 13px;
}

/* ── Profile page display ── */

/* Position match in top-right of profile header. */
#item-header {
	position: relative;
}

#item-header .matchme-display {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	margin: 0;
	align-items: flex-end;
}

#item-header .matchme-confidence {
	display: none;
}

#item-header .matchme-circle .matchme-svg {
	width: 64px;
	height: 64px;
}

#item-header .matchme-circle .matchme-circle-text {
	font-size: 13px;
}

#item-header .matchme-badge .matchme-badge-pill {
	font-size: 14px;
	padding: 6px 16px;
}

#item-header .matchme-display {
	cursor: pointer;
}

/* ── Top Matches tab ── */
.matchme-top-matches {
	max-width: 600px;
}

.matchme-top-matches-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.matchme-top-matches-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	background: #fff;
	border: 1px solid #E2E8F0;
	border-radius: 10px;
	transition: box-shadow 0.15s ease;
}

.matchme-top-matches-item:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.matchme-top-matches-avatar img {
	border-radius: 50%;
	display: block;
}

.matchme-top-matches-name {
	flex: 1;
	font-weight: 600;
	font-size: 15px;
	color: #1E293B;
	text-decoration: none;
}

.matchme-top-matches-name:hover {
	color: #3B82F6;
}

.matchme-top-matches-badge .matchme-display {
	flex-direction: row;
}

.matchme-top-matches-badge .matchme-confidence {
	display: none;
}

.matchme-top-matches-badge .matchme-svg {
	width: 44px;
	height: 44px;
}

.matchme-top-matches-badge .matchme-circle-text {
	font-size: 11px;
}

.matchme-top-matches-empty {
	color: #64748B;
	font-size: 14px;
	padding: 24px 0;
}

/* ── Breakdown (hover tooltip) ── */
.matchme-breakdown {
	margin-top: 4px;
	padding: 12px 16px;
	background: #fff;
	border: 1px solid #E2E8F0;
	border-radius: 10px;
	min-width: 220px;
	max-width: 280px;
	display: none;
	flex-direction: column;
	gap: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.matchme-display:hover .matchme-breakdown {
	display: flex;
}

.matchme-breakdown-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.matchme-breakdown-label {
	flex: 0 0 80px;
	font-size: 12px;
	font-weight: 500;
	color: #475569;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.matchme-breakdown-track {
	flex: 1;
	height: 6px;
	background: #E2E8F0;
	border-radius: 3px;
	overflow: hidden;
}

.matchme-breakdown-fill {
	height: 100%;
	border-radius: 3px;
	transition: width 0.4s ease;
}

.matchme-breakdown-bar-high { background: var(--matchme-color-high, #10B981); }
.matchme-breakdown-bar-med  { background: var(--matchme-color-medium, #2563EB); }
.matchme-breakdown-bar-low  { background: var(--matchme-color-low, #EF4444); }

.matchme-breakdown-pct {
	flex: 0 0 32px;
	font-size: 11px;
	font-weight: 600;
	color: #1E293B;
	text-align: right;
}

/* Hide breakdown in directory overlays (too small). */
.list-wrap > .matchme-lazy .matchme-breakdown,
#members-list > li > .matchme-lazy .matchme-breakdown {
	display: none;
}

/* ── Responsive ── */

/* Tablet/mobile: keep badge in top-right corner of the profile card */
@media (max-width: 768px) {
	/* Reset all intermediate BuddyBoss containers so they don't trap
	   the absolutely positioned match display. */
	#item-header #cover-image-container,
	#item-header #item-header-cover-image,
	#item-header #item-header-content,
	#item-header #item-header-content > .flex,
	#item-header .bb-user-content-wrap,
	#item-header #bb-rl-profile-container,
	#item-header #bb-rl-profile-item-header,
	#item-header #bb-rl-item-header-content,
	#item-header .item-header-wrap {
		position: static !important;
	}

	#item-header {
		position: relative !important;
	}

	#item-header .matchme-display {
		position: absolute !important;
		top: 12px;
		right: 12px;
		left: auto;
		margin: 0;
		z-index: 10;
	}

	#item-header .matchme-badge .matchme-badge-pill {
		font-size: 11px;
		padding: 3px 10px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	}

	#item-header .matchme-circle .matchme-svg {
		width: 44px;
		height: 44px;
		filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
	}

	#item-header .matchme-circle .matchme-circle-text {
		font-size: 11px;
	}
}

@media (max-width: 480px) {
	.matchme-svg {
		width: 64px;
		height: 64px;
	}

	.matchme-circle-text {
		font-size: 12px;
	}

	.matchme-badge-pill {
		font-size: 12px;
		padding: 3px 10px;
	}

	#item-header .matchme-badge .matchme-badge-pill {
		font-size: 12px;
		padding: 4px 12px;
	}

	#item-header .matchme-circle .matchme-svg {
		width: 48px;
		height: 48px;
	}

	.list-wrap > .matchme-lazy .matchme-svg {
		width: 40px;
		height: 40px;
	}

	.list-wrap > .matchme-lazy .matchme-circle-text {
		font-size: 10px;
	}

	.list-wrap > .matchme-lazy.matchme-loaded {
		top: 6px;
		left: 6px;
	}

	#members-list > li > .matchme-lazy .matchme-svg {
		width: 40px;
		height: 40px;
	}

	#members-list > li > .matchme-lazy .matchme-circle-text {
		font-size: 10px;
	}

	#members-list > li > .matchme-lazy.matchme-loaded {
		top: 6px;
		left: 6px;
	}
}
