/* ==========================================================================
   Responsive Layout – Smartphones und Tablets (hochkant)
   Desktop-Darstellung bleibt unverändert; Breakpoint passend zu is_narrow() in js/_functions.js
   ========================================================================== */

/* Alle Größen: Bilder, Tabellen und Formulare nie breiter als der Bildschirm */
#div_east img, #dialog img{ max-width: 100%; }
.ui-dialog{ max-width: calc(100vw - 8px); }
.ui-dialog .ui-dialog-content{ overflow: auto; }
#dialog input[type=text], #dialog select, #dialog textarea{ max-width: 100%; box-sizing: border-box; }
.dialog_textarea{ max-width: 100%; box-sizing: border-box; }

@media (max-width: 900px){

	/* Seite scrollt normal statt fester Fensterhöhe */
	body{
		position: static;
		overflow: auto;
		height: auto;
		font-size: 12px;
		-webkit-text-size-adjust: 100%;
	}

	/* Kopfbereich: Marke links, Benutzer rechts, Laufschrift darunter */
	#div_north{
		height: auto;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 6px 10px;
		padding: 8px 12px;
		box-sizing: border-box;
		overflow: visible;
	}
	#div_north #title.brand{ position: static; height: auto; flex: 1 1 auto; }
	#div_north #userinfo{ position: static; height: auto; flex: 0 1 auto; max-width: 55%; }
	#div_north #div_ticker{ order: 10; flex-basis: 100%; }
	#div_info{ position: fixed; top: 10px; left: 50%; max-width: 90vw; order: 5; }
	#debug_buttons, #scroll{ display: none; }   /* Debug & Monitor-Scrollmodus nur am Desktop */

	#div_center, #div_main{ height: auto !important; overflow: visible; }

	/* Hauptnavigation: horizontal wischbare Leiste */
	#tabs_head ul, #div_center > #tabs > #tabs_head > ul{
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}
	#tabs_head ul li{ float: none; flex: 0 0 auto; }
	#tabs_head ul li a{ padding: .7em 1em; }

	#div_main{ padding: 0 8px; }
	#tabs_head{ padding: 0; }
	#tabs_head .ui-tabs-nav li:last-child{ float: none; }
	.ov_tab > .ui-tabs-nav{ gap: 4px; }
	.ov_tab > .ui-tabs-nav li a{ padding: .4em .7em; }
	.search_row{ display: block; }
	.search_row label{ width: auto; margin-bottom: 3px; }
	#search_wrapper{ grid-template-columns: 1fr; }
	.setup_label{ width: 100%; }

	/* Zweispaltiges Layout -> gestapelt */
	#div_west{
		width: auto !important;
		height: auto !important;
		position: static;
		margin: 5px 0 0;
	}
	#div_east{
		position: static !important;
		float: none;
		left: auto !important;
		width: auto !important;
		margin-top: 10px;
	}
	#div_west .btn_top{ position: static; }
	#div_west br + br{ display: none; }
	#west_auftrag, #div_west #tabs-1, #div_west #tabs-2, #div_west #tabs-3{
		height: auto !important;
		max-height: 60vh;
		overflow: auto;
	}
	#datepicker .ui-datepicker{ width: auto; max-width: 22em; margin: 0 auto; }
	#div_tree, #div_left{ height: auto !important; }
	#div_left_struktur, #div_left_struktur2{ height: auto !important; max-height: 60vh; overflow: auto; }

	/* Wochenübersicht: Tabelle scrollt in ihrem Container */
	.ov_tab{ width: auto !important; height: auto !important; margin: 2px 0; }
	.ov_tab > .ui-tabs-nav{ display: flex; flex-wrap: wrap; padding-right: 4px; }
	.ov_tab > .ui-tabs-nav li{ float: none; }
	.ov_tools{ position: static; margin-left: auto; padding: 2px; }
	#tabs-4.ov_scroll{ width: auto !important; }
	.ov_scroll .table_overview{ width: auto; min-width: 100%; }
	.table_overview .td_head{ min-width: 92px; }
	.table_overview .td_line{ min-width: 92px; font-size: 10px; }
	.table_overview tbody td:first-child, .table_overview thead th:first-child{ min-width: 70px; max-width: 90px; }

	/* Tabellenlisten & Formulare */
	.table_wrap table{ min-width: 100%; }
	.form_table, .form_table tbody, .form_table tr{ width: 100%; }
	.form_table input[type=text], .form_table input[type=email], .form_table input[type=password], .form_table select, .form_table textarea{ width: 100%; }
	.form_table td.nowrap input.datum{ width: 9em; }
	.form_table td.nowrap select{ width: auto; }
	.textarea_info, .textarea_klein{ width: 100%; }
	.setup_label{ float: none; width: auto; }
	.setup_value{ margin-left: 0; }

	/* Touch-freundliche Bedienelemente */
	input[type=text], input[type=email], input[type=password], select, textarea{
		font-size: 16px;   /* verhindert Auto-Zoom auf iOS */
		min-height: 32px;
	}
	select{ height: auto; }
	.contextMenu li, #myMenu1 li{ padding: 8px 4px !important; font-size: 13px !important; }

	/* Suche */
	#search_form{ padding: 10px; }
	.search_row label{ display: block; width: auto; }
	#search_form input, #search_form select, .search_button{ width: 100%; box-sizing: border-box; }
	.search_table{ float: none; width: auto !important; margin: 0 0 10px; min-height: 0; }

	/* Galerie */
	#gallery ul{ grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
	.progress{ width: 100%; box-sizing: border-box; }

	/* Hilfe: Kapitel als wischbare Leiste oben */
	.help{ grid-template-columns: 1fr; gap: 10px; }
	.help_nav{ position: static; flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px; }
	.help_nav_title{ display: none; }
	.help_link{ width: auto; flex: none; white-space: nowrap; }
	.help_link.active{ box-shadow: inset 0 -3px 0 var(--c-accent); }
	.help_content{ padding: 16px; }
	.help_legend td:first-child{ width: auto; white-space: normal; }
}

@media (max-width: 480px){
	.user_text{ display: none; }   /* nur Initialen-Avatar */
	.brand_text strong{ font-size: 15px; }
	.table_overview .td_head, .table_overview .td_line{ min-width: 80px; }
}
