/* ==========================================================================
   UI KIT — sovrapposto a tokens.css/components.css, STESSO linguaggio sample.html
   (accent #027BE3, Roboto, radius 4px). Componenti custom + responsive 360→2560.
   ========================================================================== */

/* ---------- Reset globale link (ZERO underline) ---------- */
body.lms a { text-decoration: none !important; }
body.lms a:hover { text-decoration: none; }

/* ---------- Colonna Azioni: sempre ultima, icone inline senza underline ---------- */
body.lms td.acts, body.lms th.acts { text-align: right; white-space: nowrap; }
body.lms td.acts a.gbtn, body.lms td.acts button.gbtn {
	text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
	vertical-align: middle; flex: none;
}
body.lms td.acts form { display: contents; }
body.lms td.acts a { text-decoration: none; }

/* ---------- Card form full-width ---------- */
body.lms .card > form, body.lms .card form[style*="display:grid"] { width: 100%; }
body.lms .card[style*="max-width"] { max-width: 100% !important; }

/* ---------- Filterbar: layout compatto e allineato ---------- */
body.lms .filterbar {
	display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 12px;
	border-bottom: 1px solid var(--line); align-items: center;
}
body.lms .filterbar > label {
	display: flex; align-items: center; gap: 6px;
	font-size: 12px; font-weight: 500; color: var(--muted);
	min-width: 0; white-space: nowrap;
}
body.lms .filterbar > label > :is(select, input) { width: auto; min-width: 120px; }
body.lms .filterbar > label[style*="flex"] { flex: 1 1 200px; }
body.lms .filterbar > :is(select, input) { min-height: 34px; }
body.lms .filterbar .btn { min-height: 34px; }

/* ---------- Reset globale form controls (ZERO look nativo) ---------- */
body.lms input, body.lms select, body.lms textarea, body.lms button {
	font-family: inherit; font-size: 13px; line-height: 1.35; color: var(--ink);
}
body.lms input::placeholder, body.lms textarea::placeholder { color: var(--muted); opacity: .7; }
body.lms input:disabled, body.lms select:disabled, body.lms textarea:disabled {
	background: var(--bg); color: var(--muted); cursor: not-allowed; border-color: var(--line);
}

/* ---------- Text inputs ---------- */
body.lms :is(input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=tel], input[type=url],
input[type=date], input[type=time], input[type=datetime-local], input[type=month], input[type=week],
textarea) {
	border: 1.5px solid var(--line-strong) !important;
	border-radius: var(--radius) !important;
	padding: 7px 11px !important;
	font: 13px/1.35 var(--font) !important;
	color: var(--ink) !important;
	background: #fff !important;
	transition: border-color .15s, box-shadow .15s !important;
	min-height: 34px !important;
	box-sizing: border-box !important;
	appearance: none !important;
	-webkit-appearance: none !important;
}
body.lms textarea { resize: vertical; min-height: 60px; }
body.lms :is(input, textarea):hover:not(:disabled):not(:focus) {
	border-color: var(--accent) !important;
}
body.lms :is(input, textarea):focus:not(:disabled) {
	border-color: var(--accent) !important;
	box-shadow: 0 0 0 3px var(--accent-soft) !important;
	outline: none !important;
}

/* ---------- File input ---------- */
body.lms input[type=file] {
	border: 1.5px dashed var(--line-strong) !important;
	border-radius: var(--radius) !important;
	padding: 6px 10px !important;
	background: var(--bg) !important;
	cursor: pointer; width: 100%; box-sizing: border-box;
	transition: border-color .15s;
}
body.lms input[type=file]:hover { border-color: var(--accent); }
body.lms input[type=file]::file-selector-button {
	border: 1px solid var(--line-strong); border-radius: 3px; padding: 4px 10px; margin-right: 10px;
	background: #fff; color: var(--ink); font: 500 12px var(--font); cursor: pointer; transition: background .15s;
}
body.lms input[type=file]::file-selector-button:hover { background: var(--btn-hover); }

/* ---------- Select (ZERO nativo) ---------- */
body.lms select {
	border: 1.5px solid var(--line-strong) !important;
	border-radius: var(--radius) !important;
	padding: 7px 32px 7px 11px !important;
	font: 13px/1.35 var(--font) !important;
	color: var(--ink) !important;
	background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1.5 1.5l4.5 4.5 4.5-4.5' stroke='%235F6368' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	min-height: 34px !important;
	cursor: pointer !important;
	transition: border-color .15s, box-shadow .15s !important;
	box-sizing: border-box !important;
}
body.lms select:hover:not(:disabled) {
	border-color: var(--accent) !important;
}
body.lms select:focus:not(:disabled) {
	border-color: var(--accent) !important;
	box-shadow: 0 0 0 3px var(--accent-soft) !important;
	outline: none !important;
}
body.lms select:invalid { color: var(--muted); }

/* ---------- Checkbox (ZERO nativo) ---------- */
body.lms input[type=checkbox] {
	appearance: none !important;
	-webkit-appearance: none !important;
	width: 17px !important; height: 17px !important;
	border: 1.5px solid var(--line-strong) !important;
	border-radius: 3.5px !important;
	background: #fff !important;
	cursor: pointer !important;
	position: relative !important;
	transition: all .12s !important;
	flex-shrink: 0 !important;
	vertical-align: middle !important;
	margin: 0 !important;
	accent-color: transparent !important;
}
body.lms input[type=checkbox]:hover:not(:disabled) { border-color: var(--accent) !important; }
body.lms input[type=checkbox]:checked {
	background: var(--accent) !important;
	border-color: var(--accent) !important;
}
body.lms input[type=checkbox]:checked::after {
	content: "" !important;
	position: absolute !important; inset: 0 !important;
	background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 9'%3E%3Cpath d='M1 4.5l3 3L10 1' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat !important;
}
body.lms input[type=checkbox]:indeterminate {
	background: var(--accent) !important;
	border-color: var(--accent) !important;
}
body.lms input[type=checkbox]:indeterminate::after {
	content: "" !important;
	position: absolute !important; left: 3px !important; right: 3px !important; top: 50% !important; height: 2px !important;
	background: #fff !important; border-radius: 1px !important; transform: translateY(-50%) !important;
}
body.lms input[type=checkbox]:disabled { background: var(--bg) !important; border-color: var(--line) !important; cursor: not-allowed !important; }

/* ---------- Radio (ZERO nativo) ---------- */
body.lms input[type=radio] {
	appearance: none !important;
	-webkit-appearance: none !important;
	width: 17px !important; height: 17px !important;
	border: 1.5px solid var(--line-strong) !important;
	border-radius: 50% !important;
	background: #fff !important;
	cursor: pointer !important;
	position: relative !important;
	transition: all .12s !important;
	flex-shrink: 0 !important;
	vertical-align: middle !important;
	margin: 0 !important;
	accent-color: transparent !important;
}
body.lms input[type=radio]:hover:not(:disabled) { border-color: var(--accent) !important; }
body.lms input[type=radio]:checked {
	border-color: var(--accent) !important;
	border-width: 5.5px !important;
	background: #fff !important;
}
body.lms input[type=radio]:disabled { background: var(--bg); border-color: var(--line); cursor: not-allowed; }

/* ---------- Range ---------- */
body.lms input[type=range] {
	appearance: none !important; -webkit-appearance: none !important;
	height: 4px !important; background: var(--line) !important; border-radius: 2px !important;
	outline: none !important; cursor: pointer !important; border: none !important; padding: 0 !important;
}
body.lms input[type=range]::-webkit-slider-thumb {
	appearance: none !important; -webkit-appearance: none !important;
	width: 16px !important; height: 16px !important; border-radius: 50% !important;
	background: var(--accent) !important; border: 2px solid #fff !important;
	box-shadow: 0 1px 3px rgba(0,0,0,.25) !important; cursor: grab !important;
}

/* ---------- Color input (ZERO nativo) ---------- */
body.lms input[type=color] {
	padding: 2px 3px !important;
	border: 1.5px solid var(--line-strong) !important;
	border-radius: var(--radius) !important;
	background: #fff !important;
	height: 34px !important;
	min-height: 34px !important;
	box-sizing: border-box !important;
	cursor: pointer !important;
}
body.lms input[type=color]:hover:not(:disabled) { border-color: var(--accent) !important; }
body.lms input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
body.lms input[type=color]::-webkit-color-swatch { border: none; border-radius: 2px; }
body.lms input[type=color]::-moz-color-swatch { border: none; border-radius: 2px; }

/* ---------- Focus ring unificato ---------- */
body.lms :is(button, a, input, select, textarea):focus-visible {
	outline: 2px solid var(--focus) !important;
	outline-offset: 1px !important;
	border-radius: var(--radius) !important;
}
body.lms :is(input, select, textarea):focus:not(:disabled) { outline: none !important; }

/* ---------- Switch (checkbox → toggle) ---------- */
body.lms .switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
body.lms .switch input { position: absolute; opacity: 0; pointer-events: none; }
/* neutralizza il .switch "a riga" di components.css (space-between + padding/bordo):
   allineerebbe il toggle al centro della riga con la checkbox fantasma in mezzo */
body.lms .switch { justify-content: flex-start; padding: 0; border-bottom: 0; }
/* la regola checkbox custom (position:relative !important) vincerebbe sull'absolute
   qui sopra: l'input della switch DEVE uscire dal flusso o occupa 17px fantasma */
body.lms .switch input[type=checkbox] { position: absolute !important; opacity: 0 !important; width: auto !important; height: auto !important; border: 0 !important; }
body.lms .switch .sw {
	flex: none; width: 36px; height: 20px; border-radius: 20px; background: var(--switch-off, #BDBDBD);
	position: relative; transition: background .18s;
}
body.lms .switch .sw::after {
	content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
	background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .18s;
}
body.lms .switch input:checked + .sw { background: var(--success); }
body.lms .switch input:checked + .sw::after { left: 18px; }
body.lms .switch input:focus-visible + .sw { outline: 2px solid var(--focus); outline-offset: 2px; }
body.lms .switch .sw-label { font-size: 12.5px; color: var(--ink); }

/* ---------- Pick cards ---------- */
body.lms .pick {
	position: relative; display: inline-flex; align-items: center; gap: 8px;
	border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: #fff;
	padding: 8px 12px; font-size: 12.5px; color: var(--ink); cursor: pointer; user-select: none;
	transition: border-color .15s, background .15s; margin: 0;
}
body.lms .pick:hover { border-color: var(--accent); }
body.lms .pick input { position: absolute; opacity: 0; pointer-events: none; }
body.lms .pick::before {
	content: ""; flex: none; width: 17px; height: 17px; border-radius: 3.5px;
	border: 1.5px solid var(--line-strong); background: #fff; transition: all .12s;
}
body.lms .pick:has(input[type=radio])::before { border-radius: 50%; }
body.lms .pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
body.lms .pick:has(input:checked)::before {
	background: var(--accent);
	border-color: var(--accent);
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 9'%3E%3Cpath d='M1 4.5l3 3L10 1' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: center; background-size: 11px;
}
body.lms .pick.pick-radio:has(input:checked)::before {
	background: #fff; border-color: var(--accent); border-width: 5px;
	background-image: none;
}
body.lms .pick:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- Segmented control ---------- */
body.lms .seg {
	display: inline-flex; background: #EFF2F5; border: 1px solid var(--line); border-radius: var(--radius);
	padding: 2px; gap: 2px;
}
body.lms .seg > * {
	border: none; background: transparent; border-radius: 3px; padding: 5px 13px;
	font: 500 12.5px var(--font); color: var(--muted); cursor: pointer; transition: all .15s;
	text-decoration: none; display: inline-block;
}
body.lms .seg > *:hover { color: var(--ink); }
body.lms .seg > .on { background: #fff; color: var(--accent); box-shadow: 0 1px 2px rgba(33,33,33,.12); }

/* ---------- Chip filtranti (T19) ---------- */
body.lms .chipbar {
	display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
	padding: 10px 14px; border-bottom: 1px solid var(--line);
}
body.lms a.chip { cursor: pointer; text-decoration: none; }
body.lms a.chip:hover { border-color: var(--accent); color: var(--accent); }
body.lms .chip.on { border-color: var(--accent); color: var(--accent); background: #fff; box-shadow: 0 1px 2px rgba(33,33,33,.12); }

/* ---------- Modale ---------- */
body.lms .lms-overlay {
	position: fixed; inset: 0; background: rgba(33,33,33,.45); backdrop-filter: blur(1.5px);
	z-index: 100; display: grid; place-items: center; padding: 20px;
	animation: lmsFade .16s ease-out;
}
body.lms .lms-modal {
	background: #fff; border-radius: 6px; box-shadow: 0 8px 32px rgba(33,33,33,.28);
	width: min(430px, 100%); padding: 20px 20px 14px; animation: lmsPop .18s cubic-bezier(.2,.9,.3,1.2);
}
body.lms .lms-modal h4 { margin: 0 0 8px; font: 500 15px var(--font); color: var(--ink); }
body.lms .lms-modal .m-body { font: 400 13px/1.5 var(--font); color: var(--muted); margin-bottom: 18px; white-space: pre-line; }
body.lms .lms-modal .m-actions { display: flex; gap: 8px; justify-content: flex-end; }
body.lms .lms-modal.danger h4 { color: var(--danger); }
@keyframes lmsFade { from { opacity: 0; } }
@keyframes lmsPop { from { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- Toast ---------- */
body.lms #lms-toasts {
	position: fixed; top: 60px; right: 16px; z-index: 120; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px));
}
body.lms .lms-toast {
	background: var(--ink); color: #fff; border-radius: var(--radius); padding: 10px 14px 10px 12px;
	font: 400 12.5px/1.4 var(--font); box-shadow: 0 4px 16px rgba(33,33,33,.3);
	display: flex; gap: 9px; align-items: flex-start; animation: lmsSlide .22s ease-out;
	border-left: 3px solid var(--accent);
}
body.lms .lms-toast.success { border-left-color: var(--success); }
body.lms .lms-toast.error { border-left-color: var(--danger); }
body.lms .lms-toast .t-ico { flex: none; font-size: 13px; line-height: 1.3; }
body.lms .lms-toast.leaving { animation: lmsSlideOut .18s ease-in forwards; }
@keyframes lmsSlide { from { opacity: 0; transform: translateX(14px); } }
@keyframes lmsSlideOut { to { opacity: 0; transform: translateX(14px); } }

/* ---------- Drawer mobile ---------- */
body.lms .lms-burger {
	display: none; border: none; background: transparent; color: #fff; font-size: 17px;
	cursor: pointer; padding: 4px 6px; margin-left: -4px;
}
body.lms .lms-backdrop { position: fixed; inset: 0; background: rgba(33,33,33,.4); z-index: 40; animation: lmsFade .16s; }

/* ---------- Tabelle: MAI scrollbar orizzontale a livello PAGINA (desktop) ----------
   Grid/flex item con min-width:auto fa sforare la colonna principale (board kanban, tabelle larghe):
   min-width:0 sui figli dello shell e dei grid + scroll INTERNO solo se il contenuto eccede (auto). */
body.lms .shell > * { min-width: 0; }
body.lms .grid > * { min-width: 0; }
body.lms .table-scroll { overflow-x: auto; }
body.lms .table-scroll table { width: 100%; min-width: 0; table-layout: auto; }
body.lms table { width: 100%; table-layout: auto; }
body.lms td form[style*="contents"] { display: contents; }
body.lms td form[style*="inline"] { display: inline-flex !important; align-items: center; margin: 0; flex: none; }
body.lms .sticky-head thead th { position: sticky; top: 104px; background: #FBFCFD; z-index: 2; box-shadow: 0 1px 0 var(--line-strong); }

/* Colonna Azioni: vedi blocco iniziale (righe ~10-17) */

/* ---------- Empty state ---------- */
body.lms .empty {
	display: grid; place-items: center; gap: 6px; padding: 34px 16px; color: var(--muted); text-align: center;
}
body.lms .empty .e-ico { font-size: 26px; opacity: .5; }
body.lms .empty .e-txt { font-size: 13px; }
body.lms .empty a, body.lms .empty .btn { margin-top: 4px; }

/* ---------- Skeleton ---------- */
body.lms .skl { background: linear-gradient(90deg, #EFF2F5 25%, #F7FAFE 50%, #EFF2F5 75%); background-size: 200% 100%; animation: lmsSkl 1.1s infinite; border-radius: var(--radius); }
@keyframes lmsSkl { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Content width: full-bleed ---------- */

/* ---------- Tablet/mobile ---------- */
@media (max-width: 1100px) {
	body.lms .grid.kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
	body.lms .shell { grid-template-columns: 1fr; }
	body.lms aside {
		position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 50;
		transform: translateX(-102%); transition: transform .22s ease-out;
		box-shadow: 8px 0 24px rgba(33,33,33,.18);
	}
	body.lms aside.open { transform: translateX(0); }
	body.lms .lms-burger { display: inline-block; }
	body.lms .search { min-width: 130px; }
	body.lms .search kbd { display: none; }
	body.lms .crumb { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
	body.lms .searchbar { padding: 8px 14px; }
	body.lms header { padding: 0 12px; }
	body.lms .lead-wrap { grid-template-columns: 1fr !important; }
	body.lms .page-head { flex-wrap: wrap; gap: 8px; }
	body.lms .page-head .right { margin-left: 0; width: 100%; }
	body.lms .board { grid-template-columns: repeat(6, minmax(232px, 78vw)); overflow-x: auto; padding-bottom: 10px; }
	body.lms .sticky-head thead th { top: 0; position: static; box-shadow: none; }
	body.lms .page-head .right form { flex-wrap: wrap; }
	body.lms .page-head .right form .pick { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
	/* tabelle: scrollbar solo se strettamente necessario */
	body.lms .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
	body.lms .table-scroll table { min-width: 500px; }
}
@media (max-width: 560px) {
	body.lms .grid.kpis { grid-template-columns: 1fr; }
	body.lms .grid.two-col, body.lms .grid.three-col { grid-template-columns: 1fr; }
	body.lms .filterbar { gap: 6px; }
	body.lms .filterbar :is(select, input) { max-width: 100%; }
	body.lms .gridbar { flex-wrap: wrap; }
	body.lms .content { padding: 12px; }
	body.lms #lms-toasts { left: 12px; right: 12px; max-width: none; }
	body.lms .hd-icons .ic { display: none; }
	body.lms .page-head h2 { font-size: 16px; }
	body.lms .seg { width: 100%; }
	body.lms .seg > * { flex: 1; text-align: center; }
	body.lms .table-scroll table { min-width: 400px; }
	/* righe ripetibili form (rep-row): su mobile collassano su una colonna */
	body.lms .rep-row { grid-template-columns: 1fr !important; }
	body.lms .builder-row { grid-template-columns: 1fr; gap: 4px; }
	body.lms .builder-row .k { padding-top: 0; }
	body.lms .step-flow { flex-direction: column; align-items: stretch; gap: 6px; }
	body.lms .step-arrow { transform: rotate(90deg); padding: 0; text-align: center; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	body.lms *, body.lms *::before, body.lms *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---------- Tooltip CSS-only (data-tip, T15) ----------
   Contenuto monoriga posizionato sopra l'elemento; attributo title duplicato
   come fallback nativo (touch / lunga pressione). */
body.lms [data-tip] { position: relative; }
body.lms [data-tip]:hover::after,
body.lms [data-tip]:focus-visible::after {
	content: attr(data-tip);
	position: absolute;
	bottom: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	background: rgba(33, 33, 33, .94);
	color: #fff;
	font: 500 11.5px/1.4 var(--font);
	padding: 4px 8px;
	border-radius: var(--radius);
	white-space: nowrap;
	pointer-events: none;
	z-index: 90;
	box-shadow: 0 2px 8px rgba(33, 33, 33, .25);
}
/* vicino al bordo destro della tabella: non far sbordare il tooltip */
body.lms td [data-tip]:hover::after,
body.lms td [data-tip]:focus-visible::after {
	left: auto;
	transform: none;
}

/* ---------- Print ---------- */
@media print {
	body.lms aside, body.lms header, body.lms .searchbar, body.lms .gridbar, body.lms .pager,
	body.lms .page-head .right, body.lms #lms-toasts, body.lms .filterbar { display: none !important; }
	body.lms .shell { grid-template-columns: 1fr; }
	body.lms .content { max-width: 100%; padding: 0; }
}
