/* Kalkulator Kosztorysów – front.
 * Krój pisma dziedziczony z motywu; kolor akcentu z ustawień kalkulatora (--kk-accent).
 * Nadpisuj zmienne w motywie, np.: .kk-calc { --kk-radius: 0; }
 */
.kk-calc {
	--kk-accent: #1f5f8b;
	--kk-ink: #1d2327;
	--kk-muted: #5f6b76;
	--kk-line: #d9dee3;
	--kk-paper: #f6f7f8;
	--kk-bg: #fff;
	--kk-error: #b42318;
	--kk-ok: #1a7f4b;
	--kk-radius: 6px;
	--kk-tint: color-mix(in srgb, var(--kk-accent) 8%, transparent);
	color: var(--kk-ink);
	line-height: 1.5;
	margin: 0 0 2em;
	container-type: inline-size;
	container-name: kk;
}
.kk-calc *, .kk-calc *::before, .kk-calc *::after { box-sizing: border-box; }

.kk-calc__form {
	display: grid;
	grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
	gap: clamp(20px, 3vw, 40px);
	align-items: start;
}
/* Układ zależy od szerokości kontenera, nie ekranu – kalkulator może siedzieć w wąskiej kolumnie. */
@container kk (max-width: 760px) {
	.kk-calc__form { grid-template-columns: 1fr; }
	.kk-calc__summary { position: static; }
}

/* ---------- Pola ---------- */
.kk-calc__fields { display: flex; flex-direction: column; gap: 26px; min-width: 0; }

.kk-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.kk-calc .kk-field__label {
	display: block;
	font-weight: 600;
	font-size: 1em;
	margin: 0 0 8px;
	padding: 0;
}
.kk-field__desc { margin: -4px 0 10px; color: var(--kk-muted); font-size: .9em; }
.kk-field__meta { margin: 6px 0 0; color: var(--kk-muted); font-size: .875em; font-variant-numeric: tabular-nums; }
.kk-req { color: var(--kk-error); }
.kk-heading { margin: 8px 0 4px; font-size: 1.25em; line-height: 1.3; }
.kk-field--heading + .kk-field { margin-top: -10px; }

.kk-calc input[type="number"],
.kk-calc input[type="text"],
.kk-calc input[type="email"],
.kk-calc input[type="tel"],
.kk-calc select,
.kk-calc textarea {
	width: 100%;
	min-height: 44px;
	padding: 9px 12px;
	border: 1px solid var(--kk-line);
	border-radius: var(--kk-radius);
	background: var(--kk-bg);
	color: inherit;
	font: inherit;
	margin: 0;
}
.kk-calc textarea { min-height: 80px; resize: vertical; }
.kk-calc :is(input, select, textarea, button):focus-visible {
	outline: 2px solid var(--kk-accent);
	outline-offset: 2px;
}

/* Ilość z przyciskami */
.kk-qty { display: flex; align-items: center; gap: 0; max-width: 260px; }
.kk-qty input[type="number"] {
	border-radius: 0;
	text-align: center;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
	appearance: textfield;
}
.kk-qty input::-webkit-inner-spin-button,
.kk-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.kk-qty__btn {
	flex: 0 0 44px;
	height: 44px;
	border: 1px solid var(--kk-line);
	background: var(--kk-paper);
	color: var(--kk-ink);
	font-size: 1.2em;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}
.kk-qty__btn:first-child { border-radius: var(--kk-radius) 0 0 var(--kk-radius); border-right: 0; }
.kk-qty__btn:nth-child(3) { border-radius: 0 var(--kk-radius) var(--kk-radius) 0; border-left: 0; }
.kk-qty__btn:hover { background: var(--kk-tint); }
.kk-qty__unit { margin-left: 10px; color: var(--kk-muted); white-space: nowrap; }

/* Suwak */
.kk-slider { display: flex; align-items: center; gap: 14px; }
.kk-slider input[type="range"] {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	-webkit-appearance: none;
	appearance: none;
	background: linear-gradient(to right, var(--kk-accent) var(--kk-fill, 50%), var(--kk-line) var(--kk-fill, 50%));
	margin: 0;
	cursor: pointer;
}
.kk-slider input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 22px; height: 22px; border-radius: 50%;
	background: var(--kk-bg); border: 2px solid var(--kk-accent);
}
.kk-slider input[type="range"]::-moz-range-thumb {
	width: 22px; height: 22px; border-radius: 50%;
	background: var(--kk-bg); border: 2px solid var(--kk-accent);
}
.kk-slider__value {
	min-width: 6.5em;
	text-align: right;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

/* Opcje: radio / checkbox jako kafelki */
.kk-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.kk-choice {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border: 1px solid var(--kk-line);
	border-radius: var(--kk-radius);
	cursor: pointer;
	background: var(--kk-bg);
	margin: 0;
}
.kk-choice:hover { border-color: var(--kk-accent); }
.kk-choice:has(input:checked) { border-color: var(--kk-accent); background: var(--kk-tint); box-shadow: inset 0 0 0 1px var(--kk-accent); }
.kk-choice input { accent-color: var(--kk-accent); width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.kk-choice__label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kk-choice__price { color: var(--kk-muted); font-size: .9em; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Przełącznik */
.kk-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; }
.kk-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kk-toggle__track {
	position: relative;
	flex: 0 0 44px;
	height: 26px;
	border-radius: 13px;
	background: var(--kk-line);
	transition: background .15s;
}
.kk-toggle__track::after {
	content: "";
	position: absolute; top: 3px; left: 3px;
	width: 20px; height: 20px; border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
	transition: transform .15s;
}
.kk-toggle input:checked + .kk-toggle__track { background: var(--kk-accent); }
.kk-toggle input:checked + .kk-toggle__track::after { transform: translateX(18px); }
.kk-toggle input:focus-visible + .kk-toggle__track { outline: 2px solid var(--kk-accent); outline-offset: 2px; }
.kk-toggle__label { font-weight: 600; }
.kk-field--toggle .kk-field__desc { margin: 6px 0 0 56px; }

/* Stała pozycja */
.kk-fixed {
	display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
	margin: 0; padding: 12px 14px;
	border: 1px solid var(--kk-line); border-radius: var(--kk-radius); background: var(--kk-paper);
}
.kk-fixed__label { font-weight: 600; }
.kk-fixed__price { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.kk-field--fixed .kk-field__desc { margin: 6px 0 0; }

/* ---------- Podsumowanie (paragon) ---------- */
.kk-calc__summary { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; }
.admin-bar .kk-calc__summary { top: 56px; }

.kk-summary {
	background: var(--kk-paper);
	border-top: 4px solid var(--kk-accent);
	border-radius: 0 0 var(--kk-radius) var(--kk-radius);
	padding: 20px 22px 18px;
}
.kk-summary__title, .kk-contact__title { margin: 0 0 12px; font-size: 1.1em; line-height: 1.3; }
.kk-summary__lines { list-style: none; margin: 0; padding: 0; }
.kk-summary__empty { color: var(--kk-muted); font-size: .9em; padding: 4px 0 8px; }
.kk-line {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 7px 0;
	border-bottom: 1px dashed var(--kk-line);
	font-size: .925em;
}
.kk-line__text { flex: 1; min-width: 0; }
.kk-line__label { display: block; font-weight: 600; }
.kk-line__detail { display: block; color: var(--kk-muted); overflow-wrap: anywhere; }
.kk-line__amount { white-space: nowrap; font-variant-numeric: tabular-nums; }

.kk-summary__totals { margin: 12px 0 0; }
.kk-total { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.kk-total dt, .kk-total dd { margin: 0; }
.kk-total--grand { margin-top: 8px; padding-top: 10px; border-top: 2px solid var(--kk-ink); align-items: baseline; flex-wrap: wrap; }
.kk-total--grand dt { font-weight: 600; }
.kk-total--grand dd { margin-left: auto; font-size: 1.75em; font-weight: 700; color: var(--kk-accent); line-height: 1.1; }
.kk-summary__note { margin: 12px 0 0; font-size: .8em; color: var(--kk-muted); }

/* ---------- Formularz ---------- */
.kk-contact { display: flex; flex-direction: column; gap: 12px; }
.kk-input { margin: 0; }
.kk-input label { display: block; font-size: .9em; font-weight: 600; margin-bottom: 4px; }
.kk-opt { font-weight: 400; color: var(--kk-muted); }
.kk-consent { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-size: .85em; color: var(--kk-muted); }
.kk-consent input { accent-color: var(--kk-accent); width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; }
.kk-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.kk-submit {
	min-height: 48px;
	padding: 12px 20px;
	border: 0;
	border-radius: var(--kk-radius);
	background: var(--kk-accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: filter .15s;
}
.kk-submit:hover { filter: brightness(1.1); }
.kk-submit:disabled { opacity: .65; cursor: progress; }

.kk-msg:empty { display: none; }
.kk-msg { font-size: .9em; padding: 10px 12px; border-radius: var(--kk-radius); }
.kk-msg--error { color: var(--kk-error); background: color-mix(in srgb, var(--kk-error) 8%, transparent); }

.kk-done { padding: 18px 20px; border-left: 4px solid var(--kk-ok); background: color-mix(in srgb, var(--kk-ok) 8%, transparent); border-radius: 0 var(--kk-radius) var(--kk-radius) 0; }
.kk-done:focus { outline: none; }
.kk-done__title { margin: 0 0 4px; font-weight: 700; color: var(--kk-ok); }
.kk-done__text { margin: 0; }

@media (prefers-reduced-motion: reduce) {
	.kk-calc * { transition: none !important; }
}
