/* Dark chrome for tabs + code (matches QFChart slate look); compact spacing */
.wp-block-qfo-indicator-code.qfo-indicator-code {
	--qfo-ui-bg: #0b1120;
	--qfo-ui-bg-raised: #111827;
	--qfo-ui-border: #1e293b;
	--qfo-ui-tab-inactive: #0f172a;
	--qfo-ui-text: #e2e8f0;
	--qfo-ui-text-muted: #94a3b8;
	--qfo-code-bg: #070b14;
	margin-bottom: 1rem;
}

/* Break out of theme content width; never wider than 1500px. Default align = full. */
.wp-block-qfo-indicator-code.alignfull {
	width: min(100vw, 1500px);
	max-width: 1500px;
	margin-left: calc(50% - min(50vw, 750px));
	margin-right: calc(50% - min(50vw, 750px));
	position: relative;
	left: 0;
	box-sizing: border-box;
	padding-left: var(--wp--style--root--padding-left, 1rem);
	padding-right: var(--wp--style--root--padding-right, 1rem);
}

.wp-block-qfo-indicator-code.alignwide {
	width: min(100%, 1500px, var(--wp--style--wide-size, 1500px));
	max-width: min(1500px, var(--wp--style--wide-size, 1500px));
	margin-left: auto !important;
	margin-right: auto !important;
}

/* SEO: DOM order is chart → tabs → code; grid shows tabs → chart → code. */
.qfo-indicator-code__layout {
	display: grid;
	grid-template-areas:
		"tabs"
		"chart"
		"code";
	grid-template-rows: auto auto auto;
	border: 1px solid var(--qfo-ui-border);
	border-radius: 4px;
	padding: 0.45rem;
	background: var(--qfo-ui-bg-raised);
	align-items: start;
}

.qfo-indicator-code__layout > [data-qfo-grid="chart"] {
	grid-area: chart;
}

.qfo-indicator-code__layout > [data-qfo-grid="tabs"] {
	grid-area: tabs;
}

.qfo-indicator-code__layout > [data-qfo-grid="code"] {
	grid-area: code;
}

.qfo-indicator-code__tabs {
	display: flex;
	gap: 0;
	border-bottom: 1px solid var(--qfo-ui-border);
	margin-bottom: 0;
}

.qfo-indicator-code__tab {
	appearance: none;
	background: var(--qfo-ui-tab-inactive);
	border: 1px solid var(--qfo-ui-border);
	border-bottom: none;
	padding: 0.3rem 0.65rem;
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	cursor: pointer;
	border-radius: 4px 4px 0 0;
	margin-bottom: -1px;
	color: var(--qfo-ui-text-muted);
	line-height: 1.2;
}

.qfo-indicator-code__tab + .qfo-indicator-code__tab {
	margin-left: 2px;
}

.qfo-indicator-code__tab:hover {
	color: var(--qfo-ui-text);
	background: #131c2e;
}

.qfo-indicator-code__tab.is-active {
	background: var(--qfo-ui-bg-raised);
	color: var(--qfo-ui-text);
	border-color: var(--qfo-ui-border);
	border-bottom-color: var(--qfo-ui-bg-raised);
}

.qfo-indicator-code__panel:not(.is-active) {
	display: none;
}

.qfo-indicator-code__panel.is-active {
	display: block;
}

.qfo-indicator-chart-panel {
	position: relative;
	min-height: 380px;
}

.qfo-indicator-main-chart {
	min-height: 380px;
}

/* QFChart drawing tools: pin to chart panel so first paint isn’t clipped by overflow */
.qfo-indicator-chart-panel .qfchart-toolbar {
	position: absolute;
	z-index: 9999;
	height: 100%;
}

.qfo-indicator-loading {
	margin: 0;
	padding: 1rem;
	text-align: center;
	color: var(--qfo-ui-text-muted, #94a3b8);
	font-size: 0.875rem;
}

.qfo-indicator-loading--error {
	color: #b91c1c;
}

.qfo-indicator-code__pre {
	margin: 0;
	padding: 0;
	max-height: min(70vh, 32rem);
	overflow: auto;
	border: 1px solid var(--qfo-ui-border, #1e293b);
	border-radius: 3px;
	background: var(--qfo-code-bg, #070b14);
}

.qfo-indicator-code__syntax {
	display: block;
	box-sizing: border-box;
	width: 100%;
	min-height: 12rem;
	padding: 0.45rem 0.55rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 0.8125rem;
	line-height: 1.4;
	tab-size: 4;
	white-space: pre-wrap;
	word-break: break-word;
	color: var(--qfo-ui-text, #e2e8f0);
}

.qfo-indicator-code__syntax .qfo-ps-comment {
	color: #64748b;
	font-style: italic;
}

.qfo-indicator-code__syntax .qfo-ps-str {
	color: #86efac;
}

.qfo-indicator-code__syntax .qfo-ps-kw {
	color: #c4b5fd;
	font-weight: 500;
}

.qfo-indicator-code__syntax .qfo-ps-bi {
	color: #7dd3fc;
}

.qfo-indicator-code__syntax .qfo-ps-num {
	color: #fdba74;
}

/* Alert badge & panel (scoped, playground-style) */
.qfo-indicator-chart-panel .qfo-indicator-alert-badge {
	position: absolute;
	bottom: 12px;
	right: 12px;
	z-index: 100;
	display: flex;
	align-items: center;
	gap: 6px;
	background: rgba(251, 191, 36, 0.15);
	border: 1px solid rgba(251, 191, 36, 0.4);
	color: #fbbf24;
	padding: 6px 12px;
	border-radius: 20px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	backdrop-filter: blur(8px);
	transition: background 0.2s, transform 0.15s;
	user-select: none;
}

.qfo-indicator-chart-panel .qfo-indicator-alert-badge:hover {
	background: rgba(251, 191, 36, 0.25);
	transform: scale(1.05);
}

.qfo-indicator-alert-badge__icon {
	display: flex;
	align-items: center;
	line-height: 0;
}

.qfo-indicator-chart-panel .qfo-indicator-alert-panel {
	position: absolute;
	bottom: 48px;
	right: 12px;
	z-index: 110;
	width: min(420px, calc(100% - 24px));
	max-height: 360px;
	background: #1e293b;
	border: 1px solid #334155;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: qfo-alert-panel-in 0.15s ease-out;
}

@keyframes qfo-alert-panel-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.qfo-indicator-alert-panel__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 14px;
	background: #0f172a;
	border-bottom: 1px solid #334155;
	font-size: 13px;
	font-weight: 600;
	color: #fbbf24;
}

.qfo-indicator-alert-panel__title {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.qfo-indicator-alert-panel__close {
	background: none;
	border: none;
	color: #94a3b8;
	font-size: 18px;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
}

.qfo-indicator-alert-panel__close:hover {
	color: #f1f5f9;
}

.qfo-indicator-alert-panel__body {
	overflow-y: auto;
	flex: 1;
	padding: 0;
}

.qfo-indicator-alert-panel__empty {
	padding: 20px;
	text-align: center;
	color: #64748b;
	font-size: 13px;
	margin: 0;
}

.qfo-indicator-alert-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
}

.qfo-indicator-alert-table thead {
	position: sticky;
	top: 0;
	background: #0f172a;
}

.qfo-indicator-alert-table th {
	text-align: left;
	padding: 6px 10px;
	color: #94a3b8;
	font-weight: 600;
	border-bottom: 1px solid #334155;
	white-space: nowrap;
}

.qfo-indicator-alert-table td {
	padding: 6px 10px;
	color: #cbd5e1;
	border-bottom: 1px solid rgba(51, 65, 85, 0.4);
	vertical-align: top;
}

.qfo-indicator-alert-table tbody tr:hover {
	background: rgba(51, 65, 85, 0.3);
}

.qfo-indicator-alert-table td:first-child {
	color: #64748b;
	font-variant-numeric: tabular-nums;
	width: 32px;
}

.qfo-indicator-alert-table td:nth-child(3) {
	white-space: nowrap;
	font-family: monospace;
	font-size: 11px;
	color: #94a3b8;
}

.qfo-indicator-alert-type-alert {
	background: rgba(251, 191, 36, 0.15);
	color: #fbbf24;
	padding: 1px 6px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 600;
}

.qfo-indicator-alert-type-cond {
	background: rgba(96, 165, 250, 0.15);
	color: #60a5fa;
	padding: 1px 6px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 600;
}
