{* ============================================
   ADMIN2000 - Kunden Editor (Main)
   Modulare Struktur mit Subtemplates
   ============================================ *}

<div class="admin2000-editor-container">

	{* Header: Breadcrumb + Messages *}
	{include file="admin2000/k-editor/header.tpl"}

	{* Tab Navigation *}
	<div class="admin2000-tabs-nav">
		<button type="button" class="admin2000-tab-button active" data-tab="stammdaten">Stammdaten</button>
		<button type="button" class="admin2000-tab-button" data-tab="firmendaten">Firmendaten</button>
		<button type="button" class="admin2000-tab-button" data-tab="adressen">Adressen</button>
		<button type="button" class="admin2000-tab-button" data-tab="zusatzfelder">Zusatzfelder</button>
		<button type="button" class="admin2000-tab-button" data-tab="rechnungen">Rechnungen</button>
	</div>

	{* Main Form *}
	<form id="admin2000-customer-form" method="post" action="./index.php?admin_modul=admin2000&section=stammdaten&page=kunden_editor&id={$customer_id}" class="admin2000-form">

		{* Hidden Fields *}
		<input type="hidden" name="customer_id" value="{$customer_id}">
		<input type="hidden" name="action" value="save">

		{* TAB 1: Stammdaten *}
		<div class="admin2000-tab-content active" data-tab-content="stammdaten">
			{include file="admin2000/k-editor/stammdaten.tpl"}
			{include file="admin2000/k-editor/kontaktdaten.tpl"}
			{include file="admin2000/k-editor/passwort.tpl"}
			{include file="admin2000/k-editor/steuer.tpl"}
		</div>

		{* TAB 2: Firmendaten *}
		<div class="admin2000-tab-content" data-tab-content="firmendaten">
			{include file="admin2000/k-editor/firmendaten.tpl"}
		</div>

		{* TAB 4: Zusatzfelder *}
		<div class="admin2000-tab-content" data-tab-content="zusatzfelder">
			{include file="admin2000/k-editor/zusatzfelder.tpl"}
		</div>

	</form>

	{* TAB 3: Adressen (outside form) *}
	<div class="admin2000-tab-content" data-tab-content="adressen">
		{include file="admin2000/k-editor/adressen.tpl"}
	</div>

	{* TAB 5: Rechnungen (outside form) *}
	<div class="admin2000-tab-content" data-tab-content="rechnungen">
		{include file="admin2000/k-editor/rechnungen.tpl"}
	</div>

	{* Sticky Save/Cancel Actions - Overall unten *}
	<div class="admin2000-form-actions-sticky">
		<div style="display: flex; gap: 15px;">
			<button type="submit" form="admin2000-customer-form" class="admin2000-btn admin2000-btn-primary">
				💾 Speichern
			</button>
			<a href="./index.php?admin_modul=admin2000&section=stammdaten&page=kunden" class="admin2000-btn admin2000-btn-secondary">
				Abbrechen
			</a>
		</div>
	</div>

</div>

<script>
$(document).ready(function() {
	console.log('🎨 Kunden-Editor geladen (modular mit Tabs)');
	console.log('Customer ID:', {$customer_id});

	// Tab Switching
	$('.admin2000-tab-button').click(function() {
		var tabName = $(this).data('tab');

		// Remove active class from all buttons and contents
		$('.admin2000-tab-button').removeClass('active');
		$('.admin2000-tab-content').removeClass('active');

		// Add active class to clicked button and corresponding content
		$(this).addClass('active');
		$('[data-tab-content="' + tabName + '"]').addClass('active');

		console.log('Switched to tab:', tabName);
	});
});
</script>
