/* TFC Smart Edit: the quiet footer button and the edit panel. Modal, toolbar, prompts and hover labels live in a shadow root (editor.js). */
button#tfc-se-open.tfc-se-open {
	position: fixed;
	right: 12px;
	bottom: 12px;
	z-index: 99990;
	margin: 0;
	padding: 4px 10px;
	font: 12px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	letter-spacing: 0;
	text-transform: none;
	color: #6b7280;
	background: rgba(255, 255, 255, 0.85);
	border: 1px solid #d1d5db;
	border-radius: 6px;
	box-shadow: none;
	opacity: 0.65;
	cursor: pointer;
}

button#tfc-se-open.tfc-se-open:hover,
button#tfc-se-open.tfc-se-open:focus-visible {
	opacity: 1;
	color: #111827;
	background: #fff;
}

button#tfc-se-open.tfc-se-open:focus-visible {
	outline: 2px solid #1d4ed8;
	outline-offset: 2px;
}

button#tfc-se-open.tfc-se-open[hidden],
#tfc-se-root[hidden] {
	display: none !important;
}

/* Desktop only, even if script fails to toggle. */
@media (max-width: 1024px) {
	button#tfc-se-open.tfc-se-open {
		display: none !important;
	}
}

/*
 * Edit panel: a right-hand drawer in the LIGHT DOM (TinyMCE does not work inside shadow DOM), so it must defend itself
 * against the Elementor theme. Every element we create carries the class .tfc-se-p and is reset with `all: initial`,
 * then given explicit fonts, colours and sizes, so nothing is inherited from the site. TinyMCE's own markup (inside
 * .tfc-se-p-editor) is deliberately NOT reset: its stylesheet needs to apply untouched.
 * z-index 65000: above sticky headers, below TinyMCE's floating menus (65535+), the link dialog and the media modal.
 */
#tfc-se-panel {
	all: initial;
	box-sizing: border-box;
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 65000;
	display: flex;
	flex-direction: column;
	width: min(420px, 100vw);
	background: #fff;
	color: #111827;
	border-left: 1px solid #9ca3af;
	box-shadow: -8px 0 30px rgba(0, 0, 0, 0.25);
	font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	text-align: left;
}

body.admin-bar #tfc-se-panel {
	top: 32px; /* The front-end admin bar is fixed and sits above the drawer. */
}

#tfc-se-panel[hidden] {
	display: none !important;
}

#tfc-se-panel .tfc-se-p {
	all: initial;
	box-sizing: border-box;
	font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: #111827;
}

#tfc-se-panel .tfc-se-p-head {
	display: block;
	padding: 14px 16px;
	border-bottom: 1px solid #e5e7eb;
}

#tfc-se-panel .tfc-se-p-title {
	display: block;
	font-size: 18px;
	font-weight: 600;
}

#tfc-se-panel .tfc-se-p-title:focus {
	outline: 2px solid #1d4ed8;
	outline-offset: 2px;
}

#tfc-se-panel .tfc-se-p-body {
	display: block;
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 12px 16px;
}

#tfc-se-panel .tfc-se-p-field {
	display: block;
	margin: 0 0 14px;
}

#tfc-se-panel .tfc-se-p-label,
#tfc-se-panel .tfc-se-p-legend {
	display: block;
	margin: 0 0 4px;
	font-weight: 600;
}

#tfc-se-panel .tfc-se-p-input {
	display: block;
	width: 100%;
	padding: 8px 10px;
	background: #fff;
	color: #111827;
	border: 1px solid #6b7280;
	border-radius: 6px;
	font-size: 14px;
	line-height: 1.4;
}

#tfc-se-panel textarea.tfc-se-p-input {
	min-height: 84px;
	resize: vertical;
}

#tfc-se-panel .tfc-se-p-input:focus {
	outline: 2px solid #1d4ed8;
	outline-offset: 1px;
}

#tfc-se-panel .tfc-se-p-input[aria-invalid="true"] {
	border-color: #b91c1c;
}

#tfc-se-panel .tfc-se-p-input[readonly] {
	background: #f3f4f6;
}

#tfc-se-panel .tfc-se-p-checklabel {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 6px 0 0;
	font-size: 13px;
}

#tfc-se-panel .tfc-se-p-check {
	display: inline-block;
	appearance: auto;
	-webkit-appearance: checkbox;
	width: 16px;
	height: 16px;
	margin: 0;
	flex: 0 0 auto;
}

#tfc-se-panel .tfc-se-p-err {
	display: block;
	margin: 4px 0 0;
	color: #b91c1c;
	font-size: 13px;
}

#tfc-se-panel .tfc-se-p-err[hidden] {
	display: none;
}

#tfc-se-panel .tfc-se-p-img {
	display: block;
	max-width: 100%;
	max-height: 160px;
	margin: 0 0 8px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	object-fit: contain;
	background: #f3f4f6;
}

#tfc-se-panel .tfc-se-p-img[hidden] {
	display: none;
}

#tfc-se-panel .tfc-se-p-imgrow {
	display: flex;
	align-items: center;
	gap: 10px;
}

#tfc-se-panel .tfc-se-p-imgname {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: #4b5563;
	font-size: 13px;
}

#tfc-se-panel .tfc-se-p-set {
	display: block;
	margin: 0 0 14px;
	padding: 0;
	border: 0;
}

#tfc-se-panel .tfc-se-p-item {
	display: block;
	margin: 0 0 8px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: #f9fafb;
}

#tfc-se-panel .tfc-se-p-summary {
	display: list-item;
	list-style: disclosure-closed inside;
	padding: 9px 10px;
	font-weight: 600;
	cursor: pointer;
}

#tfc-se-panel .tfc-se-p-item[open] > .tfc-se-p-summary {
	list-style-type: disclosure-open;
	border-bottom: 1px solid #e5e7eb;
}

#tfc-se-panel .tfc-se-p-item > .tfc-se-p-field {
	margin: 10px;
}

#tfc-se-panel .tfc-se-p-note {
	display: block;
	color: #4b5563;
}

#tfc-se-panel .tfc-se-p-msg {
	display: block;
	padding: 0 16px;
	min-height: 0;
	font-size: 13px;
}

#tfc-se-panel .tfc-se-p-msg:not(:empty) {
	padding-top: 8px;
	padding-bottom: 8px;
	border-top: 1px solid #e5e7eb;
}

#tfc-se-panel .tfc-se-p-msg[data-kind="error"] {
	color: #b91c1c;
}

#tfc-se-panel .tfc-se-p-msg[data-kind="ok"] {
	color: #065f46;
}

#tfc-se-panel .tfc-se-p-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 16px 72px; /* Bottom room keeps Save clear of the floating toolbar. */
	border-top: 1px solid #e5e7eb;
}

#tfc-se-panel .tfc-se-p-btn {
	display: inline-block;
	padding: 8px 14px;
	background: #fff;
	color: #111827;
	border: 1px solid #6b7280;
	border-radius: 6px;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
}

#tfc-se-panel .tfc-se-p-btn:hover {
	background: #f3f4f6;
}

#tfc-se-panel .tfc-se-p-btn:focus-visible {
	outline: 2px solid #1d4ed8;
	outline-offset: 2px;
}

#tfc-se-panel .tfc-se-p-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

#tfc-se-panel .tfc-se-p-btn.tfc-se-p-primary {
	background: #1d4ed8;
	border-color: #1d4ed8;
	color: #fff;
}

#tfc-se-panel .tfc-se-p-editor {
	display: block;
}

/* Desktop only, even if script fails to toggle. */
@media (max-width: 1024px) {
	#tfc-se-panel {
		display: none !important;
	}
}
