/* ==========================================================
   Forum Frontend Styles
   ========================================================== */

.forum-container {
	max-width: 800px;
	margin: 0 auto;
	padding: 1rem;
}

/* Breadcrumbs */
.forum-breadcrumbs {
	padding: 0.75rem 0;
	font-size: 0.875rem;
	color: #666;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0;
}
.forum-breadcrumbs a {
	color: #2563eb;
	text-decoration: none;
}
.forum-breadcrumbs a:hover {
	text-decoration: underline;
}
.forum-breadcrumbs__sep {
	margin: 0 0.375rem;
	color: #999;
}
.forum-breadcrumbs__current {
	color: #333;
}

/* Forum Index */
/* Forum Index Nav */
.forum-index__nav {
	margin-bottom: 1rem;
}

/* Feed Header */
.forum-feed__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}
.forum-feed__header-right {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

/* Tags + Count Row */
.forum-tags-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 1.5rem;
}

/* Count Label */
.forum-count {
	font-size: 0.8125rem;
	color: #888;
	white-space: nowrap;
	margin-left: auto;
}

.forum-category {
	margin-bottom: 2rem;
}
.forum-category__title {
	font-size: 1.125rem;
	font-weight: 600;
	color: #111;
	padding-bottom: 0.5rem;
	border-bottom: 2px solid #e5e7eb;
	margin-bottom: 0;
}
.forum-category__list {
	border: 1px solid #e5e7eb;
	border-top: none;
	border-radius: 0 0 0.5rem 0.5rem;
}

/* Forum Row (index listing) */
.forum-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid #f3f4f6;
	text-decoration: none;
	color: inherit;
	transition: background-color 0.15s;
}
.forum-row:last-child {
	border-bottom: none;
}
.forum-row:hover {
	background-color: #f9fafb;
}
.forum-row__name {
	font-size: 1rem;
	font-weight: 600;
	color: #111;
	margin: 0;
}
.forum-row__desc {
	font-size: 0.8125rem;
	color: #666;
	margin: 0.25rem 0 0;
}
.forum-row__stats {
	display: flex;
	gap: 1rem;
	flex-shrink: 0;
	margin-left: 1rem;
}
.forum-stat {
	font-size: 0.8125rem;
	color: #888;
	white-space: nowrap;
}
.forum-stat strong {
	color: #333;
}

/* Thread Listing */
.forum-thread-list__header {
	margin-bottom: 1.5rem;
}
.forum-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: #111;
	margin: 0;
}
.forum-description {
	color: #666;
	margin: 0.25rem 0 0;
	font-size: 0.875rem;
}
.forum-scroll-area {
	max-height: calc(100vh - 16rem);
	overflow-y: auto;
}
.forum-thread-list__items {
	border: 1px solid #e5e7eb;
}

/* Thread Row */
.thread-row {
	display: flex;
	align-items: center;
	padding: 0.6rem;
	border-bottom: 1px solid #f3f4f6;
	color: inherit;
	transition: background-color 0.15s;
}
.thread-row {
	cursor: pointer;
}
.thread-row:last-child {
	border-bottom: none;
}
.thread-row:hover {
	background-color: #f9fafb;
}
.thread-row--sticky {
	background-color: #fffbeb;
}
.thread-row--sticky:hover {
	background-color: #fef3c7;
}
.thread-row__info {
	flex: 1;
	min-width: 0;
}
.thread-row__subject {
	font-size: 0.9375rem;
	font-weight: 600;
	color: #111;
	margin: 0;
}
.thread-row__meta {
	font-size: 0.8125rem;
	color: #888;
	margin-top: 0.125rem;
	display: block;
}
.thread-row__stats {
	display: flex;
	gap: 1rem;
	flex-shrink: 0;
	margin-left: 1rem;
}

/* Thread Badges */
.thread-badge {
	display: inline-block;
	font-size: 0.6875rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.025em;
	padding: 0.125rem 0.5rem;
	border-radius: 999px;
	vertical-align: middle;
}
.thread-badge--sticky {
	background-color: #fef3c7;
	color: #92400e;
}
.thread-badge--locked {
	background-color: #fee2e2;
	color: #991b1b;
}
.thread-badge--hidden {
	background-color: #e5e7eb;
	color: #374151;
}
.thread-badge--moderator {
	background-color: #dbeafe;
	color: #1e40af;
}
.thread-badge--flagged {
	background-color: #fde68a;
	color: #78350f;
	cursor: help;
}
.post-card__badges {
	display: inline;
}

/* Tag Pills */
.forum-tag-pill {
	display: inline-block;
	font-size: 0.6875rem;
	font-weight: 500;
	padding: 0.0625rem 0.4375rem;
	border-radius: 999px;
	background-color: #f3f4f6;
	color: #374151;
	vertical-align: middle;
}
.forum-tag-pill--link {
	text-decoration: none;
	cursor: pointer;
}
.forum-tag-pill--link:hover {
	background-color: #e5e7eb;
	color: #111;
}
.thread-row__author-link {
	color: inherit;
	text-decoration: none;
}
.thread-row__author-link:hover {
	color: #2563eb;
	text-decoration: underline;
}
.thread-row__tags {
	display: flex;
	gap: 0.25rem;
	flex-wrap: wrap;
	margin-top: 0.125rem;
}

/* Filter Bar */
.forum-filter-bar {
	padding: 0.5rem 0;
}
.forum-filter-bar__row {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	align-items: center;
}
.forum-filter-bar__row--extra {
	margin-top: 0.375rem;
}
.forum-filter-bar__input {
	font-size: 0.8125rem;
	padding: 0.3125rem 0.625rem;
	border: 1px solid #d1d5db;
	border-radius: 0.375rem;
	background: #fff;
	color: #374151;
	flex: 1;
	min-width: 120px;
	max-width: 240px;
}
.forum-filter-bar__input--sm {
	max-width: 160px;
}
.forum-filter-bar__select {
	font-size: 0.8125rem;
	padding: 0.3125rem 0.5rem;
	border: 1px solid #d1d5db;
	border-radius: 0.375rem;
	background: #fff;
	color: #374151;
	cursor: pointer;
}
.forum-filter-bar__btn {
	padding: 0.3125rem 0.75rem;
	font-size: 0.8125rem;
}
.forum-filter-bar__toggle {
	font-size: 0.75rem;
	color: #2563eb;
	text-decoration: none;
}
.forum-filter-bar__toggle:hover {
	text-decoration: underline;
}
.forum-filter-bar__extra {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	align-items: center;
	margin-top: 0.25rem;
}

/* Tag Checkboxes (new thread dialog) */
.forum-tag-checkboxes {
	display: flex;
	flex-wrap: wrap;
	gap: 0.375rem 0.75rem;
}
.forum-tag-checkbox {
	font-size: 0.8125rem;
	cursor: pointer;
}
.forum-tag-checkbox input {
	margin-right: 0.25rem;
}

/* Search Filter Tags */
#search-tags {
	padding: 0.25rem 0;
}
#search-tags .tag {
	display: inline-flex;
	align-items: center;
	background: linear-gradient(to right, #9ca3af 20px, #fef3c7 20px, #fef3c7 100%);
	border: 1px solid #d1d5db;
	border-radius: 0.25rem;
	padding: 0.125rem 0.5rem 0.125rem 0.125rem;
	margin: 0 0.375rem 0.375rem 0;
	font-size: 0.8125rem;
	position: relative;
}
#search-tags .tag button {
	position: absolute;
	left: 0;
	background: none;
	border: none;
	color: #fff;
	font-weight: bold;
	cursor: pointer;
	padding: 0.25rem 0.375rem;
	font-size: 0.6875rem;
	line-height: 1;
}
#search-tags .tag button:hover {
	color: #fee2e2;
}
#search-tags .tag span {
	margin-left: 1.25rem;
}
#search-tags .tag strong {
	margin-left: 0;
}


/* Thread View Header */
.forum-thread-view__header {
	display: block;
}
.forum-thread-view__tags {
	display: flex;
	gap: 0.375rem;
	flex-wrap: wrap;
	margin-bottom: 0.5rem;
}

/* Thread View */
.forum-thread-view__actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-bottom: 0.5rem;
}
.forum-btn--sm {
	padding: 0.25rem 0.75rem;
	font-size: 0.8125rem;
}
.forum-thread-view__title {
	font-size: 1.5rem;
	font-weight: 700;
	color: #111;
	margin: 0 0 0.5rem;
}

/* ==========================================================
   Post Card — all posts look the same by default
   ========================================================== */
.post-card {
	padding: 0.75rem;
	border-bottom: 1px solid #e5e7eb;
}
.post-card__header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.375rem;
}
.post-card__author {
	font-weight: 700;
	color: #111;
	font-size: 0.9375rem;
}
.post-card__right-group {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-left: auto;
	flex-shrink: 0;
}
.post-card__date-group {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.post-card__date {
	font-size: 0.8125rem;
	color: #888;
}
.post-card__time-ago {
	font-size: 0.8125rem;
	color: #aaa;
}
.post-card__body {
	padding-left: 2rem;
	overflow-wrap: break-word;
}
.post-card__body p:first-child { margin-top: 0; }
.post-card__body p:last-child  { margin-bottom: 0; }
.post-card__body--truncated {
	display: -webkit-box;
	-webkit-line-clamp: 6;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.post-card__read-more {
	background: none;
	border: none;
	color: #2563eb;
	font-size: 0.8125rem;
	font-weight: 500;
	cursor: pointer;
	padding: 0;
	padding-left: 0.75rem;
	white-space: nowrap;
}
.post-card__read-more:hover { text-decoration: underline; }
.post-card__footer {
	margin-top: 0.5rem;
	padding-left: 2rem;
	display: flex;
	align-items: center;
	gap: 0.75rem;
}
.post-card__reply-icon {
	width: 14px;
	height: 14px;
	vertical-align: -2px;
	margin-right: 0.25rem;
	opacity: 0.6;
}
.post-card__reply-count {
	font-size: 0.8125rem;
	color: #888;
	text-decoration: none;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
}
.post-card__reply-count:hover { color: #2563eb; }
.post-card__edited {
	font-size: 0.75rem;
	color: #999;
	font-style: italic;
}

/* ==========================================================
   Reply chain layout
   ========================================================== */
.forum-reply-chain {
	max-height: calc(100vh - 16rem);
	overflow-y: auto;
    border: 1px solid #e5e7eb;
}

/* Ancestors — quote line down the left */
.forum-reply-chain__ancestors {
	position: relative;
	padding-left: 1.25rem;
}
.forum-reply-chain__ancestors::before {
	content: '';
	position: absolute;
	left: 15px;
	top: 0;
	bottom: 0;
	width: 3px;
	background: #cfd8dc;
}
.post-card--ancestor .post-card__body {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.post-card--focused {
	background-color: #f0f8ff;
}

/* Focused post — text aligns back to left margin, slightly larger */
.post-card--focused .post-card__body {
	padding-left: 0;
	font-size: 1.0625rem;
}
.post-card--focused .post-card__footer {
	padding-left: 0;
}
.forum-reply-chain__focus {
	padding-bottom: 100rem;
}

/* Replies section */
.forum-replies {
	margin-top: 0;
}

/* Latest Posts Feed */
.forum-latest-posts {
	max-width: 800px;
}
.forum-latest-post {
	padding: 0.75rem;
	border-bottom: 1px solid #e5e7eb;
	cursor: pointer;
	transition: background-color 0.15s;
}
.forum-latest-post:hover {
	background-color: #f5f5f5;
}
.forum-latest-post__meta {
	font-size: 0.8125rem;
	margin-bottom: 0.25rem;
	display: flex;
	gap: 0.5rem;
}
.forum-latest-post__forum a {
	color: #2563eb;
	text-decoration: none;
	font-weight: 500;
}
.forum-latest-post__thread a {
	color: #888;
	text-decoration: none;
}
.forum-latest-post__thread a:hover,
.forum-latest-post__forum a:hover {
	text-decoration: underline;
}
.forum-latest-post__body {
	padding-left: 0.75rem;
	color: #333;
	line-height: 1.5;
	font-size: 0.9375rem;
}

/* Infinite Scroll */
.forum-scroll-sentinel {
	padding: 1.5rem;
	text-align: center;
}
.forum-loading {
	color: #888;
	font-size: 0.875rem;
}

/* Empty State */
.forum-empty {
	text-align: center;
	padding: 3rem 1rem;
	color: #888;
	font-size: 0.9375rem;
}

/* Markdown Body */
.markdown-body code {
	background: #f3f4f6;
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-size: 0.875em;
}
.markdown-body pre {
	background: #f8f9fa;
	border: 1px solid #e5e7eb;
	border-radius: 0.375rem;
	padding: 1rem;
	overflow-x: auto;
}
.markdown-body pre code {
	background: none;
	padding: 0;
}
.markdown-body blockquote {
	border-left: 3px solid #d1d5db;
	margin-left: 0;
	padding-left: 1rem;
	color: #666;
}
.markdown-body img {
	max-width: 100%;
	height: auto;
	border-radius: 0.375rem;
}
.markdown-body table {
	border-collapse: collapse;
	width: 100%;
}
.markdown-body th,
.markdown-body td {
	border: 1px solid #e5e7eb;
	padding: 0.5rem 0.75rem;
	text-align: left;
}
.markdown-body th {
	background: #f9fafb;
	font-weight: 600;
}

/* Buttons */
.forum-btn {
	display: inline-block;
	padding: 0.5rem 1.25rem;
	border-radius: 0.375rem;
	font-size: 0.875rem;
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	transition: background-color 0.15s, border-color 0.15s;
}
.forum-btn--primary {
	background: #2563eb;
	color: #fff;
	border-color: #2563eb;
}
.forum-btn--primary:hover {
	background: #1d4ed8;
}
.forum-btn--secondary {
	background: #fff;
	color: #333;
	border-color: #d1d5db;
}
.forum-btn--secondary:hover {
	background: #f9fafb;
}

/* Clickable Post */
.post-card--clickable {
	cursor: pointer;
	transition: background-color 0.15s;
}
.post-card--clickable:hover {
	background-color: #f5f5f5;
}

/* Action Buttons in Post Card */
.post-card__action-btn {
	background: none;
	border: none;
	color: #888;
	cursor: pointer;
	font-size: 0.8125rem;
	font-weight: 500;
	padding: 0;
}
.post-card__action-btn:hover {
	color: #2563eb;
	text-decoration: underline;
}

/* Reply Dialog */
.dlg-reply__quoted {
	background: #f9fafb;
	border-left: 3px solid #d1d5db;
	border-radius: 0 0.25rem 0.25rem 0;
	padding: 0.75rem 1rem;
	margin-bottom: 1rem;
	max-height: 12em;
	overflow-y: auto;
}
.dlg-reply__quoted-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}
.dlg-reply__quoted-body {
	font-size: 0.875rem;
	color: #555;
	line-height: 1.5;
}
.dlg-reply__quoted-body p:first-child {
	margin-top: 0;
}
.dlg-reply__quoted-body p:last-child {
	margin-bottom: 0;
}

/* Thread List Actions */
.forum-thread-list__actions {
	margin-top: 0.75rem;
	text-align: right;
}

/* Reply Form */
.forum-reply-form {
	margin-top: 0.5rem;
}
.forum-reply-form__actions {
	display: flex;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

/* Markdown Editor */
.forum-editor {
	border: 1px solid #d1d5db;
	border-radius: 0.375rem;
	overflow: hidden;
}
.forum-editor__toolbar {
	display: flex;
	gap: 0.25rem;
	padding: 0.375rem 0.5rem;
	background: #f9fafb;
	border-bottom: 1px solid #e5e7eb;
}
.forum-editor__btn {
	background: none;
	border: 1px solid transparent;
	border-radius: 0.25rem;
	padding: 0.25rem 0.5rem;
	cursor: pointer;
	font-size: 0.8125rem;
	color: #333;
}
.forum-editor__btn:hover {
	background: #e5e7eb;
}
.forum-editor__btn.active {
	background: #dbeafe;
	border-color: #93c5fd;
}
.forum-editor__btn--preview {
	margin-left: auto;
}
.forum-editor__textarea {
	width: 100%;
	border: none;
	padding: 0.75rem;
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.6;
	resize: vertical;
	min-height: 120px;
	box-sizing: border-box;
}
.forum-editor__textarea:focus {
	outline: none;
}
.forum-editor__preview {
	padding: 0.75rem;
	border-top: 1px solid #e5e7eb;
	min-height: 60px;
	background: #fefefe;
}

/* Auth Notices */
.forum-login-prompt,
.forum-auth-notice {
	padding: 1rem;
	background: #f3f4f6;
	border-radius: 0.375rem;
	text-align: center;
	font-size: 0.875rem;
	color: #666;
	margin-top: 0.5rem;
}
.forum-login-prompt a {
	color: #2563eb;
	font-weight: 500;
}

/* Error */
.forum-error {
	padding: 0.75rem;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 0.375rem;
	color: #991b1b;
	font-size: 0.875rem;
}

/* Action menu (three dots) */
.forum-action-cell {
	position: relative;
	flex-shrink: 0;
}
.forum-action-btn {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 18px;
	color: #888;
	padding: 0 8px;
	border-radius: 4px;
	line-height: 1;
}
.forum-action-btn::after {
	content: '⋮';
	font-weight: bold;
}
.forum-action-btn:hover {
	background-color: #eee;
	color: #333;
}
.forum-action-menu {
	position: fixed;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 0.5rem;
	box-shadow: 0 2px 10px rgba(0,0,0,0.15);
	z-index: 100;
	min-width: 160px;
}
.forum-action-menu ul {
	list-style: none;
	margin: 0;
	padding: 0.25rem 0;
}
.forum-action-menu li {
	border-bottom: 1px solid #f3f4f6;
}
.forum-action-menu li:last-child {
	border-bottom: none;
}
.forum-action-menu a {
	display: block;
	padding: 0.5rem 0.75rem;
	font-size: 0.8125rem;
	color: #333;
	text-decoration: none;
	cursor: pointer;
}
.forum-action-menu a:hover {
	background-color: #f5f5f5;
}
.forum-action-menu a.forum-action--danger {
	color: #991b1b;
}
/* Like button */
.post-card__like-wrap {
	display: inline-flex;
}
.post-card__like-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	background: none;
	border: none;
	cursor: pointer;
	color: #888;
	font-size: 0.8125rem;
	font-weight: 500;
	padding: 0;
}
.post-card__like-btn:hover {
	color: #2563eb;
}
.post-card__like-btn--active {
	color: #2563eb;
}
.post-card__like-icon {
	width: 14px;
	height: 14px;
}
.post-card__like-count {
	font-size: 0.8125rem;
}

.post-card__header .forum-action-cell {
	margin-left: auto;
}

/* Thread View Header */
.forum-thread-view__header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
	margin-bottom: 0.5rem;
}

/* New Post Animation */
.post-card--new {
	animation: forum-fade-in 0.3s ease-out;
}
@keyframes forum-fade-in {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 640px) {
	.forum-container {
		padding: 0.5rem;
	}
	.forum-row,
	.thread-row {
		flex-direction: column;
		align-items: flex-start;
	}
	.forum-row__stats,
	.thread-row__stats {
		margin-left: 0;
		margin-top: 0.5rem;
	}
	.forum-reply-chain__ancestors {
		padding-left: 0.75rem;
	}
}
