/**
 * Advanced Comment Editor Styles — Phase 6: Responsive & Performance
 *
 * @package PandaTheme
 */

/* ─── Editor Wrapper ─────────────────────────────────────────────────────── */

.dp-comment-editor-wrapper {
	margin-bottom: 15px;
	position: relative;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	overflow: visible;
	background: #fff;
}

.dp-comment-editor-wrapper .wp-editor-container {
	border: 0 !important;
}

.dp-comment-editor-wrapper .wp-editor-area {
	border: 0 !important;
	box-shadow: none !important;
	border-radius: 0 !important;
	padding: 10px !important;
}

/* Make TinyMCE toolbar wrap gracefully on narrow screens */
.dp-comment-editor-wrapper .mce-toolbar .mce-btn-group {
	flex-wrap: wrap;
}

/* ─── Comment Content Render ─────────────────────────────────────────────── */

.comment-content {
	word-wrap: break-word;
	overflow-wrap: break-word;
	line-height: 1.7;
}

.comment-content p {
	margin-bottom: 0.85rem;
}

.comment-content p:last-child {
	margin-bottom: 0;
}

.comment-content ul,
.comment-content ol {
	padding-left: 20px;
	margin-bottom: 0.85rem;
}

.comment-content li {
	margin-bottom: 0.25rem;
}

.comment-content a {
	color: #0d6efd;
	text-decoration: underline;
	word-break: break-all;
}

.comment-content a:hover {
	color: #0a58ca;
}

/* ─── Rendered Emoji In Comment ──────────────────────────────────────────── */

.dp-comment-emoji {
	width: 32px;
	height: auto;
	vertical-align: middle;
	display: inline-block;
	margin: 0 3px;
	/* Prevent layout shift while loading */
	aspect-ratio: 1;
}

/* ─── Emoji Trigger Bar ──────────────────────────────────────────────────── */

.dp-emoji-section-wrapper {
	padding: 8px 12px;
	border-top: 1px solid #f1f5f9;
	background: #f8fafc;
	display: flex;
	align-items: center;
	gap: 8px;
	position: relative;
	/* Ensures the absolute panel is positioned relative to this bar */
}

.dp-emoji-trigger-btn {
	border-radius: 6px;
	font-weight: 500;
	padding: 5px 12px;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	border-color: #cbd5e1;
	color: #475569;
	/* Touch-friendly minimum target */
	min-height: 36px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.dp-emoji-trigger-btn:hover,
.dp-emoji-trigger-btn:focus-visible {
	background-color: #e2e8f0;
	border-color: #94a3b8;
	color: #0f172a;
	outline: none;
}

/* ─── Emoji Panel Popup ──────────────────────────────────────────────────── */

.dp-emoji-panel {
	position: absolute;
	bottom: calc(100% + 6px);
	left: 0;
	width: 340px;
	max-width: calc(100vw - 24px);
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	box-shadow:
		0 20px 25px -5px rgba(0, 0, 0, 0.1),
		0 10px 10px -5px rgba(0, 0, 0, 0.04);
	z-index: 9999;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	/* Smooth show/hide transition */
	transform-origin: bottom left;
	animation: dp-panel-fadein 0.15s ease;
}

@keyframes dp-panel-fadein {
	from {
		opacity: 0;
		transform: translateY(6px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* ─── Emoji Tabs ─────────────────────────────────────────────────────────── */

.dp-emoji-tabs {
	display: flex;
	background: #f1f5f9;
	border-bottom: 1px solid #e2e8f0;
	overflow-x: auto;
	white-space: nowrap;
	/* Smooth momentum scroll on iOS */
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	scrollbar-width: none;
}

.dp-emoji-tabs::-webkit-scrollbar {
	display: none;
}

.dp-emoji-tab-item {
	padding: 9px 16px;
	font-size: 13px;
	font-weight: 600;
	color: #64748b;
	border: 0;
	background: transparent;
	cursor: pointer;
	border-bottom: 2px solid transparent;
	outline: none;
	transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
	flex-shrink: 0;
	/* Touch-friendly tap target */
	min-height: 38px;
	-webkit-tap-highlight-color: transparent;
}

.dp-emoji-tab-item:hover {
	color: #1e293b;
	background: #e8edf2;
}

.dp-emoji-tab-item:focus-visible {
	outline: 2px solid #0284c7;
	outline-offset: -2px;
}

.dp-emoji-tab-item.active {
	color: #0284c7;
	border-bottom-color: #0284c7;
	background: #ffffff;
}

/* ─── Emoji Grid ─────────────────────────────────────────────────────────── */

.dp-emoji-items {
	padding: 12px;
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 8px;
	max-height: 196px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e1 transparent;
}

.dp-emoji-items::-webkit-scrollbar {
	width: 4px;
}

.dp-emoji-items::-webkit-scrollbar-track {
	background: transparent;
}

.dp-emoji-items::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 99px;
}

.dp-emoji-item-pic {
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	cursor: pointer;
	padding: 3px;
	border-radius: 6px;
	transition: transform 0.12s ease, background-color 0.12s ease;
	display: block;
	-webkit-tap-highlight-color: transparent;
}

.dp-emoji-item-pic:hover {
	transform: scale(1.2);
	background-color: #f1f5f9;
}

.dp-emoji-item-pic:active {
	transform: scale(0.95);
}

/* ─── Empty / Loading / Error States ────────────────────────────────────── */

.dp-emoji-loading,
.dp-emoji-empty,
.dp-emoji-error {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 20px 12px;
	font-size: 13px;
	grid-column: 1 / -1;
}

.dp-emoji-loading {
	color: #64748b;
}

.dp-emoji-empty {
	color: #94a3b8;
	font-style: italic;
}

.dp-emoji-error {
	color: #ef4444;
}

/* ─── Mobile Breakpoint ≤ 480px ──────────────────────────────────────────── */

@media (max-width: 480px) {
	/* Panel spans full width at bottom of section wrapper on small screens */
	.dp-emoji-panel {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-width: 100%;
		border-radius: 14px 14px 0 0;
		box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
		transform-origin: bottom center;
	}

	.dp-emoji-items {
		grid-template-columns: repeat(6, 1fr);
		max-height: 220px;
		padding: 14px;
		gap: 10px;
	}

	.dp-emoji-tab-item {
		padding: 10px 14px;
		font-size: 12px;
	}

	/* Emoji in rendered comments slightly smaller on mobile */
	.dp-comment-emoji {
		width: 26px;
	}

	/* Trigger button: icon-only on very small screens */
	.dp-emoji-trigger-btn .dp-trigger-label {
		display: none;
	}
}

/* ─── Tablet Breakpoint 481px – 768px ───────────────────────────────────── */

@media (min-width: 481px) and (max-width: 768px) {
	.dp-emoji-panel {
		width: 300px;
	}

	.dp-emoji-items {
		grid-template-columns: repeat(6, 1fr);
	}
}

/* ─── Mobile Overlay Backdrop ────────────────────────────────────────────── */

.dp-emoji-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 9998;
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.dp-emoji-overlay.active {
	display: block;
}

/* Prevent body scroll when emoji panel is open on mobile */
body.dp-emoji-panel-active {
	overflow: hidden;
	touch-action: none;
}

