/**
 * WCF Comments – Frontend Styles
 *
 * All rules are scoped to .wcf-comments so the widget never leaks styles
 * outside of its own container.
 *
 * Design tokens (CSS custom properties) are set inline by the PHP render()
 * method and optionally overridden by Elementor's style controls:
 *
 *   --wcf-primary      Primary brand colour (buttons, avatars, accents)
 *   --wcf-staff        Staff badge / reply border colour
 *   --wcf-bg-comment   Background for root-level comment cards
 *   --wcf-bg-reply     Background for nested reply cards
 *   --wcf-radius       Border-radius applied to cards, inputs and buttons
 */

/* ── Reset / container ─────────────────────────────────────────────────── */

.wcf-comments {
	--wcf-primary:    #4f46e5;
	--wcf-staff:      #059669;
	--wcf-bg-comment: #f9fafb;
	--wcf-bg-reply:   #f0fdf4;
	--wcf-radius:     8px;

	box-sizing: border-box;
	max-width: 100%;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
	             Helvetica, Arial, sans-serif, "Apple Color Emoji";
	font-size: 15px;
	color: #111827;
	line-height: 1.5;
}

.wcf-comments *,
.wcf-comments *::before,
.wcf-comments *::after {
	box-sizing: inherit;
}

/* ── Comments header (count + sort) ───────────────────────────────────── */

.wcf-comments-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 20px;
	padding-bottom: 12px;
	border-bottom: 1px solid #e5e7eb;
}

.wcf-comment-count {
	font-size: 17px;
	font-weight: 700;
	color: #111827;
}

.wcf-sort-select {
	border: 1px solid #e5e7eb;
	border-radius: var(--wcf-radius);
	color: #6b7280;
	font-family: inherit;
	font-size: 13px;
	padding: 5px 10px;
	background: #fff;
	cursor: pointer;
	outline: none;
	transition: border-color 0.15s, color 0.15s;
}

.wcf-sort-select:hover,
.wcf-sort-select:focus {
	border-color: var(--wcf-primary);
	color: var(--wcf-primary);
}

/* ── Comment card ──────────────────────────────────────────────────────── */

.wcf-comment {
	display: flex;
	gap: 12px;
	background: var(--wcf-bg-comment);
	border-radius: var(--wcf-radius);
	padding: 16px;
	margin-bottom: 12px;
}

/* Reply card – indented, with a left accent border */
.wcf-comment--reply {
	background: var(--wcf-bg-reply);
	margin-left: 40px;
	border-left: 3px solid var(--wcf-primary);
}

/* Staff reply – different accent colour */
.wcf-comment--reply.wcf-comment--staff {
	border-left-color: var(--wcf-staff);
}

/* ── Avatar ────────────────────────────────────────────────────────────── */

.wcf-avatar {
	width: 40px;
	height: 40px;
	min-width: 40px;
	background: var(--wcf-primary);
	color: #fff;
	font-size: 16px;
	font-weight: 700;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	user-select: none;
}

/* ── Comment body wrapper ──────────────────────────────────────────────── */

.wcf-comment-body {
	flex: 1;
	min-width: 0; /* prevent flex children from overflowing */
}

/* ── Meta row (author · badge · time) ─────────────────────────────────── */

.wcf-comment-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 6px;
}

.wcf-author-name {
	font-weight: 600;
	color: #111827;
}

.wcf-staff-badge {
	display: inline-block;
	background: var(--wcf-staff);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 99px;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.wcf-time {
	color: #6b7280;
	font-size: 13px;
}

/* ── Comment text ──────────────────────────────────────────────────────── */

.wcf-comment-content {
	line-height: 1.6;
	color: #374151;
	word-break: break-word;
	overflow-wrap: break-word;
}

.wcf-comment-content code {
	background: #f3f4f6;
	padding: 1px 4px;
	border-radius: 3px;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
	             Courier, monospace;
	font-size: 0.9em;
}

/* ── Reply button ──────────────────────────────────────────────────────── */

.wcf-reply-btn {
	display: inline-block;
	background: none;
	border: none;
	color: var(--wcf-primary);
	font-size: 13px;
	font-weight: 600;
	padding: 4px 0;
	margin-top: 6px;
	cursor: pointer;
	transition: opacity 0.15s;
}

.wcf-reply-btn:hover {
	opacity: 0.75;
}

/* ── Inline reply form wrapper ─────────────────────────────────────────── */

.wcf-inline-reply-form {
	margin-top: 12px;
	padding: 12px;
	background: #fff;
	border-radius: var(--wcf-radius);
	border: 1px solid #e5e7eb;
}

/* ── Comment form ──────────────────────────────────────────────────────── */

.wcf-form {
	margin-top: 24px;
}

.wcf-form-row {
	margin-bottom: 12px;
}

.wcf-form input[type="text"],
.wcf-form input[type="email"],
.wcf-form textarea {
	display: block;
	width: 100%;
	padding: 10px 14px;
	border: 1px solid #e5e7eb;
	border-radius: var(--wcf-radius);
	font-family: inherit;
	font-size: 14px;
	color: #111827;
	background: #fff;
	outline: none;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.wcf-form input[type="text"]:focus,
.wcf-form input[type="email"]:focus,
.wcf-form textarea:focus {
	border-color: var(--wcf-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wcf-primary) 15%, transparent);
}

.wcf-form textarea {
	min-height: 100px;
	resize: vertical;
}

/* ── Markdown hint ─────────────────────────────────────────────────────── */

.wcf-markdown-hint {
	margin: 4px 0 0;
	font-size: 12px;
	color: #9ca3af;
	line-height: 1.4;
}

/* ── Form actions row ──────────────────────────────────────────────────── */

.wcf-form-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	align-items: center;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.wcf-btn {
	display: inline-block;
	background: var(--wcf-btn-bg, var(--wcf-primary));
	color: var(--wcf-btn-text, #fff);
	border: none;
	padding: 10px 20px;
	border-radius: var(--wcf-radius);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: filter 0.2s;
	line-height: 1.4;
}

.wcf-btn:hover:not(:disabled) {
	filter: brightness(0.9);
}

.wcf-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.wcf-btn--secondary {
	background: #e5e7eb;
	color: #374151;
}

.wcf-btn--secondary:hover:not(:disabled) {
	background: #d1d5db;
	filter: none;
}

/* ── Status messages ───────────────────────────────────────────────────── */

.wcf-loading,
.wcf-error,
.wcf-success {
	text-align: center;
	padding: 16px;
	border-radius: var(--wcf-radius);
}

.wcf-loading {
	color: #6b7280;
	font-style: italic;
}

.wcf-error {
	color: #dc2626;
	background: #fef2f2;
	border: 1px solid #fecaca;
}

.wcf-success {
	color: #059669;
	background: #f0fdf4;
	border: 1px solid #a7f3d0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.wcf-comment {
		padding: 12px;
		gap: 8px;
	}

	.wcf-comment--reply {
		margin-left: 16px;
	}

	.wcf-avatar {
		width: 32px;
		height: 32px;
		min-width: 32px;
		font-size: 13px;
	}

	.wcf-btn {
		width: 100%;
		text-align: center;
	}

	.wcf-form-actions {
		flex-direction: column;
	}

	.wcf-btn--secondary {
		width: 100%;
		text-align: center;
	}
}
