/* ═══════════════════════════════════════════════════════════════
   Code Highlighter Widget – Styles
   ═══════════════════════════════════════════════════════════════ */

.rd-ch {
	position: relative;
	overflow: hidden;
	font-family: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace;
	box-sizing: border-box;
}

.rd-ch *, .rd-ch *::before, .rd-ch *::after { box-sizing: border-box; }

/* Empty state */
.rd-ch--empty {
	padding: 40px;
	text-align: center;
	color: #94a3b8;
	font-size: 14px;
	border: 2px dashed #334155;
	border-radius: 12px;
}

/* ─── Header ───────────────────────────────────────────────── */

.rd-ch__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	border-bottom: 1px solid #334155;
	padding: 12px 16px;
	background: #0f172a;
}

.rd-ch__header-left,
.rd-ch__header-right {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.rd-ch__header-left { min-width: 0; flex: 1; }
.rd-ch__header-right { flex-shrink: 0; }

/* macOS dots */
.rd-ch__macos-dots {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}

.rd-ch__dot {
	display: block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
}

.rd-ch__dot--red    { background: #ff5f56; }
.rd-ch__dot--yellow { background: #ffbd2e; }
.rd-ch__dot--green  { background: #27c93f; }

/* Filename */
.rd-ch__filename {
	font-size: 13px;
	color: #94a3b8;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Language badge */
.rd-ch__lang-badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	background: rgba(255,255,255,0.08);
	color: #cbd5e1;
}

/* ─── Body ─────────────────────────────────────────────────── */

.rd-ch__body { padding: 0; }

.rd-ch__title {
	margin: 0;
	padding: 16px 20px 0;
	font-size: 15px;
	font-weight: 600;
	color: #f1f5f9;
}

.rd-ch__desc {
	margin: 0;
	padding: 8px 20px 0;
	font-size: 13px;
	color: #94a3b8;
	line-height: 1.5;
}

/* ─── Code Container ───────────────────────────────────────── */

.rd-ch__code-container {
	display: flex;
	overflow-y: auto;
	align-items: flex-start;
}

/* Line numbers */
.rd-ch__line-numbers {
	flex-shrink: 0;
	width: 50px;
	padding: 16px 8px;
	text-align: right;
	background: rgba(0,0,0,0.15);
	border-right: 1px solid rgba(255,255,255,0.06);
	overflow: hidden;
	user-select: none;
}

.rd-ch__line-num {
	display: block;
	font-size: 13px;
	line-height: 1.6;
	color: #64748b;
	font-variant-numeric: tabular-nums;
}

.rd-ch__line-num--highlighted {
	color: #3b82f6;
	font-weight: 600;
}

/* Code wrapper */
.rd-ch__code-wrapper {
	position: relative;
	flex: 1;
	padding: 16px 20px;
	background: #1e293b;
}

.rd-ch__code {
	margin: 0;
	padding: 0;
	font-size: 14px;
	line-height: 1.6;
	font-family: inherit;
	white-space: pre;
	tab-size: 4;
	-moz-tab-size: 4;
}

.rd-ch__code code {
	font-family: inherit;
	background: none;
	padding: 0;
}

.rd-ch__line {
	min-height: 1.6em;
	padding-left: 4px;
	padding-right: 4px;
	margin-left: -4px;
	margin-right: -4px;
	border-radius: 3px;
}

.rd-ch__line--highlighted {
	position: relative;
	background: rgba(59, 130, 246, 0.12);
}

.rd-ch__line--highlighted::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: #3b82f6;
	border-radius: 0 2px 2px 0;
}

/* Word wrap */
.rd-ch--wrap .rd-ch__code,
.rd-ch--wrap .rd-ch__code code,
.rd-ch--wrap .rd-ch__line {
	white-space: pre-wrap;
	word-break: break-word;
}

/* ─── Copy Button ──────────────────────────────────────────── */

.rd-ch__copy-btn {
	appearance: none;
	border: none;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
	font-weight: 500;
	padding: 6px 14px;
	border-radius: 6px;
	background: rgba(255,255,255,0.1);
	color: #94a3b8;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.rd-ch__copy-btn:hover {
	background: rgba(255,255,255,0.2);
	color: #f8fafc;
}

.rd-ch__copy-btn--success {
	background: rgba(34, 197, 94, 0.15) !important;
}

.rd-ch__copy-btn--top_right,
.rd-ch__copy-btn--bottom_right {
	position: absolute;
	right: 12px;
	z-index: 2;
}

.rd-ch__copy-btn--top_right { top: 12px; }
.rd-ch__copy-btn--bottom_right { bottom: 12px; }

/* ─── Scrollbar ────────────────────────────────────────────── */

.rd-ch__code-container::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.rd-ch__code-container::-webkit-scrollbar-track {
	background: transparent;
}

.rd-ch__code-container::-webkit-scrollbar-thumb {
	background: #475569;
	border-radius: 4px;
}

.rd-ch__code-container::-webkit-scrollbar-thumb:hover {
	background: #64748b;
}

/* Firefox */
.rd-ch__code-container {
	scrollbar-width: thin;
	scrollbar-color: #475569 transparent;
}

/* ─── Themes ───────────────────────────────────────────────── */

/* Light */
.rd-ch--theme-light { background: #ffffff; }
.rd-ch--theme-light .rd-ch__header { background: #f8fafc; border-bottom-color: #e2e8f0; }
.rd-ch--theme-light .rd-ch__filename { color: #64748b; }
.rd-ch--theme-light .rd-ch__lang-badge { background: rgba(0,0,0,0.06); color: #475569; }
.rd-ch--theme-light .rd-ch__code-wrapper { background: #ffffff; }
.rd-ch--theme-light .rd-ch__code { color: #1e293b; }
.rd-ch--theme-light .rd-ch__line-num { color: #94a3b8; }
.rd-ch--theme-light .rd-ch__title { color: #0f172a; }
.rd-ch--theme-light .rd-ch__desc { color: #64748b; }
.rd-ch--theme-light .rd-ch__copy-btn { background: rgba(0,0,0,0.06); color: #64748b; }
.rd-ch--theme-light .rd-ch__copy-btn:hover { background: rgba(0,0,0,0.1); color: #1e293b; }

/* GitHub */
.rd-ch--theme-github { background: #f6f8fa; }
.rd-ch--theme-github .rd-ch__header { background: #f6f8fa; border-bottom-color: #d0d7de; }
.rd-ch--theme-github .rd-ch__code-wrapper { background: #ffffff; }
.rd-ch--theme-github .rd-ch__code { color: #24292f; }

/* GitHub Dark */
.rd-ch--theme-github-dark { background: #161b22; }
.rd-ch--theme-github-dark .rd-ch__header { background: #0d1117; border-bottom-color: #30363d; }
.rd-ch--theme-github-dark .rd-ch__code-wrapper { background: #161b22; }
.rd-ch--theme-github-dark .rd-ch__code { color: #c9d1d9; }

/* VS Code */
.rd-ch--theme-vscode { background: #1e1e1e; }
.rd-ch--theme-vscode .rd-ch__header { background: #252526; border-bottom-color: #3c3c3c; }
.rd-ch--theme-vscode .rd-ch__code-wrapper { background: #1e1e1e; }
.rd-ch--theme-vscode .rd-ch__code { color: #d4d4d4; }

/* Dracula */
.rd-ch--theme-dracula { background: #282a36; }
.rd-ch--theme-dracula .rd-ch__header { background: #282a36; border-bottom-color: #44475a; }
.rd-ch--theme-dracula .rd-ch__code-wrapper { background: #282a36; }
.rd-ch--theme-dracula .rd-ch__code { color: #f8f8f2; }

/* Monokai */
.rd-ch--theme-monokai { background: #272822; }
.rd-ch--theme-monokai .rd-ch__header { background: #272822; border-bottom-color: #49483e; }
.rd-ch--theme-monokai .rd-ch__code-wrapper { background: #272822; }
.rd-ch--theme-monokai .rd-ch__code { color: #f8f8f2; }

/* One Dark */
.rd-ch--theme-one-dark { background: #282c34; }
.rd-ch--theme-one-dark .rd-ch__header { background: #21252b; border-bottom-color: #3e4451; }
.rd-ch--theme-one-dark .rd-ch__code-wrapper { background: #282c34; }
.rd-ch--theme-one-dark .rd-ch__code { color: #abb2bf; }

/* Nord */
.rd-ch--theme-nord { background: #2e3440; }
.rd-ch--theme-nord .rd-ch__header { background: #2e3440; border-bottom-color: #4c566a; }
.rd-ch--theme-nord .rd-ch__code-wrapper { background: #2e3440; }
.rd-ch--theme-nord .rd-ch__code { color: #d8dee9; }

/* Solarized Dark */
.rd-ch--theme-solarized-dark { background: #002b36; }
.rd-ch--theme-solarized-dark .rd-ch__header { background: #073642; border-bottom-color: #586e75; }
.rd-ch--theme-solarized-dark .rd-ch__code-wrapper { background: #002b36; }
.rd-ch--theme-solarized-dark .rd-ch__code { color: #839496; }

/* Solarized Light */
.rd-ch--theme-solarized-light { background: #fdf6e3; }
.rd-ch--theme-solarized-light .rd-ch__header { background: #eee8d5; border-bottom-color: #93a1a1; }
.rd-ch--theme-solarized-light .rd-ch__code-wrapper { background: #fdf6e3; }
.rd-ch--theme-solarized-light .rd-ch__code { color: #657b83; }

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

@media (max-width: 767px) {
	.rd-ch__header { padding: 10px 12px; gap: 8px; }
	.rd-ch__filename { font-size: 12px; }
	.rd-ch__lang-badge { font-size: 10px; padding: 3px 8px; }
	.rd-ch__code-wrapper { padding: 12px 14px; }
	.rd-ch__code { font-size: 12px; }
	.rd-ch__line-numbers { width: 40px; padding: 12px 6px; }
	.rd-ch__line-num { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
	.rd-ch__copy-btn { transition: none; }
}
