/**
 * KundenKarte Graph-Ansicht Styles
 * Nutzt Dolibarr CSS-Variablen für Theme-Kompatibilität
 */

/* Graph Container */
.kundenkarte-graph-wrapper {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin-top: 10px;
	overflow: visible;
	box-sizing: border-box;
}

#kundenkarte-graph-container {
	width: 100%;
	max-width: 100%;
	height: 400px;
	min-height: 300px;
	max-height: 80vh;
	border: 1px solid var(--inputbordercolor, #3a3a3a);
	border-radius: 4px;
	background: var(--colorbackbody, #1d1e20);
	overflow: hidden;
	box-sizing: border-box;
	resize: vertical;
}

@media (max-width: 768px) {
	#kundenkarte-graph-container {
		height: 300px;
	}
}

/* Toolbar: Zweizeilig */
.kundenkarte-graph-toolbar {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 8px 0;
}

.kundenkarte-graph-toolbar-row {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

/* Alle Buttons in der Graph-Toolbar einheitlich */
.kundenkarte-graph-toolbar .button,
.kundenkarte-graph-toolbar button.button {
	white-space: nowrap;
	display: inline-flex;
	align-items: center !important;
	gap: 4px !important;
	padding: 6px 12px !important;
	font-size: 12px !important;
	height: 30px !important;
	box-sizing: border-box !important;
}

/* Spacer: schiebt Anordnen/Speichern/Abbrechen nach rechts */
.kundenkarte-graph-toolbar-spacer {
	flex: 1;
}

#btn-graph-wheel-zoom.active {
	background: var(--butactionbg, #4390dc) !important;
	color: #fff !important;
	border-color: var(--butactionbg, #4390dc) !important;
}

/* Bearbeitungsmodus: Container-Rahmen */
#kundenkarte-graph-container.graph-edit-mode {
	border-color: #5a9a6a;
	box-shadow: 0 0 0 2px rgba(90, 154, 106, 0.3);
}

/* Speichern-Button grün, Abbrechen-Button rot */
.btn-graph-save {
	background: #2e7d32 !important;
	border-color: #2e7d32 !important;
	color: #fff !important;
}

.btn-graph-save:hover {
	background: #388e3c !important;
}

.btn-graph-cancel {
	background: #c62828 !important;
	border-color: #c62828 !important;
	color: #fff !important;
}

.btn-graph-cancel:hover {
	background: #d32f2f !important;
}

/* Legende */
.kundenkarte-graph-legend {
	display: flex;
	gap: 15px;
	padding: 8px 12px;
	margin-top: 8px;
	background: var(--colorbacktitle1, rgba(30, 30, 50, 0.8));
	border-radius: 4px;
	font-size: 11px;
	color: var(--colortext, #aaa);
	flex-wrap: wrap;
}

.kundenkarte-graph-legend-item {
	display: flex;
	align-items: center;
	gap: 5px;
}

.kundenkarte-graph-legend-line {
	width: 20px;
	height: 2px;
	display: inline-block;
}

.kundenkarte-graph-legend-line.cable {
	background: #5a8a5a;
}

.kundenkarte-graph-legend-line.passthrough {
	background: none;
	border-top: 2px dashed #505860;
	height: 0;
}

.kundenkarte-graph-legend-line.hierarchy {
	background: none;
	border-top: 2px dotted #6a7a8a;
	height: 0;
}

.kundenkarte-graph-legend-box {
	width: 16px;
	height: 12px;
	border-radius: 2px;
	display: inline-block;
}

.kundenkarte-graph-legend-box.building {
	background: #2a2b2d;
	border: 1px dashed #4390dc;
}

.kundenkarte-graph-legend-box.device {
	background: #2d4a3a;
	border: 2px solid #5a9a6a;
}

/* Loading Overlay */
.kundenkarte-graph-loading {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
	color: var(--colortext, #aaa);
	font-size: 14px;
	z-index: 10;
	border-radius: 4px;
}

.kundenkarte-graph-loading i {
	margin-right: 8px;
}

/* Graph Tooltip */
.kundenkarte-graph-tooltip {
	position: absolute;
	z-index: 100;
	background: var(--colorbacktabcard1, #1e2a3a);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	padding: 0;
	font-size: 12px;
	color: var(--colortext, #ccc);
	max-width: 320px;
	min-width: 200px;
	pointer-events: none;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
	overflow: hidden;
}

.kundenkarte-graph-tooltip .tooltip-header {
	padding: 10px 14px;
	background: rgba(255, 255, 255, 0.03);
	margin-bottom: 0;
}

.kundenkarte-graph-tooltip .tooltip-title {
	font-weight: bold;
	color: var(--colortextlink, #7ab0d4);
	font-size: 13px;
	line-height: 1.3;
}

.kundenkarte-graph-tooltip .tooltip-title i {
	margin-right: 4px;
	opacity: 0.8;
}

.kundenkarte-graph-tooltip .tooltip-type {
	color: var(--colortext, #999);
	font-size: 11px;
	margin-top: 3px;
	opacity: 0.7;
}

.kundenkarte-graph-tooltip .tooltip-system {
	background: rgba(255, 255, 255, 0.08);
	padding: 1px 6px;
	border-radius: 3px;
	font-size: 10px;
	margin-left: 4px;
}

.kundenkarte-graph-tooltip .tooltip-fields {
	padding: 6px 14px;
}

.kundenkarte-graph-tooltip .tooltip-field {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 3px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.kundenkarte-graph-tooltip .tooltip-field:last-child {
	border-bottom: none;
}

.kundenkarte-graph-tooltip .tooltip-field-label {
	color: var(--colortext, #888);
	opacity: 0.6;
	font-size: 11px;
	white-space: nowrap;
}

.kundenkarte-graph-tooltip .tooltip-field-value {
	color: var(--colortext, #eee);
	text-align: right;
	font-weight: 500;
}

.kundenkarte-graph-tooltip .tooltip-field-badge {
	color: #fff;
	text-align: right;
	font-weight: 600;
	font-size: 11px;
	padding: 1px 8px;
	border-radius: 4px;
	white-space: nowrap;
}

.kundenkarte-graph-tooltip .tooltip-footer {
	padding: 6px 14px;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	display: flex;
	gap: 10px;
	font-size: 11px;
	color: var(--colortext, #888);
	opacity: 0.7;
}

.kundenkarte-graph-tooltip .tooltip-file-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.kundenkarte-graph-tooltip .tooltip-file-badge i {
	font-size: 10px;
}

/* Leer-Zustand */
.kundenkarte-graph-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 300px;
	color: var(--colortext, #666);
	font-size: 14px;
	opacity: 0.6;
}

.kundenkarte-graph-empty i {
	font-size: 48px;
	margin-bottom: 16px;
}

/* Kontextmenü (Rechtsklick auf Node) */
.kundenkarte-graph-contextmenu {
	position: absolute;
	z-index: 200;
	background: var(--colorbacktabcard1, #1e2a3a);
	border: 1px solid var(--inputbordercolor, #3a6a8e);
	border-radius: 6px;
	padding: 4px 0;
	min-width: 160px;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.kundenkarte-graph-contextmenu .ctx-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	color: var(--colortext, #ddd);
	text-decoration: none;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.15s;
}

.kundenkarte-graph-contextmenu .ctx-item:hover {
	background: var(--butactionbg, #4390dc);
	color: #fff;
}

.kundenkarte-graph-contextmenu .ctx-item i {
	width: 16px;
	text-align: center;
	font-size: 12px;
}

.kundenkarte-graph-contextmenu .ctx-delete {
	color: #e57373;
}

.kundenkarte-graph-contextmenu .ctx-delete:hover {
	background: #c62828;
	color: #fff;
}

/* Suchfeld als Overlay im Graph-Container */
.kundenkarte-graph-search-floating {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 20;
}

.kundenkarte-graph-search-floating input {
	padding: 6px 10px 6px 28px;
	border: 1px solid var(--inputbordercolor, #3a3a3a);
	border-radius: 4px;
	background: var(--colorbackbody, #1d1e20);
	color: var(--colortext, #ddd);
	font-size: 12px;
	width: 180px;
	opacity: 0.7;
	transition: opacity 0.2s, width 0.2s;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: 8px center;
}

.kundenkarte-graph-search-floating input:focus {
	outline: none;
	border-color: var(--butactionbg, #4390dc);
	opacity: 1;
	width: 220px;
}

/* Mobile Anpassungen */
@media (max-width: 768px) {
	.kundenkarte-graph-toolbar-row {
		gap: 4px;
	}

	.kundenkarte-graph-toolbar .button,
	.kundenkarte-graph-toolbar button.button {
		padding: 8px 8px !important;
		font-size: 11px !important;
		height: 28px !important;
	}

	.kundenkarte-graph-search-floating input {
		width: 140px;
	}

	.kundenkarte-graph-search-floating input:focus {
		width: 160px;
	}
}
