/**
 * bbPress Search & Widget Styles
 *
 * Styles for bbPress search form, search results page, and sidebar widgets.
 *
 * @package AgenticWP
 */

/* ==========================================================================
   SEARCH FORM
   Styles for bbPress search form matching blog search pattern.
   ========================================================================== */

/* Search Form Container */
.bbp-search-form {
	max-width: 480px;
	margin: 0 auto 32px;
}

/* Search Input Wrapper
   Matches blog .search-input-wrapper pattern */
.bbp-search-form #bbp-search-form {
	position: relative;
	display: flex;
	align-items: center;
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: visible;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Inner div wrapper - needs flex and position relative for search icon */
.bbp-search-form #bbp-search-form > div {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	border: none;
	outline: none;
	box-shadow: none;
}

.bbp-search-form #bbp-search-form:focus-within {
	border-color: var(--line) !important;
	box-shadow: none !important;
	outline: none !important;
}

/* Search Icon
   Positioned absolutely within wrapper */
.bbp-search-form .bbp-search-icon {
	position: absolute;
	left: 16px;
	width: 20px;
	height: 20px;
	color: var(--muted);
	pointer-events: none;
	z-index: 1;
}

/* Search Input Field */
.bbp-search-form #bbp_search {
	flex: 1;
	padding: 14px 16px 14px 48px;
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: 16px;
	color: var(--ink);
	outline: none;
	box-shadow: none;
}

.bbp-search-form #bbp_search:focus {
	outline: none !important;
	box-shadow: none !important;
}

.bbp-search-form #bbp_search::placeholder {
	color: var(--muted);
}

/* Search Submit Button */
.bbp-search-form #bbp_search_submit {
	padding: 14px 24px;
	background: var(--accent);
	color: var(--bg);
	border: none;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.bbp-search-form #bbp_search_submit:hover {
	background: #0a1a4d;
}

.bbp-search-form #bbp_search_submit:focus {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ==========================================================================
   SEARCH RESULTS
   Styles for bbPress search results page.
   ========================================================================== */

/* Search Results Container */
.bbp-search-results {
	padding: 40px 0 80px;
}

/* Search Results Header */
.bbp-search-results-header {
	text-align: center;
	margin-bottom: 40px;
}

.bbp-search-results-header h1 {
	font-size: clamp(28px, 5vw, 36px);
	font-weight: 700;
	color: var(--ink);
	margin: 0 0 12px;
	letter-spacing: -0.02em;
}

.bbp-search-results-header .search-query {
	color: var(--accent);
}

.bbp-search-results-count {
	font-size: 15px;
	color: var(--muted);
	margin: 0;
}

/* Search Results List - reuses topic list styling */
.bbp-search-results ul.bbp-topics,
.bbp-search-results ul.bbp-forums,
.bbp-search-results ul.bbp-replies {
	padding: 0;
}

/* Hide redundant header/footer rows in search results
   These show "Author" and "Search Results" labels that aren't needed */
#bbpress-forums .bbp-search-results .bbp-header,
#bbpress-forums .bbp-search-results .bbp-footer,
.bbp-search-results li.bbp-header,
.bbp-search-results li.bbp-footer {
	display: none;
}

/* Hide IP addresses from public view in search results
   Should only be visible in admin context */
.bbp-search-results .bbp-author-ip,
.bbp-search-results .bbp-reply-ip {
	display: none;
}

/* Search Result List Container */
#bbpress-forums ul.bbp-search-results,
ul.bbp-search-results {
	list-style: none;
	padding: 0;
	margin: 40px 0;
}

/* Body container holds all results */
.bbp-search-results li.bbp-body {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

/* Each result is a header + author + content group
   We use CSS to visually group them as cards */
.bbp-search-results .bbp-topic-header,
.bbp-search-results .bbp-forum-header,
.bbp-search-results .bbp-reply-header {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 24px;
	padding-bottom: 0;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Include author and content in the same card visually */
.bbp-search-results .bbp-topic-author,
.bbp-search-results .bbp-reply-author {
	background: var(--bg);
	border: 1px solid var(--line);
	border-top: none;
	border-radius: 0;
	padding: 16px 24px;
	margin-top: -1px;
}

.bbp-search-results .bbp-topic-content,
.bbp-search-results .bbp-reply-content {
	border: 1px solid var(--line);
	border-top: none;
	border-radius: 0 0 12px 12px;
	padding: 16px 24px 24px;
	margin-top: -1px;
	margin-bottom: 0;
}

/* Forum results don't have author section - header contains everything */
.bbp-search-results .bbp-forum-header {
	padding-bottom: 24px;
	border-radius: 12px;
}

/* Forum content appears after header, style it as continuation of card */
.bbp-search-results .bbp-forum-content {
	border: 1px solid var(--line);
	border-top: none;
	border-left: 3px solid #94a3b8;
	border-radius: 0 0 12px 12px;
	padding: 16px 24px 24px;
	margin-top: -13px;
	background: var(--bg);
}

/* Hover effect on header triggers card highlight */
.bbp-search-results .bbp-topic-header:hover,
.bbp-search-results .bbp-forum-header:hover,
.bbp-search-results .bbp-reply-header:hover {
	border-color: var(--accent);
}

/* Left border accent for result type */
.bbp-search-results .bbp-topic-header {
	border-left: 3px solid var(--accent);
}

.bbp-search-results .bbp-forum-header {
	border-left: 3px solid #94a3b8;
}

/* Search Result Card Layout */
.bbp-search-results .bbp-forum-header,
.bbp-search-results .bbp-topic-header,
.bbp-search-results .bbp-reply-header {
	margin-bottom: 16px;
}

/* Search Result Meta (date, permalink) */
.bbp-search-results .bbp-forum-header > div:first-child,
.bbp-search-results .bbp-topic-header > div:first-child,
.bbp-search-results .bbp-reply-header > div:first-child {
	font-size: 13px;
	color: var(--muted);
	margin-bottom: 8px;
}

.bbp-search-results .bbp-forum-header a,
.bbp-search-results .bbp-topic-header a,
.bbp-search-results .bbp-reply-header a {
	color: var(--muted);
	text-decoration: none;
}

.bbp-search-results .bbp-forum-header a:hover,
.bbp-search-results .bbp-topic-header a:hover,
.bbp-search-results .bbp-reply-header a:hover {
	color: var(--accent);
}

/* Search Result Title */
.bbp-search-results h3 {
	font-size: 18px;
	font-weight: 600;
	color: var(--ink);
	margin: 0 0 6px;
	line-height: 1.4;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/* Result type prefix (Topic:, Forum:) as subtle badge */
.bbp-search-results h3::first-letter {
	text-transform: uppercase;
}

.bbp-search-results h3 a {
	color: var(--ink);
	text-decoration: none;
}

.bbp-search-results h3 a:hover {
	color: var(--accent);
}

/* Style the "Topic:" and "Forum:" prefix text */
.bbp-search-results .bbp-topic-header h3,
.bbp-search-results .bbp-forum-header h3 {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* "in forum X" text */
.bbp-search-results .bbp-topic-header > div:last-child,
.bbp-search-results .bbp-reply-header > div:last-child {
	font-size: 14px;
	color: var(--muted);
}

.bbp-search-results .bbp-topic-header > div:last-child a,
.bbp-search-results .bbp-reply-header > div:last-child a {
	color: var(--accent);
	text-decoration: none;
}

.bbp-search-results .bbp-topic-header > div:last-child a:hover,
.bbp-search-results .bbp-reply-header > div:last-child a:hover {
	text-decoration: underline;
}

/* Search Result Author Section
   Structure: .bbp-topic-author > a.bbp-author-link(avatar + name) + div.bbp-author-role */
.bbp-search-results .bbp-topic-author,
.bbp-search-results .bbp-reply-author {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 16px;
	padding: 0;
	border: none;
}

/* Author link - contains avatar span + name span */
.bbp-search-results .bbp-author-link {
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
}

/* Avatar container */
.bbp-search-results .bbp-author-avatar {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

/* Avatar image */
.bbp-search-results .bbp-author-avatar img.avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
}

/* Author name */
.bbp-search-results .bbp-author-name {
	font-size: 15px;
	font-weight: 600;
	color: var(--ink);
}

.bbp-search-results .bbp-author-link:hover .bbp-author-name {
	color: var(--accent);
}

/* Role badge */
.bbp-search-results .bbp-author-role {
	display: inline-block;
	padding: 4px 10px;
	background: var(--accent-weak);
	color: var(--accent);
	font-size: 11px;
	font-weight: 600;
	border-radius: 20px;
}

/* Search Result Content/Excerpt - Topic & Reply */
.bbp-search-results .bbp-topic-content,
.bbp-search-results .bbp-reply-content {
	font-size: 15px;
	line-height: 1.7;
	color: var(--muted);
	background: #f9fafb;
}

/* Forum content - simpler styling */
.bbp-search-results .bbp-forum-content {
	font-size: 14px;
	line-height: 1.6;
	color: var(--muted);
}

.bbp-search-results .bbp-topic-content p,
.bbp-search-results .bbp-reply-content p,
.bbp-search-results .bbp-forum-content p {
	margin: 0 0 8px;
}

.bbp-search-results .bbp-topic-content p:last-child,
.bbp-search-results .bbp-reply-content p:last-child,
.bbp-search-results .bbp-forum-content p:last-child {
	margin-bottom: 0;
}

/* Hide content headings and lists in search excerpts for cleaner display */
.bbp-search-results .bbp-topic-content h3,
.bbp-search-results .bbp-reply-content h3,
.bbp-search-results .bbp-topic-content ul,
.bbp-search-results .bbp-reply-content ul,
.bbp-search-results .bbp-topic-content ol,
.bbp-search-results .bbp-reply-content ol {
	display: none;
}

/* Highlighted Search Terms */
.bbp-search-results mark,
.bbp-search-results .search-highlight {
	background: var(--accent-weak);
	color: var(--accent);
	padding: 1px 4px;
	border-radius: 3px;
	font-weight: 500;
}

/* Search Result Excerpt */
.bbp-search-excerpt {
	font-size: 15px;
	line-height: 1.6;
	color: var(--muted);
	margin-top: 8px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* No Results State */
.bbp-search-no-results {
	text-align: center;
	padding: 60px 20px;
	background: var(--subtle-bg);
	border-radius: 16px;
}

.bbp-search-no-results-icon {
	margin-bottom: 24px;
}

.bbp-search-no-results-icon svg {
	width: 64px;
	height: 64px;
	color: var(--line);
}

.bbp-search-no-results h2 {
	font-size: 24px;
	font-weight: 600;
	color: var(--ink);
	margin: 0 0 12px;
}

.bbp-search-no-results p {
	font-size: 16px;
	color: var(--muted);
	margin: 0 0 24px;
	max-width: 400px;
	margin-left: auto;
	margin-right: auto;
}

.bbp-search-no-results .bbp-search-again {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 24px;
	background: var(--accent);
	color: var(--bg);
	border-radius: 8px;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	transition: background-color 0.2s ease;
}

.bbp-search-no-results .bbp-search-again:hover {
	background: #0a1a4d;
}

/* ==========================================================================
   WIDGETS
   Styles for bbPress sidebar widgets.
   ========================================================================== */

/* Widget Container */
.widget_display_forums,
.widget_display_topics,
.widget_display_replies,
.widget_display_views,
.widget_display_stats,
.bbp-widget,
.widget.bbpress {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 24px;
	margin-bottom: 24px;
}

/* Widget Title */
.widget_display_forums h2.widget-title,
.widget_display_topics h2.widget-title,
.widget_display_replies h2.widget-title,
.widget_display_views h2.widget-title,
.widget_display_stats h2.widget-title,
.bbp-widget h2.widget-title,
.widget.bbpress h2.widget-title {
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin: 0 0 16px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--line);
}

/* Widget Lists */
.widget_display_forums ul,
.widget_display_topics ul,
.widget_display_replies ul,
.widget_display_views ul,
.bbp-widget ul,
.widget.bbpress ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Widget List Items */
.widget_display_forums li,
.widget_display_topics li,
.widget_display_replies li,
.widget_display_views li,
.bbp-widget li,
.widget.bbpress li {
	margin-bottom: 4px;
}

.widget_display_forums li:last-child,
.widget_display_topics li:last-child,
.widget_display_replies li:last-child,
.widget_display_views li:last-child,
.bbp-widget li:last-child,
.widget.bbpress li:last-child {
	margin-bottom: 0;
}

/* Widget Links - TOC Link Pattern */
.widget_display_forums li a,
.widget_display_topics li a,
.widget_display_replies li a,
.widget_display_views li a,
.bbp-widget li a,
.widget.bbpress li a {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 8px 12px;
	border-radius: 8px;
	text-decoration: none;
	color: var(--muted);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	transition: all 0.2s ease;
}

.widget_display_forums li a:hover,
.widget_display_topics li a:hover,
.widget_display_replies li a:hover,
.widget_display_views li a:hover,
.bbp-widget li a:hover,
.widget.bbpress li a:hover {
	background: #f3f4f6;
	color: var(--ink);
}

.widget_display_forums li a:focus,
.widget_display_topics li a:focus,
.widget_display_replies li a:focus,
.widget_display_views li a:focus,
.bbp-widget li a:focus,
.widget.bbpress li a:focus {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Forum Statistics Widget */
.widget_display_stats dl {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.widget_display_stats dt {
	font-size: 13px;
	color: var(--muted);
	margin: 0;
}

.widget_display_stats dd {
	font-size: 15px;
	font-weight: 600;
	color: var(--ink);
	margin: 0 0 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--line);
}

.widget_display_stats dd:last-of-type {
	border-bottom: none;
	padding-bottom: 0;
	margin-bottom: 0;
}

/* Recent Topics/Replies Widget Author Info */
.widget_display_topics .bbp-author-avatar,
.widget_display_replies .bbp-author-avatar {
	display: none;
}

.widget_display_topics .bbp-topic-meta,
.widget_display_replies .bbp-reply-meta {
	font-size: 12px;
	color: var(--muted);
	margin-top: 4px;
	padding-left: 12px;
}

/* Views Widget (e.g., Popular, No Replies) */
.widget_display_views li a::before {
	content: '';
	display: block;
	width: 6px;
	height: 6px;
	background: var(--accent);
	border-radius: 50%;
	flex-shrink: 0;
	margin-top: 6px;
}

/* ==========================================================================
   SEARCH RESPONSIVE
   Mobile-friendly search form adjustments.
   ========================================================================== */

@media (max-width: 640px) {
	/* Stack search form vertically */
	.bbp-search-form #bbp-search-form {
		flex-direction: column;
		border-radius: 12px;
	}

	.bbp-search-form #bbp-search-form > div {
		flex-direction: column;
	}

	.bbp-search-form .bbp-search-icon {
		top: 17px;
	}

	.bbp-search-form #bbp_search {
		width: 100%;
		padding: 14px 16px 14px 48px;
	}

	.bbp-search-form #bbp_search_submit {
		width: 100%;
		border-radius: 0 0 11px 11px;
	}

	/* Search results adjustments */
	.bbp-search-results-header h1 {
		font-size: clamp(24px, 6vw, 28px);
	}

	.bbp-search-no-results {
		padding: 40px 16px;
	}

	.bbp-search-no-results-icon svg {
		width: 48px;
		height: 48px;
	}

	.bbp-search-no-results h2 {
		font-size: 20px;
	}

	/* Widget adjustments */
	.widget_display_forums,
	.widget_display_topics,
	.widget_display_replies,
	.widget_display_views,
	.widget_display_stats,
	.bbp-widget,
	.widget.bbpress {
		padding: 20px;
	}
}

/* ==========================================================================
   SEARCH & WIDGETS ACCESSIBILITY
   Focus states and reduced motion support.
   ========================================================================== */

/* Focus visible states */
.bbp-search-form #bbp_search:focus-visible,
.bbp-search-form #bbp_search_submit:focus-visible,
.widget_display_forums li a:focus-visible,
.widget_display_topics li a:focus-visible,
.widget_display_replies li a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	/* Search & widgets */
	.bbp-search-form #bbp-search-form,
	.bbp-search-form #bbp_search_submit,
	.widget_display_forums li a,
	.widget_display_topics li a,
	.widget_display_replies li a,
	.widget_display_views li a,
	.bbp-widget li a,
	.widget.bbpress li a {
		transition: none;
	}
}
