/**
 * FlowCanvas Diagrams - Frontend & Shared Node Canvas Styles
 * Zero external image dependencies, pure CSS radial-gradient dot-grid & SVG vector overlay.
 */

.fc-diagram-figure {
	position: relative;
	margin: 0;
	padding: 0;
	width: 100%;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
}

.fc-diagram-figure *,
.fc-diagram-figure *::before,
.fc-diagram-figure *::after {
	box-sizing: border-box;
}

/* Screenreader & SEO Only Logical Flow Summary */
.fc-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Responsive Scroll / Touch Wrapper (CLS = 0) */
.fc-canvas-scroll {
	position: relative;
	width: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	/* Kein Rahmen, keine Abstände */
	border: 0;
	border-radius: 0;
	box-shadow: none;
	/* Auf der Website immer transparent: das Diagramm übernimmt den Hintergrund der Seite/Spalte */
	background-color: transparent;
}

/* Auf der Website ohne Hintergrund und ohne Punkteraster – auch die Bühne ist durchsichtig */
.fc-canvas-scroll .fc-canvas-stage,
.fc-canvas-scroll .fc-canvas-stage.fc-has-grid {
	background: transparent;
}

/*
 * Sizer: reserves exactly the (scaled) space of the canvas so the page never jumps (CLS = 0).
 * Fixed mode: native canvas size, container scrolls horizontally.
 * Fit mode:   shrinks with the column via aspect-ratio; frontend.js scales the stage to match.
 */
.fc-canvas-sizer {
	position: relative;
	margin-left: auto;
	margin-right: auto;
	width: var(--fc-canvas-w, 1060px);
	height: var(--fc-canvas-h, 440px);
	overflow: hidden;
}

.fc-diagram-figure.is-fit .fc-canvas-sizer {
	width: 100%;
	max-width: var(--fc-canvas-w, 1060px);
	height: auto;
	aspect-ratio: var(--fc-ratio, 1060 / 440);
}

/* Once JS has measured, it sets explicit px sizes (needed for zoom > fit and min-scale scrolling) */
.fc-diagram-figure.fc-ready .fc-canvas-sizer {
	max-width: none;
	aspect-ratio: auto;
}

.fc-canvas-sizer > .fc-canvas-stage {
	position: absolute;
	top: 0;
	left: 0;
}


/* Inner Canvas Stage with Pure CSS Radial-Gradient Dot-Grid */
.fc-canvas-stage {
	position: relative;
	width: var(--fc-canvas-w, 1060px);
	height: var(--fc-canvas-h, 440px);
	min-width: var(--fc-canvas-w, 1060px);
	min-height: var(--fc-canvas-h, 440px);
	background-color: var(--fc-bg-color, #f8fafc);
	transform-origin: 0 0;
	user-select: none;
}

.fc-canvas-stage.fc-has-grid {
	background-image: radial-gradient(var(--fc-dot-color, #cbd5e1) 1.25px, transparent 1.25px);
	background-size: var(--fc-grid-size, 20px) var(--fc-grid-size, 20px);
	background-position: 0 0;
}

/* SVG Vector Connections Overlay */
.fc-connections-svg {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 1;
	overflow: visible;
}

.fc-edge-path {
	fill: none;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.fc-edge-path.is-dashed {
	stroke-dasharray: 6 6;
}

.fc-edge-path.is-animated {
	stroke-dasharray: 8 6;
	animation: fcFlowDash 1.1s linear infinite;
}

@keyframes fcFlowDash {
	to {
		stroke-dashoffset: -28;
	}
}

/* Edge Floating Badges Layer */
.fc-edge-badges-layer {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 3;
}

/* Badges / Status Pills */
/* Angelehnt an die VDI-/RITTEC-Badges (.vdi-badge): eckig, Versalien, feine Kontur */
.fc-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	box-sizing: border-box;
	padding: 7px 11px 6px 11px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border-radius: 3px;
	white-space: nowrap;
	background-color: #f8fafc;
	color: #0f766e;
	border: 1px solid rgba(15, 23, 42, 0.18); /* ≈ #cbd5e1 auf hellem Grund */
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
	transition: all 0.2s ease;
}

/* Dunkle Badges: Kontur in Textfarbe (wie .style-dark .vdi-badge) */
.fc-badge.is-dark {
	border-color: rgba(127, 227, 204, 0.4);
	border-color: color-mix(in srgb, currentColor 40%, transparent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.fc-badge .fc-badge-icon {
	margin-top: -1px;
}

.fc-edge-badge {
	position: absolute;
	transform: translate(-50%, -50%);
	z-index: 4;
}

.fc-node-badge {
	position: absolute;
	z-index: 4;
}

.fc-node-badge.fc-pos-top-left {
	top: -31px;
	left: 0;
}

.fc-node-badge.fc-pos-top-right {
	top: -31px;
	right: 0;
}

.fc-node-badge.fc-pos-bottom-left {
	bottom: -31px;
	left: 0;
}

/* Nodes Layer & Cards */
.fc-nodes-layer {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 2;
}

.fc-node-card {
	position: absolute;
	display: flex;
	align-items: center;
	min-height: 68px;
	padding: 12px 14px;
	background-color: #ffffff;
	border: 1.5px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
	transition: box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.fc-node-card:hover {
	box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.fc-node-inner {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-width: 0;
}

.fc-node-multiport .fc-node-inner {
	padding-right: 36px;
}

/* Left Icon Container */
.fc-node-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-width: 40px;
	border-radius: 10px;
	flex-shrink: 0;
}

.fc-node-icon svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* Uploaded icons (FlowCanvas → Icons) */
.fc-node-icon.has-media-icon {
	padding: 3px;
	box-sizing: border-box;
}

.fc-node-icon .fc-node-icon-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	margin: 0;
	border: 0;
	box-shadow: none;
}

/* Icons inside badges */
.fc-badge-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.fc-badge-icon svg,
.fc-badge-icon .fc-node-icon-img {
	display: block;
	width: 13px;
	height: 13px;
	object-fit: contain;
}

.fc-badge-icon.has-media-icon,
.fc-badge-icon.has-media-icon .fc-node-icon-img {
	width: 16px;
	height: 16px;
}

.fc-badge-icon .dashicons {
	font-size: 13px;
	width: 13px;
	height: 13px;
}

.fc-node-icon .dashicons {
	font-size: 20px;
	width: 20px;
	height: 20px;
}

/* Node Typography */
.fc-node-content {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.fc-node-title {
	margin: 0 !important;
	padding: 0 !important;
	font-size: 16px !important;
	font-weight: 600 !important;
	line-height: 1.25 !important;
	color: #0f172a !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fc-node-subtitle {
	margin: 3px 0 0 0 !important;
	padding: 0 !important;
	font-size: 13.5px !important;
	font-weight: 400 !important;
	line-height: 1.35 !important;
	color: #64748b !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Input & Output Anchor Pins (Sockets) */
.fc-port {
	display: block;
	width: 10px;
	height: 10px;
	background-color: #ffffff;
	border: 2px solid #94a3b8;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
	transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.fc-port-in {
	position: absolute;
	left: -6px;
	top: 50%;
	transform: translateY(-50%);
}

/* Output Ports (Single & Multi-Port like If True/False) */
.fc-node-outputs.is-single {
	position: absolute;
	right: -6px;
	top: 50%;
	transform: translateY(-50%);
}

.fc-node-outputs.is-multi {
	position: absolute;
	right: -6px;
	top: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	justify-content: space-evenly;
	align-items: flex-end;
}

.fc-output-slot {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.fc-port-label {
	font-size: 11px;
	font-weight: 600;
	color: #475569;
	background: #f1f5f9;
	padding: 1px 6px;
	border-radius: 4px;
	border: 1px solid #e2e8f0;
	line-height: 1.3;
	white-space: nowrap;
}

/* Zoom Controls Toolbar */
.fc-zoom-controls {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 10;
	display: inline-flex;
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(4px);
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.fc-zoom-btn {
	appearance: none;
	background: transparent;
	border: 0;
	border-right: 1px solid #e2e8f0;
	padding: 5px 10px;
	font-size: 12px;
	font-weight: 600;
	color: #334155;
	cursor: pointer;
	line-height: 1;
}

.fc-zoom-btn:last-child {
	border-right: 0;
}

.fc-zoom-btn:hover {
	background-color: #f1f5f9;
	color: #0f172a;
}

/* Figcaption */
.fc-diagram-caption {
	margin-top: 8px;
	font-size: 13px;
	color: #64748b;
	text-align: center;
}

/* Draft preview hint (only visible to logged-in editors) */
.fc-draft-notice {
	margin-bottom: 8px;
	padding: 6px 12px;
	font-size: 12px;
	color: #92400e;
	background: #fef3c7;
	border: 1px solid #fde68a;
	border-radius: 8px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
	.fc-edge-path.is-animated {
		animation: none;
		stroke-dasharray: 8 6;
	}

	.fc-canvas-stage,
	.fc-node-card,
	.fc-port,
	.fc-edge-path {
		transition: none;
	}
}

/* ------------------------------------------------------------------ */
/* Anschlüsse oben/unten (vertikaler Fluss)                            */
/* ------------------------------------------------------------------ */
.fc-ports-tb .fc-port-in {
	left: 50%;
	top: -6px;
	transform: translateX(-50%);
}

.fc-ports-tb .fc-node-outputs.is-single,
.fc-ports-tb .fc-node-outputs.is-multi {
	left: 0;
	right: 0;
	top: calc(100% - 6px);
	bottom: auto;
	transform: none;
	display: flex;
	flex-direction: row;
	justify-content: space-evenly;
	align-items: flex-start;
}

.fc-ports-tb .fc-output-slot {
	flex-direction: column-reverse;
	gap: 3px;
}

/* Anschlusspunkte an frei gewählten Seiten (SVG) */
.fc-edge-anchor {
	fill: #ffffff;
	stroke: #94a3b8;
	stroke-width: 2;
}

/* ------------------------------------------------------------------ */
/* Bereiche (Gruppen-Container ohne Anschlüsse)                        */
/* ------------------------------------------------------------------ */
.fc-groups-layer {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
	pointer-events: none;
}

.fc-group {
	position: absolute;
	box-sizing: border-box;
	border: 2px solid #2d6bb5;
	border-radius: 16px;
	background-color: #eef6fb;
}

.fc-group.is-dashed {
	border-style: dashed;
}

.fc-group-title {
	position: absolute;
	top: 14px;
	left: 18px;
	right: 18px;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fc-group.fc-title-top-center .fc-group-title { text-align: center; }
.fc-group.fc-title-top-right .fc-group-title { text-align: right; }

/* ------------------------------------------------------------------ */
/* Mehrzeiliger Text (Option „Text umbrechen“)                          */
/* ------------------------------------------------------------------ */
.fc-node-card.is-wrap .fc-node-title {
	white-space: normal;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.fc-node-card.is-wrap .fc-node-subtitle {
	white-space: normal;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
}

/* ------------------------------------------------------------------ */
/* Gefüllte Box (Option „Box farbig füllen“)                            */
/* ------------------------------------------------------------------ */
.fc-node-card.is-filled.is-fill-dark .fc-node-title {
	color: #ffffff !important;
}

.fc-node-card.is-filled.is-fill-dark .fc-node-subtitle {
	color: rgba(255, 255, 255, 0.82) !important;
}

.fc-node-card.is-filled.is-fill-dark .fc-port-label {
	background: rgba(255, 255, 255, 0.92);
}
