/*
 * Zehner-Oberfläche — Handy-Ansicht (ab 1.5.0)
 *
 * Wirkt nur bis 767 px Breite (eldy-Grenze für Handys), also auf dem Smartphone im Browser,
 * als Web-App vom Home-Bildschirm und im Rahmen der Mitarbeiter-App. Darüber bleibt alles wie bisher.
 * Geändert wird nur das Aussehen; Felder, Formulare, Menüs und Rechte bleiben Dolibarr.
 *
 * Herkunft: Die Inhaltsregeln (Eingaben, Formulare, Knöpfe, Listen, Reiter) stammen aus dem
 * Handy-Skin der Mitarbeiter-App (dolibarr-pwa/public/desktop-skin.css, gegen Dolibarr 24 / eldy
 * im Handy-Layout geprüft). Dort gelten sie nur im App-Rahmen; hier für jede Doli-Seite auf dem Handy.
 * Neu dazu: Kopfmenü in einer Zeile zum Wischen und größere Einträge im Seitenmenü.
 *
 * Maße: Tippflächen 40–44 px (Apple 44 pt, WCAG 2.2 mindestens 24 px), Eingabefelder 16 px Schrift
 * (darunter zoomt Safari auf dem iPhone beim Antippen hinein und bleibt gezoomt).
 *
 * Gewicht gegen eldy: #id-right:not(#zui1) zählt wie zwei IDs; eldy setzt viele Werte mit !important,
 * deshalb stehen die Maße hier ebenfalls mit !important.
 */

@media (max-width: 767px) {

	/* ---------- Kopfmenü: eine Zeile zum seitlichen Wischen statt zwei Zeilen abgeschnittener Wörter ---------- */
	#id-top:not(#zui1) #tmenu_tooltip .tmenudiv {
		overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
		-webkit-overflow-scrolling: touch; scrollbar-width: none;
	}
	#id-top:not(#zui1) #tmenu_tooltip .tmenudiv::-webkit-scrollbar { display: none; }
	#id-top:not(#zui1) ul.tmenu {
		display: flex !important; flex-wrap: nowrap; width: max-content !important; min-width: 100%; height: auto !important;
		margin: 0 !important; padding: 0 !important;
	}
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) {
		float: none !important; flex: none; width: 66px !important; height: 52px !important; margin: 0 !important;
	}
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) .tmenucenter { width: auto !important; max-width: none !important; height: 52px !important; padding: 2px 2px 0 !important; }
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) :is(a.tmenuimage, a.tmenulabel) { width: auto !important; max-width: none !important; }
	/* Symbol und Beschriftung sind zwei Links zum selben Ziel: zusammen die ganze Kachel, jeder mindestens 24 px hoch */
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) a.tmenuimage { display: flex !important; align-items: flex-end; justify-content: center; height: 26px !important; }
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) a.tmenulabel { display: block !important; min-height: 24px; padding-top: 2px; box-sizing: border-box; }
	#id-top:not(#zui1) li:is(.tmenu, .tmenusel) .mainmenuaspan {
		display: block; max-width: 62px; margin: 0 auto !important; overflow: hidden; text-overflow: ellipsis;
		white-space: nowrap; text-align: center; font-size: 11px !important; line-height: 1.3;
	}
	/* Menü-Knopf (≡) bleibt beim Wischen links stehen */
	#id-top:not(#zui1) li.menuhider {
		position: sticky; left: 0; z-index: 3; width: 48px !important; background: var(--colorbackhmenu1, #263c5c);
		box-shadow: 6px 0 8px -6px rgba(0, 0, 0, .35);
	}

	/* ---------- Seitenmenü (über ≡): Einträge daumengroß statt 16 px hoher Textzeilen ---------- */
	#id-left:not(#zui1) div.menu_contenu,
	#id-left:not(#zui1) div.menu_titre { padding-top: 0 !important; padding-bottom: 0 !important; }
	#id-left:not(#zui1) div.menu_contenu a,
	#id-left:not(#zui1) div.menu_titre a.vmenu {
		display: block; min-height: 40px; padding: 10px 0 !important; box-sizing: border-box; line-height: 20px;
	}
	#id-left:not(#zui1) .blockvmenusearch a { display: block; padding: 10px 0; }

	/* ---------- Eingaben: 16 px gegen das Hineinzoomen, nichts ragt über den Rand ---------- */
	#id-right:not(#zui1) :is(input[type="text"], input[type="email"], input[type="number"], input[type="password"],
		input[type="tel"], input[type="url"], input[type="search"], input[type="date"], input[type="time"], input:not([type]), textarea, select) {
		font-size: 16px !important; max-width: 100% !important; box-sizing: border-box;
	}
	#id-right:not(#zui1) :is(input[type="text"], input[type="email"], input[type="number"], input[type="password"],
		input[type="tel"], input[type="url"], input[type="date"], input[type="time"], input:not([type]), select):not(.select2-search__field) { min-height: 40px; }
	#id-right:not(#zui1) .select2-container { max-width: 100% !important; }
	#id-right:not(#zui1) .select2-container .select2-selection--single { min-height: 40px; display: flex; align-items: center; }
	#id-right:not(#zui1) :is(input[type="checkbox"], input[type="radio"]) { width: 20px; height: 20px; }
	/* Suchfeld der aufgeklappten Auswahlliste hängt am <body> */
	.select2-container--open .select2-search__field { font-size: 16px !important; }

	/* ---------- Formulare und Karten: Beschriftung über dem Feld statt daneben.
	              Nur Tabellen, deren Zeilen höchstens zwei Zellen haben (Beschriftung + Wert). ---------- */
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))),
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody,
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr,
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr > :is(td, th) {
		display: block; width: auto !important; max-width: none !important; height: auto !important; box-sizing: border-box;
	}
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr > :is(td, th) {
		border: 0 !important; padding: 2px 0 !important; text-align: left !important;
	}
	#id-right:not(#zui1) :is(table.border, table.tableforfield, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr > :is(td, th):first-child:not(:only-child) {
		padding-top: 14px !important; font-weight: 600; opacity: .85;
	}
	#id-right:not(#zui1) :is(table.border, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr > td
		:is(input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="url"], input:not([type]), textarea, select):not(.maxwidthdate, .maxwidth50, .maxwidth75, .width50, .width75, [size="2"], [size="3"], [size="4"], [size="5"], .select2-search__field) {
		width: 100% !important; min-width: 0 !important;
	}
	#id-right:not(#zui1) :is(table.border, table.tableforfieldcreate, table.tableforfieldedit):not(.liste, :has(> tbody > tr > :nth-child(3))) > tbody > tr > td > .select2-container { width: 100% !important; }

	/* ---------- Knöpfe: daumengroß, in der Aktionszeile gleich breit nebeneinander ---------- */
	#id-right:not(#zui1) :is(.button, .butAction, .butActionDelete, .butActionRefused, .butActionNew, input[type="submit"], input[type="button"]):not(.select2-selection, .ui-button, .cke_button, .button_search, .button_removefilter) {
		min-height: 44px; padding: 10px 16px !important; font-size: 15px !important; line-height: 1.25 !important; box-sizing: border-box;
	}
	#id-right:not(#zui1) div.tabsAction { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 0 !important; text-align: left; }
	#id-right:not(#zui1) div.tabsAction > :is(a, .inline-block, div.inline-block > a) { flex: 1 1 140px; margin: 0 !important; text-align: center; }
	#id-right:not(#zui1) div.tabsAction :is(.butAction, .butActionDelete, .butActionRefused) { display: flex; align-items: center; justify-content: center; margin: 0 !important; }
	#id-right:not(#zui1) :is(div.center, div.tabsAction):has(> input.button) { display: flex; flex-wrap: wrap; gap: 8px; }
	#id-right:not(#zui1) :is(div.center, div.tabsAction):has(> input.button) > input.button { flex: 1 1 140px; margin: 0 !important; }
	/* Lupe und Filter-löschen in der Filterzeile von Listen */
	#id-right:not(#zui1) :is(.button_search, .button_removefilter) { min-width: 36px; min-height: 36px; }

	/* ---------- Listen: seitlich wischen statt abschneiden, Zeilen gut treffbar ---------- */
	#id-right:not(#zui1) :is(.div-table-responsive, .div-table-responsive-no-min) {
		overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
	}
	#id-right:not(#zui1) table.liste tr:not(.liste_titre, .liste_titre_filter) > td { padding-top: 10px; padding-bottom: 10px; }
	/* Links in Zeilen und Sortier-Links in der Kopfzeile: Innenabstand vergrößert nur die Trefferfläche.
	   Bewusst inline – als inline-block verlöre ein abgeschnittener Text in .tdoverflowmax… seine „…“. */
	#id-right:not(#zui1) table.liste td a:not(.reposition) { padding: 6px 0; }
	#id-right:not(#zui1) table.liste tr.liste_titre :is(th, td) > a.reposition { padding: 10px 0; }

	/* ---------- Reiter: eine Zeile zum Wischen ----------
	   Auf dem Handy zeigt Dolibarr 24 nur den aktiven Reiter und „+13“; die Liste dahinter öffnet nur
	   beim Überfahren mit der Maus, Antippen springt nach oben (behoben erst nach v24, PR #42745).
	   Hier stehen alle Reiter in einer wischbaren Zeile, „+13“ entfällt. */
	#id-right:not(#zui1) div.tabs { display: flex; flex-wrap: nowrap; align-items: stretch; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none; }
	#id-right:not(#zui1) div.tabs::-webkit-scrollbar { display: none; }
	#id-right:not(#zui1) div.tabs > div.tabsElem { flex: none; }
	#id-right:not(#zui1) div.tabs > div.tabsElem:has(> div.tab > a.moretab) { display: contents; }
	#id-right:not(#zui1) div.tabs > div.tabsElem > div.tab:has(> a.moretab) { display: none !important; }
	#id-right:not(#zui1) div.tabs [id^="moretabsList"],
	#id-right:not(#zui1) div.tabs [id^="moretabsList"] > .popuptabset { display: contents !important; }
	#id-right:not(#zui1) div.tabs .popuptab {
		flex: none; display: flex !important; align-items: center; min-height: 44px; padding: 0 12px; box-sizing: border-box;
		white-space: nowrap; border-bottom: 2px solid transparent;
	}
	#id-right:not(#zui1) div.tabs .popuptab > a { white-space: nowrap; text-decoration: none; }

	/* ---------- Listen: Filter hinter dem Knopf „Filter (n)“ (js/zehnerui-handy.js) ---------- */
	#id-right:not(#zui1) form.zui-filter-zu :is(.liste_titre_bydiv, tr.liste_titre_filter) { display: none !important; }
	#id-right:not(#zui1) form.zui-filter-zu table.liste:has(> tbody > tr.trkanban) tr.liste_titre { display: none !important; }
	#id-right:not(#zui1) .zui-filterknopf {
		display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin: 2px 0 10px; padding: 0 14px 0 12px;
		border: 1px solid var(--zui-line, rgba(15, 23, 42, .18)); border-radius: 20px; background: var(--zui-bg, #fff);
		color: var(--zui-text, #333); font: inherit; font-size: 15px; cursor: pointer; touch-action: manipulation;
	}
	#id-right:not(#zui1) .zui-filterknopf::before {
		content: ''; width: 16px; height: 16px; flex: none; background: currentColor; opacity: .7;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 2.5h13l-5 6v5l-3-1.5V8.5z' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
		        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 2.5h13l-5 6v5l-3-1.5V8.5z' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	}
	#id-right:not(#zui1) .zui-filterknopf::after { content: ''; width: 16px; height: 16px; flex: none; background: var(--zui-chevron) center / 16px no-repeat; }
	#id-right:not(#zui1) .zui-filterknopf[aria-expanded="true"]::after { transform: rotate(180deg); }
	#id-right:not(#zui1) .zui-filterknopf.zui-filter-aktiv { border-color: var(--zui-line-strong, rgba(15, 23, 42, .6)); font-weight: 600; box-shadow: inset 3px 0 0 var(--zui-accent, #263c5c); }

	/* ---------- Kartenansicht (mode=kanban): Karten untereinander in voller Breite.
	              Ohne das spannt die Kopfzeile die Karten auf Tabellenbreite (5 Karten nebeneinander). ---------- */
	#id-right:not(#zui1) table.liste:has(> tbody > tr.trkanban),
	#id-right:not(#zui1) table.liste:has(> tbody > tr.trkanban) > tbody,
	#id-right:not(#zui1) table.liste tr.trkanban,
	#id-right:not(#zui1) table.liste tr.trkanban > td { display: block; width: auto !important; }
	#id-right:not(#zui1) table.liste tr.trkanban > td { padding: 4px 0 !important; border: 0 !important; }
	#id-right:not(#zui1) .box-flex-container.kanban { flex-direction: column; flex-wrap: nowrap; gap: 8px; width: auto !important; }
	#id-right:not(#zui1) .box-flex-container.kanban > .box-flex-item { flex: none; width: auto !important; margin: 0 !important; }
	#id-right:not(#zui1) .box-flex-container.kanban .info-box { width: auto !important; max-width: none !important; }

	/* ---------- Seitentitel kompakter, Meldungen über die ganze Breite ---------- */
	#id-right:not(#zui1) table.table-fiche-title { margin: 2px 0 6px; }
	.jnotify-container { left: 8px !important; right: 8px !important; top: 8px !important; width: auto !important; }

	/* ---------- Kalender (FullCalendar, z. B. Dienstplan): Kopfzeile bricht um statt zu stapeln ---------- */
	#id-right:not(#zui1) .fc .fc-header-toolbar { flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
	#id-right:not(#zui1) .fc .fc-toolbar-chunk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
	#id-right:not(#zui1) .fc .fc-toolbar-chunk > * { margin: 0 !important; }
	#id-right:not(#zui1) .fc .fc-toolbar-title { font-size: 1.05rem !important; line-height: 1.25; }
	#id-right:not(#zui1) .fc .fc-button { min-height: 40px; padding: 6px 12px; font-size: 14px; }
	#id-right:not(#zui1) .fc .fc-toolbar-chunk:has(.fc-toolbar-title) { flex: 1 1 100%; order: -1; }
}
