/* Cloudflare Dev Tools — admin styles. Everything uses the TCMS design tokens
   (--totalform-*) so light and dark mode both work without extra selectors. */

/* Allow sections to shrink below their content's intrinsic width so that wide
   <pre> code blocks scroll horizontally inside the section instead of forcing
   the whole layout wider than the viewport. Grid/flex children default to
   min-width: auto, which is what causes the overflow without this rule.       */
.cfdvs,
.dashboard-section.cfdvs {
	min-width: 0;
	max-width: 100%;
}

/* Frontend embed code block — theme-aware surface */

.cfdvs-embed pre {
	margin: 0.5rem 0 16px 0;
	padding: 0.75rem;
	background: oklch(var(--totalform-nearwhite) / 0.5);
	border: 1px solid oklch(var(--totalform-border-color));
	border-radius: var(--totalform-radius, 6px);
	color: oklch(var(--totalform-text-color));
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.85rem;
	max-width: 100%;
	box-sizing: border-box;
	overflow-x: auto;
}

.cfdvs-embed pre code {
	color: inherit;
	background: transparent;
}

.cfdvs-embed table {
	width: 100%;
	max-width: 100%;
	display: block;
	overflow-x: auto;
	margin: 0.5rem 0 16px;
	border-collapse: collapse;
	font-size: 0.95rem;
	color: oklch(var(--totalform-text-color));
	border: 1px solid oklch(var(--totalform-lightgray));
	border-radius: var(--totalform-radius, 6px);
}

.cfdvs-embed table thead th {
	background: oklch(var(--totalform-nearwhite) / 0.5);
	color: oklch(var(--totalform-nearblack));
	font-weight: 600;
	text-align: left;
	padding: 0.6rem 0.85rem;
	border-bottom: 1px solid oklch(var(--totalform-lightgray));
}

.cfdvs-embed table tbody td {
	padding: 0.55rem 0.85rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid oklch(var(--totalform-lightgray) / 0.5);
}

.cfdvs-embed table tbody tr:last-child td {
	border-bottom: 0;
}

.cfdvs-embed table tbody tr:nth-child(odd) {
	background: oklch(var(--totalform-purewhite, var(--totalform-white)));
}

.cfdvs-embed table tbody tr:hover {
	background: oklch(var(--totalform-accent) / 0.08);
}

.cfdvs-embed table code {
	background: oklch(var(--totalform-text-color) / 0.08);
	padding: 0.1rem 0.35rem;
	border-radius: 3px;
	font-size: 0.95em;
	white-space: nowrap;
}

.cfdvs-pill {
	display: inline-block;
	margin-left: 0.5rem;
	padding: 2px 8px;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	border-radius: 999px;
	vertical-align: middle;
	background: oklch(var(--totalform-accent) / 0.15);
	color: oklch(var(--totalform-accent));
	border: 1px solid oklch(var(--totalform-accent) / 0.4);
}

.cfdvs-note {
	margin: 0.5rem 0 0 0 !important;
	font-size: 0.85rem;
	color: oklch(var(--totalform-text-color) / 0.65);
}

.cfdvs-note code {
	background: oklch(var(--totalform-text-color) / 0.08);
	padding: 0.1rem 0.35rem;
	border-radius: 3px;
	font-size: 0.85em;
}

.cfdvs--unconfigured {
	border-left: 4px solid oklch(var(--totalform-warning));
}

/* Dashboard widget + full dashboard — layers on top of TCMS's .dashboard-section / .system-status / .status-* classes */

.cfdvs .status-badge {
	padding: 2px 8px !important;
}

.cfdvs .status-value .status-badge {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.cfdvs .status-actions {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-top: 0.75rem;
}

/* Optional wrapper for the Admin Welcome embed: keeps the widget at half-width
   so buttons stay close to the status, instead of stretching to full page width. */
.cfdvs-embed-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	align-items: start;
}

@media (max-width: 720px) {
	.cfdvs-embed-grid {
		grid-template-columns: 1fr;
	}
}


/* When the dashboard renders, give each section a bit of breathing room */
.cfdvs + .cfdvs,
.cfdvs-row + .cfdvs {
	margin-top: 1rem;
}

/* Two-up row for Development Mode + Cache sections */
.cfdvs-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	align-items: stretch;
	min-width: 0;
}

.cfdvs-row .cfdvs {
	margin-top: 0;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.cfdvs-row .cfdvs .system-status {
	display: flex;
	flex-direction: column;
	flex: 1;
}

/* Push action buttons to the bottom so Turn ON and Purge align horizontally
   even when the panels above them have different heights. */
.cfdvs-row .cfdvs .status-actions {
	margin-top: auto;
}

@media (max-width: 720px) {
	.cfdvs-row {
		grid-template-columns: 1fr;
	}
}

.cfdvs h2 {
	margin: 0 0 0.6rem 0;
}

.cfdvs .system-status > p {
	margin: 0 0 0.5rem 0;
	color: oklch(var(--totalform-text-color) / 0.8);
}

.cfdv-btn {
	flex: 1 1 auto;
	text-align: center;
	font-weight: 600;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cfdv-btn:disabled {
	opacity: 0.6;
	cursor: wait;
}

/* "Turn ON" (dev mode is currently off) — green accent, matches status-success */
.cfdv-btn--toggle.cfdv-btn--off {
	background: oklch(var(--totalform-success) / 0.12);
	border-color: oklch(var(--totalform-success) / 0.5);
	color: oklch(var(--totalform-success));
}
.cfdv-btn--toggle.cfdv-btn--off:hover {
	background: oklch(var(--totalform-success));
	border-color: oklch(var(--totalform-success));
	color: oklch(var(--totalform-white));
}

/* "Turn OFF" (dev mode is currently on) — warning accent, matches status-warning */
.cfdv-btn--toggle.cfdv-btn--on {
	background: oklch(var(--totalform-warning) / 0.12);
	border-color: oklch(var(--totalform-warning) / 0.5);
	color: oklch(var(--totalform-warning));
}
.cfdv-btn--toggle.cfdv-btn--on:hover {
	background: oklch(var(--totalform-warning));
	border-color: oklch(var(--totalform-warning));
	color: oklch(var(--totalform-white));
}

/* Purge — warning accent (matches the Turn OFF toggle) */
.cfdv-btn--purge {
	background: oklch(var(--totalform-warning) / 0.12)!important;
	border-color: oklch(var(--totalform-warning) / 0.5)!important;
	color: oklch(var(--totalform-warning))!important;
}
.cfdv-btn--purge:hover {
	background: #f2a945!important;
	border-color: #f2a945!important;
	color: oklch(var(--totalform-white))!important;
}

.cfdv-widget-msg {
	padding: 0.4rem 0.6rem;
	border-radius: var(--totalform-radius, 4px);
	font-size: 0.85rem;
}

.cfdv-widget-msg--success {
	background: oklch(var(--totalform-success) / 0.1);
	color: oklch(var(--totalform-success));
}

.cfdv-widget-msg--error {
	background: oklch(var(--totalform-danger) / 0.1);
	color: oklch(var(--totalform-danger));
}

.cfdv-widget-msg--info {
	background: oklch(var(--totalform-info) / 0.1);
	color: oklch(var(--totalform-info));
}

/* Diagnostics page — theme-aware via TCMS design tokens */

.cfdv-diag {
	max-width: 960px;
}

.cfdv-diag__intro {
	color: oklch(var(--totalform-text-color) / 0.85);
	margin-bottom: 1rem;
}

.cfdv-diag__actions {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.cfdv-diag__run-all {
	padding: 0.55rem 1.1rem;
	border-radius: var(--totalform-radius, 6px);
	border: 1px solid oklch(var(--totalform-accent));
	background: oklch(var(--totalform-accent));
	color: oklch(var(--totalform-white));
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.cfdv-diag__run-all:hover:not(:disabled) {
	filter: brightness(1.1);
}

.cfdv-diag__run-all:disabled {
	opacity: 0.6;
	cursor: wait;
}

.cfdv-diag__settings-link {
	color: oklch(var(--totalform-accent));
	font-weight: 600;
}

.cfdv-diag__routecheck {
	background: oklch(var(--totalform-warning) / 0.15);
	border: 1px solid oklch(var(--totalform-warning) / 0.5);
	color: oklch(var(--totalform-text-color));
	padding: 1rem 1.2rem;
	border-radius: var(--totalform-radius, 8px);
	margin-bottom: 1.5rem;
	line-height: 1.5;
}

.cfdv-diag__routecheck code {
	background: oklch(var(--totalform-text-color) / 0.1);
	padding: 0.1rem 0.35rem;
	border-radius: 3px;
	font-size: 0.9em;
}

.cfdv-diag__routecheck ol {
	margin: 0.6rem 0 0 0;
	padding-left: 1.4rem;
}

.cfdv-diag__routecheck li {
	margin-bottom: 0.35rem;
}

.cfdv-diag__probes {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.cfdv-diag__probe {
	border: 1px solid oklch(var(--totalform-border-color));
	border-radius: var(--totalform-radius, 8px);
	padding: 1rem;
	background: oklch(var(--totalform-white));
	color: oklch(var(--totalform-text-color));
}

.cfdv-diag__probe header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.35rem;
}

.cfdv-diag__probe header h3 {
	margin: 0;
	font-size: 1rem;
	color: oklch(var(--totalform-text-color));
}

.cfdv-diag__run {
	padding: 0.35rem 0.85rem;
	border-radius: var(--totalform-radius, 4px);
	border: 1px solid oklch(var(--totalform-border-color));
	background: oklch(var(--totalform-white));
	color: oklch(var(--totalform-text-color));
	font: inherit;
	font-size: 0.85rem;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cfdv-diag__run:hover:not(:disabled) {
	background: oklch(var(--totalform-accent));
	border-color: oklch(var(--totalform-accent));
	color: oklch(var(--totalform-white));
}

.cfdv-diag__run:disabled {
	opacity: 0.6;
	cursor: wait;
}

.cfdv-diag__desc {
	margin: 0 0 0.6rem 0;
	color: oklch(var(--totalform-text-color) / 0.8);
	font-size: 0.9rem;
}

.cfdv-diag__desc code {
	background: oklch(var(--totalform-text-color) / 0.08);
	padding: 0.1rem 0.35rem;
	border-radius: 3px;
	font-size: 0.85em;
}

/* Output blocks stay intentionally dark in both themes — they're for code/JSON */

.cfdv-diag__output {
	margin: 0;
	padding: 0.75rem;
	background: #0f172a;
	color: #d1d5db;
	border-radius: var(--totalform-radius, 6px);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.8rem;
	line-height: 1.45;
	max-height: 400px;
	overflow: auto;
	white-space: pre-wrap;
	word-break: break-word;
}

.cfdv-diag__output--running {
	background: #1e293b;
	color: #93c5fd;
}

.cfdv-diag__output--ok {
	background: #052e16;
	color: #bbf7d0;
	border-left: 4px solid #22c55e;
}

.cfdv-diag__output--fail {
	background: #450a0a;
	color: #fecaca;
	border-left: 4px solid #ef4444;
}

