/**
 * Release Interactions Styles
 *
 * Reactions bar, comments section, and inline auth modal.
 *
 * @package Changeloger_Pro
 */

/* ========================================
   Interactions Bar (reactions + comment)
   ======================================== */

.cha-interactions-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding:8px 10px;
	margin-top: 35px;
	border: 1px solid #5b678f26;
	border-radius: 10px;
	/* ── Reactions group ── */
	.cha-reactions-group {
		display: flex;
		align-items: center;
		gap: 10px;
		margin-right: 5px;
		.cha-reaction-btn {
			display: inline-flex;
			align-items: center;
			gap: 4px;
			padding: 6px;
			border:1px solid transparent;
			border-radius: 6px;
			background: #fff;
			cursor: pointer;
			font-size: 14px;
			transition: all 0.2s;
			line-height: 1;
			color: #64748b;
			margin-top: 5px;
			position: relative;
			&:hover {
				border-color: #e2e8f0;
				background: #f8fafc;
			}

			&.active {
				background: color-mix(in srgb, var(--changeloger_brand_color, #6366f1) 15%, #fff);
				color: var(--changeloger_brand_color, #6366f1);
				.cha-reaction-count{
					border-color: var(--changeloger_brand_color, #6366f1);
					background: var(--changeloger_brand_color, #6366f1);
					color: #fff;
				}
			}

			.cha-reaction-emoji {
				font-size: 17px;
				line-height: 1;
			}

			.cha-reaction-count {
				position: absolute;
				top: -7px;
				right: -7px;
				font-size: 10px;
				font-weight: 600;
				min-width: 12px;
				padding: 2px 4px;
				border: 1px solid #e2e8f0;
				border-radius: 50%;
				background: #fff;
				text-align: center;
			}
		}
	}

	/* ── Comment count link ── */
	.cha-comment-count-link {
		display: inline-flex;
		align-items: center;
		gap: 5px;
		padding: 6px 10px;
		border-radius: 6px;
		font-size: 13px;
		font-weight: 500;
		color: #64748b;
		text-decoration: none;
		transition: all 0.2s;
		line-height: 1;

		&:hover {
			color: var(--changeloger_brand_color, #6366f1);
			background: color-mix(in srgb, var(--changeloger_brand_color, #6366f1) 8%, #fff);
		}

		svg {
			flex-shrink: 0;
		}
	}

	/* ── Divider ── */
	.cha-bar-divider {
		width: 1px;
		height: 30px;
		background: #dee1ea;
		margin: 0 4px;
	}

	/* ── Inline comment (logged-in) ── */
	.cha-inline-comment {
		display: flex;
		align-items: center;
		gap: 0;
		flex: 1;

		.cha-inline-comment-avatar {
			width: 28px;
			height: 28px;
			border-radius: 50%;
			object-fit: cover;
			flex-shrink: 0;
			border: 1.5px solid #e2e8f0;
		}

		.cha-inline-comment-field {
			flex: 1;
			display: flex;
			align-items: center;
			gap: 0;
			position: relative;
			border: none;
			transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
			overflow: hidden;

			&:focus-within {
				input::placeholder {
					color: #323334;
				}
			}

			.cha-inline-comment-input {
				flex: 1;
				padding: 7px 0 7px 10px;
				border: none !important;
				background: #fff !important;
				font-size: 13px;
				outline: none;
				color: #1e293b;
				min-width: 0;

				&:focus {
					outline: none !important;
					border-color: transparent !important;
					box-shadow: none !important;
				}

				&::placeholder {
					color: #94a3b8;
				}
			}

			.cha-inline-comment-submit {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 32px;
				height: 32px;
				padding: 0;
				border: none;
				background: var(--changeloger_brand_color, #6366f1);
				color: #fff;
				cursor: pointer;
				border-radius: 50%;
				margin: 2px;
				flex-shrink: 0;
				transition: opacity 0.2s, transform 0.15s;

				&:hover:not(:disabled) {
					opacity: 0.9;
					transform: scale(1.05);
				}

				&:disabled {
					opacity: 0.3;
					cursor: not-allowed;
				}
			}
		}

		/* Toast notification */
		.cha-inline-comment-toast {
			font-size: 12px;
			font-weight: 500;
			padding: 3px 10px;
			border-radius: 12px;
			white-space: nowrap;
			animation: chaToastFadeIn 0.25s ease;

			&.cha-inline-comment-toast--success {
				color: #16a34a;
				background: #f0fdf4;
			}

			&.cha-inline-comment-toast--error {
				color: #dc2626;
				background: #fef2f2;
			}
		}

		/* Guest variant */
		&.cha-inline-comment--guest {
			text-decoration: none;
			color: #64748b;
			cursor: pointer;
			padding: 7px 14px;
			border: 1px solid #e2e8f0;
			border-radius: 22px;
			font-size: 13px;
			background: #f8fafc;
			transition: border-color 0.2s, background 0.2s;

			&:hover {
				border-color: #94a3b8;
				background: #f1f5f9;
				color: #475569;
			}

			.cha-inline-comment-placeholder {
				flex: 1;
			}

			.cha-inline-comment-arrow {
				display: flex;
				align-items: center;
				color: #94a3b8;
			}

			.cha-comment-icon {
				flex-shrink: 0;
			}
		}
	}
}

@keyframes chaToastFadeIn {
	from {
		opacity: 0;
		transform: translateY(4px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ========================================
   Comments Section (single release page)
   ======================================== */

.cha-comments-section {
	margin-top: 32px;
	padding-top: 24px;
	border-top: 1px solid #e2e8f0;

	/* ── Header ── */
	.cha-comments-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 20px;

		.cha-comments-title {
			margin: 0;
			font-size: 18px;
			font-weight: 600;
			color: #1e293b;
			display: flex;
			align-items: center;
			gap: 6px;

			.cha-comments-count {
				font-size: 14px;
				font-weight: 400;
				color: #94a3b8;
			}
		}

		.cha-comments-sort {
			display: flex;
			align-items: center;

			.cha-sort-select {
				padding: 5px 10px;
				border: 1px solid #e2e8f0;
				border-radius: 6px;
				font-size: 13px;
				background: #fff;
				color: #475569;
				cursor: pointer;
			}
		}
	}

	/* ── Comment form wrapper ── */
	.cha-comment-form-wrapper {
		margin-bottom: 24px;

		.cha-comment-form {
			display: flex;
			gap: 12px;
			align-items: flex-start;

			.cha-comment-avatar {
				width: 36px;
				height: 36px;
				border-radius: 50%;
				object-fit: cover;
				flex-shrink: 0;
			}

			.cha-comment-input-wrap {
				flex: 1;
				display: flex;
				flex-direction: column;
				gap: 0;

				/* WYSIWYG toolbar */
				.cha-wysiwyg-toolbar {
					display: flex;
					flex-wrap: wrap;
					gap: 2px;
					padding: 4px 6px;
					border: 1px solid #e2e8f0;
					border-bottom: none;
					border-radius: 10px 10px 0 0;
					background: #f8fafc;

					.cha-wysiwyg-btn {
						display: inline-flex;
						align-items: center;
						justify-content: center;
						width: 28px;
						height: 28px;
						padding: 0;
						border: none;
						border-radius: 4px;
						background: transparent;
						color: #475569;
						font-size: 14px;
						cursor: pointer;
						transition: background 0.15s, color 0.15s;

						&:hover {
							background: #e2e8f0;
							color: #1e293b;
						}

						&.is-active {
							background: var(--changeloger_brand_color, #6366f1);
							color: #fff;
						}

						.dashicons {
							font-size: 16px;
							width: 16px;
							height: 16px;
						}
					}

					.cha-wysiwyg-separator {
						width: 1px;
						height: 18px;
						margin: 5px 4px;
						background: #e2e8f0;
					}
				}

				/* WYSIWYG editor (contenteditable) */
				.cha-wysiwyg-editor {
					width: 100%;
					padding: 10px 14px;
					border: 1px solid #e2e8f0;
					border-radius: 0 0 10px 10px;
					font-size: 14px;
					outline: none;
					transition: border-color 0.2s;
					min-height: 80px;
					max-height: 300px;
					overflow-y: auto;
					line-height: 1.6;

					&:focus {
						border-color: var(--changeloger_brand_color, #6366f1);
					}

					&:empty::before {
						content: attr(data-placeholder);
						color: #94a3b8;
						pointer-events: none;
					}

					a {
						color: var(--changeloger_brand_color, #6366f1);
						text-decoration: underline;
					}

					img {
						max-width: 100%;
						height: auto;
						border-radius: 6px;
						margin: 4px 0;
					}

					ul,
					ol {
						margin: 4px 0;
						padding-left: 20px;
					}
				}

				.cha-comment-submit {
					margin-top: 12px;
margin-left: auto;
					&:disabled {
						opacity: 0.5;
						cursor: not-allowed;
					}
				}
			}
		}

		/* Login prompt for guests */
		.cha-comment-login-prompt {
			padding: 14px;
			text-align: center;
			border: 1px dashed #cbd5e1;
			border-radius: 10px;
			cursor: pointer;

			.cha-login-link {
				color: var(--changeloger_brand_color, #6366f1);
				font-weight: 500;
				text-decoration: none;

				&:hover {
					text-decoration: underline;
				}
			}
		}
	}

	/* ── Comments list ── */
	.cha-comments-list {
		display: flex;
		flex-direction: column;
		gap: 0;

		.cha-comments-loading {
			display: flex;
			justify-content: center;
			padding: 24px;
		}

		.cha-no-comments,
		.cha-comments-error {
			color: #94a3b8;
			font-style: italic;
			text-align: center;
			padding: 32px 16px;
			background: #f8fafc;
			border-radius: 12px;
			border: 1px dashed #e2e8f0;
		}
	}

	/* ── Single comment ── */
	.cha-comment {
		display: flex;
		flex-direction: column;
		gap: 6px;
		padding: 16px 0;
		position: relative;

		/* SVG connector line from parent to children */
		.cha-comment-connector {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			pointer-events: none;
			z-index: 0;
			overflow: visible;
		}

		/* Reply variant — just indented, no lines */
		&.cha-comment--reply {
			margin-left: 48px;
			padding: 12px 0;
		}

		.cha-comment-header {
			display: flex;
			align-items: center;
			gap: 10px;

			.cha-comment-avatar {
				width: 32px;
				height: 32px;
				border-radius: 50%;
				object-fit: cover;
				flex-shrink: 0;
			}

			.cha-comment-meta {
				display: flex;
				align-items: center;
				gap: 4px;
				flex-wrap: wrap;

				.cha-comment-author {
					font-size: 14px;
					font-weight: 600;
					color: #1e293b;
				}

				.cha-comment-date {
					font-size: 13px;
					color: #94a3b8;
					padding-left: 4px;

					&::before {
						content: '·';
						margin-right: 4px;
						color: #94a3b8;
						font-weight: 700;
					}
				}
			}
		}

		.cha-comment-body {
			font-size: 14px;
			line-height: 1.7;
			color: #374151;
			padding-left: 42px;
			word-break: break-word;

			a {
				color: var(--changeloger_brand_color, #6366f1);
				text-decoration: underline;
			}

			p {
				margin: 0 0 8px;

				&:last-child {
					margin-bottom: 0;
				}
			}

			img {
				max-width: 100%;
				height: auto;
				border-radius: 8px;
				margin: 6px 0;
			}

			ul, ol {
				margin: 4px 0;
				padding-left: 20px;
			}
		}

		.cha-comment-actions {
			padding-left: 42px;
			display: flex;
			align-items: center;
			gap: 12px;
			margin-top: 2px;

			.cha-comment-reply-btn {
				display: inline-flex;
				align-items: center;
				gap: 4px;
				font-size: 13px;
				font-weight: 400;
				color: #94a3b8;
				background: none;
				border: none;
				cursor: pointer;
				padding: 2px 0;
				box-shadow: none;
				transition: color 0.15s;

				&:hover {
					color: var(--changeloger_brand_color, #6366f1);
				}
			}
		}

		.cha-comment-children {
			display: flex;
			flex-direction: column;
			gap: 0;
		}

		/* Reply form */
		.cha-reply-form {
			margin-top: 8px;
			margin-left: 42px;

			.cha-reply-input {
				width: 100%;
				padding: 10px 14px;
				border: 1px solid #e2e8f0;
				border-radius: 10px;
				font-size: 13px;
				resize: none;
				outline: none;
				transition: border-color 0.2s;
				background: #fafbfd;

				&:focus {
					border-color: var(--changeloger_brand_color, #6366f1);
					background: #fff;
				}
			}

			.cha-reply-actions {
				display: flex;
				justify-content: flex-end;
				gap: 8px;
				margin-top: 8px;

				.cha-reply-cancel {
					background: #f1f5f9;
					color: #64748b;

					&:hover {
						background: #e2e8f0;
					}
				}

				.cha-reply-submit {
					background: var(--changeloger_brand_color, #6366f1);
					color: #fff;

					&:disabled {
						opacity: 0.5;
						cursor: not-allowed;
					}
				}
			}
		}
	}
}

/* ========================================
   Auth Modal Additions
   (complements cha-common.css)
   ======================================== */

#cha-interactions-auth-overlay .cha-auth-modal {
	width: 400px;
	max-width: 95%;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
	overflow: hidden;

	.cha-auth-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 14px 20px;
		border-bottom: 1px solid #e2e8f0;

		.cha-auth-tabs {
			display: flex;
			gap: 0;

			.cha-auth-tab {
				padding: 8px 16px;
				font-size: 14px;
				font-weight: 500;
				border: none;
				background: transparent;
				cursor: pointer;
				color: #94a3b8;
				border-bottom: 2px solid transparent;
				transition: all 0.2s;

				&.active {
					color: var(--changeloger_brand_color, #6366f1);
					border-bottom-color: var(--changeloger_brand_color, #6366f1);
				}
			}
		}

		.cha-auth-close {
			padding: 6px;
			background: none;
			border: none;
			cursor: pointer;
			color: #94a3b8;
			border-radius: 6px;
			transition: all 0.15s;

			&:hover {
				background: #f1f5f9;
				color: #1e293b;
			}
		}
	}

	.cha-auth-body {
		padding: 20px;

		.cha-auth-error {
			background: #fef2f2;
			color: #dc2626;
			padding: 10px 14px;
			border-radius: 8px;
			font-size: 13px;
			margin-bottom: 16px;
		}

		.cha-auth-form {
			display: flex;
			flex-direction: column;
			gap: 14px;

			.cha-auth-field {
				label {
					display: block;
					margin-bottom: 4px;
					font-size: 13px;
					font-weight: 500;
					color: #1e293b;
				}

				input {
					width: 100%;
					padding: 9px 12px;
					border: 1px solid #e2e8f0;
					border-radius: 8px;
					font-size: 14px;
					outline: none;
					transition: border-color 0.2s;
					box-sizing: border-box;

					&:focus {
						border-color: var(--changeloger_brand_color, #6366f1);
					}
				}
			}

			.cha-auth-submit {
				padding: 10px 20px;
				font-size: 14px;
				font-weight: 500;
				border: none;
				border-radius: 8px;
				background: var(--changeloger_brand_color, #6366f1);
				color: #fff;
				cursor: pointer;
				transition: opacity 0.2s;

				&:hover {
					opacity: 0.9;
				}
			}
		}
	}

	.cha-auth-footer {
		padding: 14px 20px;
		border-top: 1px solid #e2e8f0;
		text-align: center;
		background: #f8fafc;

		p {
			margin: 0;
			font-size: 13px;
			color: #64748b;
		}

		button {
			background: none;
			border: none;
			color: var(--changeloger_brand_color, #6366f1);
			font-weight: 500;
			cursor: pointer;
			font-size: 13px;

			&:hover {
				text-decoration: underline;
			}
		}
	}
}
