/*
 * RateTheTool — Free Alternative Finder
 * Uses RateTheTool's existing brand tokens — no new palette introduced.
 * Primary:  #2563EB   Secondary: #0F172A   Text: #64748B
 */

.rtt-faf {
	--rtt-blue: #2563EB;
	--rtt-blue-dark: #1d4ed8;
	--rtt-ink: #0F172A;
	--rtt-slate: #64748B;
	--rtt-border: #E2E8F0;
	--rtt-bg: #F8FAFC;
	--rtt-green: #15803D;
	--rtt-amber: #B45309;

	box-sizing: border-box;
	max-width: 560px;
	margin: 2rem auto;
	padding: 1.5rem;
	background: #FFFFFF;
	border: 1px solid var(--rtt-border);
	border-radius: 12px;
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--rtt-ink);
}

.rtt-faf *,
.rtt-faf *::before,
.rtt-faf *::after {
	box-sizing: inherit;
}

.rtt-faf__label {
	display: block;
	font-size: 0.95rem;
	font-weight: 600;
	margin-bottom: 0.5rem;
	color: var(--rtt-ink);
}

.rtt-faf__search {
	position: relative;
}

.rtt-faf__input {
	width: 100%;
	padding: 0.75rem 1rem;
	font-size: 1rem;
	line-height: 1.4;
	color: var(--rtt-ink);
	background: var(--rtt-bg);
	border: 1.5px solid var(--rtt-border);
	border-radius: 8px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rtt-faf__input:focus {
	outline: none;
	border-color: var(--rtt-blue);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
	background: #FFFFFF;
}

.rtt-faf .rtt-faf__suggestions {
	position: absolute !important;
	top: calc(100% + 4px) !important;
	left: 0 !important;
	right: 0 !important;
	z-index: 20 !important;
	margin: 0 !important;
	padding: 0.25rem !important;
	list-style: none !important;
	background: #FFFFFF !important;
	border: 1px solid var(--rtt-border) !important;
	border-radius: 8px !important;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1) !important;
	max-height: 260px !important;
	overflow-y: auto !important;
}

.rtt-faf .rtt-faf__suggestion {
	display: flex !important;
	align-items: center !important;
	width: 100% !important;
	gap: 0.5rem !important;
	padding: 0.6rem 0.75rem !important;
	border-radius: 6px !important;
	cursor: pointer !important;
	list-style: none !important;
}

.rtt-faf .rtt-faf__suggestion:hover,
.rtt-faf .rtt-faf__suggestion.is-active {
	background: var(--rtt-bg) !important;
}

/*
 * The name and the category tag must never visually touch, even if the
 * flex layout above gets overridden by theme/plugin CSS somewhere. So the
 * separation comes from real margin on the tag (works in any display
 * mode), not just flex `gap` (which only works if flex is winning).
 * min-width: 0 + ellipsis lets a long tool name truncate instead of
 * pushing the tag off-screen or wrapping it to a new line.
 */
.rtt-faf .rtt-faf__suggestion-name {
	font-size: 0.95rem !important;
	font-weight: 500 !important;
	color: var(--rtt-ink) !important;
	text-align: left !important;
	flex: 1 1 auto !important;
	min-width: 0 !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	white-space: nowrap !important;
	margin: 0 0.6rem 0 0 !important;
}

.rtt-faf .rtt-faf__suggestion-category {
	font-size: 0.72rem !important;
	font-weight: 600 !important;
	color: var(--rtt-blue) !important;
	white-space: nowrap !important;
	background: #EFF6FF !important;
	border: 1px solid #DBEAFE !important;
	padding: 0.22rem 0.6rem !important;
	border-radius: 999px !important;
	flex-shrink: 0 !important;
	margin: 0 !important;
	display: inline-block !important;
	line-height: 1.3 !important;
}

.rtt-faf__chips {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.75rem;
}

.rtt-faf__chips-label {
	font-size: 0.82rem;
	color: var(--rtt-slate);
	margin-right: 0.15rem;
}

.rtt-faf__chip {
	font-family: inherit;
	font-size: 0.82rem;
	color: var(--rtt-blue);
	background: #EFF6FF;
	border: 1px solid #DBEAFE;
	border-radius: 999px;
	padding: 0.3rem 0.7rem;
	cursor: pointer;
	transition: background 0.15s ease;
}

.rtt-faf__chip:hover,
.rtt-faf__chip:focus-visible {
	background: #DBEAFE;
}

.rtt-faf__chip:focus-visible,
.rtt-faf__input:focus-visible {
	outline: 2px solid var(--rtt-blue);
	outline-offset: 2px;
}

.rtt-faf__result {
	margin-top: 1.25rem;
	padding: 1.1rem 1.25rem;
	background: var(--rtt-bg);
	border: 1px solid var(--rtt-border);
	border-left: 4px solid var(--rtt-blue);
	border-radius: 8px;
}

.rtt-faf__result-heading {
	margin: 0 0 0.2rem;
	font-size: 0.78rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--rtt-blue);
}

.rtt-faf__result-name {
	margin: 0 0 0.5rem;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--rtt-ink);
}

.rtt-faf__result-why {
	margin: 0 0 0.6rem;
	font-size: 0.95rem;
	line-height: 1.5;
	color: var(--rtt-ink);
}

.rtt-faf__result-caveat {
	margin: 0 0 0.85rem;
	font-size: 0.88rem;
	line-height: 1.5;
	color: var(--rtt-amber);
}

.rtt-faf__cta {
	display: inline-block;
	font-size: 0.92rem;
	font-weight: 600;
	color: #FFFFFF;
	background: var(--rtt-blue);
	padding: 0.55rem 1rem;
	border-radius: 6px;
	text-decoration: none;
	transition: background 0.15s ease;
}

.rtt-faf__cta:hover,
.rtt-faf__cta:focus-visible {
	background: var(--rtt-blue-dark);
}

.rtt-faf__empty {
	margin-top: 1.25rem;
	padding: 1.1rem 1.25rem;
	background: var(--rtt-bg);
	border: 1px dashed var(--rtt-border);
	border-radius: 8px;
}

.rtt-faf__empty-text {
	margin: 0 0 0.75rem;
	font-size: 0.92rem;
	color: var(--rtt-slate);
}

@media (prefers-reduced-motion: reduce) {
	.rtt-faf__input,
	.rtt-faf__chip,
	.rtt-faf__cta {
		transition: none;
	}
}

@media (max-width: 480px) {
	.rtt-faf {
		margin: 1.25rem 0;
		padding: 1.1rem;
		border-radius: 10px;
	}

	.rtt-faf__result-name {
		font-size: 1.1rem;
	}

	/* Category tag stays pinned to the right on mobile too — the name
	   truncates with an ellipsis instead of wrapping or losing its margin. */
	.rtt-faf .rtt-faf__suggestion-category {
		font-size: 0.68rem !important;
		padding: 0.2rem 0.5rem !important;
	}
}
