/* =========================================================================
   BASE – design tokeny a vzhled holých HTML prvků (bez tříd).
   Barvy, mezery, rádiusy používat VŽDY přes proměnné níže.
   ========================================================================= */
:root {
	--bg: #f6f6f7;
	--surface: #ffffff;
	--text: #18181b;
	--muted: #71717a;
	--line: #e4e4e7;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--accent-soft: #eff4ff;
	--danger: #dc2626;
	--success: #16a34a;
	--warning: #d97706;

	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-5: 24px;
	--space-6: 32px;

	--radius: 8px;
	--font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--fs-sm: .8125rem;
	color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 var(--font);
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}

/* atribut hidden (netteForms toggle, JS) musí vyhrát nad display: flex/grid z ostatních pravidel */
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: .9375rem; }
p { margin: 0 0 var(--space-3); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Formuláře (HTML z FormFactory: form > div > label + input) ---------- */
form { display: flex; flex-direction: column; gap: var(--space-4); }
form > div, fieldset > div { display: flex; flex-direction: column; gap: var(--space-1); }
label { font-size: var(--fs-sm); font-weight: 500; }

/* Formulář se sekcemi ($form->addGroup()): sekce vedle sebe v mřížce, .wide = přes celou šířku.
   Uvnitř sekce jsou pole v mřížce, zaškrtávátka pod sebou bez mezer. */
form:has(> fieldset) {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--space-5) var(--space-6);
	align-items: start;
}
form:has(> fieldset) > :not(fieldset), fieldset.wide { grid-column: 1 / -1; }
/* formulář po polovinách (detail nabídky / zakázky): {form x class: cols-2} – sekce bez .wide = půl šířky */
form.cols-2:has(> fieldset) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-3);
	align-content: start;
}
fieldset.wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3) var(--space-4); }
legend {
	float: left;
	width: 100%;
	grid-column: 1 / -1;
	padding: 0 0 6px;
	border-bottom: 1px solid var(--line);
	font-size: .75rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--muted);
}
legend output { float: right; text-transform: none; letter-spacing: 0; color: var(--text); }
fieldset > div:has(> label > input[type=checkbox]) { margin-block: -4px; }
/* checkbox v řádku s inputy (široká sekce) zarovnat k polím */
fieldset.wide > div:has(> label > input[type=checkbox]):not(:has(> br)) { align-self: end; margin: 0; padding-bottom: 9px; }
/* seznam checkboxů (addCheckboxList): položky pod sebou bez <br> */
div:has(> label > input[type=checkbox]) > br { display: none; }
/* přepínač (addRadioList s class prepinac): volby vedle sebe jako segmenty, např. Textová nabídka / Kalkulačka */
div.prepinac { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
div.prepinac > label:empty { display: none; }
div.prepinac > br { display: none; }
div.prepinac > label { padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-weight: 500; }
div.prepinac > label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* sekce se 3 sloupci (hlavička detailu); třídy na řádku pole přes setOption('class'):
   .row-start = začít nový řádek, .full = přes celou šířku */
fieldset.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
fieldset.wide > div.row-start { grid-column-start: 1; }
fieldset.wide > div.full { grid-column: 1 / -1; }
/* .pulka = půl sloupce (datum + čas vedle sebe velké jako jedno pole) – sekce se pak skládá z 6 polovin */
fieldset.cols-3:has(> div.pulka) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
fieldset.cols-3:has(> div.pulka) > div { grid-column: span 2; }
fieldset.cols-3:has(> div.pulka) > div.pulka { grid-column: span 1; }

/* pole s přívěskem (data-suffix / data-generate-password, obaluje app.js) */
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-group .addon {
	display: inline-flex;
	align-items: center;
	padding: 0 12px;
	border: 1px solid var(--line);
	border-left: 0;
	border-radius: 0 var(--radius) var(--radius) 0;
	background: var(--bg);
	color: var(--muted);
	font-size: var(--fs-sm);
	font-weight: 600;
	white-space: nowrap;
}
.input-group button.addon { cursor: pointer; }
.input-group button.addon:hover { background: var(--line); color: var(--text); }

fieldset.wide > div:has(textarea) { grid-column: span 2; }
@media (max-width: 720px) {
	fieldset.cols-3, fieldset.cols-2, form.cols-2:has(> fieldset) { grid-template-columns: 1fr; }
	/* span 2 by na mobilu založil druhý (implicitní) sloupec a pole by se řadila vedle sebe */
	fieldset.wide > div:has(textarea) { grid-column: 1 / -1; }
	fieldset.cols-3:has(> div.pulka) { grid-template-columns: 1fr 1fr; }
	fieldset.cols-3:has(> div.pulka) > div { grid-column: 1 / -1; }
}
select[multiple] { min-height: 140px; }
img.photo { display: block; width: 58px; height: 75px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); margin-top: var(--space-2); }

/* hodnocení hvězdičkami: <select data-stars> + tlačítka ★ (app.js) */
.stars-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
.stars { display: inline-flex; }
.stars button {
	padding: 0 1px;
	border: 0;
	background: none;
	color: #d4d4d8;
	font-size: 1.25rem;
	line-height: 1;
}
.stars button.on { color: #f5a623; }
.stars:hover button { color: #f5a623; }
.stars button:hover ~ button { color: #d4d4d8; }
.stars button:hover, .stars button:focus { background: none; }

input, select, textarea {
	font: inherit;
	font-size: .875rem;
	color: var(--text);
	background: var(--surface);
	padding: 7px 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	width: 100%;
	transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 60px; resize: vertical; }

input[type=checkbox], input[type=radio] {
	width: 16px;
	height: 16px;
	padding: 0;
	margin: 0 var(--space-2) 0 0;
	vertical-align: -3px;
	accent-color: var(--accent);
}
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { font-weight: 400; cursor: pointer; }

.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
small.error { color: var(--danger); }
.errors p {
	margin: 0;
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius);
	background: #fef2f2;
	color: var(--danger);
	font-size: .875rem;
}

/* tlačítka: <button>, odeslání formuláře i odkaz .btn vypadají stejně */
button, [type=submit], [type=button], .btn {
	display: inline-block;
	width: auto;
	font: inherit;
	font-size: .875rem;
	font-weight: 500;
	line-height: 1.4;
	padding: 7px 14px;
	border: 1px solid var(--accent);
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	transition: background .15s;
}
button:hover, [type=submit]:hover, [type=button]:hover, .btn:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	text-decoration: none;
}
form > div:has(> [type=submit]) { flex-direction: row; gap: var(--space-2); }

/* ---------- Tabulky ---------- */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 8px var(--space-4); text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); white-space: nowrap; }
th a { color: inherit; }
th[aria-sort] a { color: var(--text); }
th[aria-sort=ascending] a::after { content: " \2191 "; }
th[aria-sort=descending] a::after { content: " \2193 "; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafafa; }
td.empty { text-align: center; color: var(--muted); padding: var(--space-6); }

pre { margin: 0; padding: var(--space-3); max-height: 60vh; overflow: auto; background: var(--bg); border-radius: var(--radius); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
