/* ==========================================================================
   LAGLISTAN – tillägg för Razor Pages-versionen (laddas efter laglistan.css).
   ========================================================================== */

/* Hoppa till innehållet (tangentbord/skärmläsare). */
.skiplink {
	position: absolute;
	left: -9999px;
	top: 8px;
	z-index: 2000;
	padding: 8px 14px;
	background: var(--surface);
	color: var(--brand-dark);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-2);
}
.skiplink:focus { left: 8px; }

/* Utloggning är ett POST-formulär – knappen ska se ut som en menyrad. */
.dropdown-menu form { margin: 0; }
.dropdown-menu form .dropdown-item { width: 100%; text-align: left; border: 0; background: none; }

/* Impersonering ("logga in som") – tydlig varning överst. */
.impbanner {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: var(--gap);
	padding: 10px 14px;
	border-radius: var(--radius-sm);
	background: var(--warn-bg);
	color: var(--warn);
	font-size: .875rem;
	font-weight: 600;
}

/* Valideringsfel från Razor Pages tag helpers. */
.field-validation-error { display: block; margin-top: 4px; font-size: .8125rem; color: var(--danger); }
.input-validation-error { border-color: var(--danger) !important; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

/* Hela lagraden är en länk. */
a.lawrow { color: inherit; text-decoration: none; }
a.lawrow:hover .lawrow__name { color: var(--brand-dark); }

/* Nyhetskort som länkar. */
a.newscard { color: inherit; text-decoration: none; }

/* Enkel HTML-redigerare (data-richtext i app.js). */
.rtedit { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.rtedit:focus-within { box-shadow: var(--focus-ring); border-color: var(--brand); }
.rtedit__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rtedit__btn { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--text); font-size: .8125rem; cursor: pointer; }
.rtedit__btn:hover, .rtedit__btn.is-active { background: var(--brand-light); border-color: var(--border); }
.rtedit__area { min-height: 240px; max-height: 60vh; overflow-y: auto; padding: 12px; outline: none; }
.rtedit__source { width: 100%; min-height: 240px; border: 0; padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: .8125rem; }

/* Formulärrader i inställningar och admin. */
.check-inline { display: inline-flex; align-items: center; gap: 8px; }
.table-list { width: 100%; font-size: .875rem; }
.table-list th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.table-list td, .table-list th { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.table-list tr.is-inactive td { color: var(--text-faint); }

/* RAG-chatten (AI-assistent) – flytande knapp och panel. */
.ragchat__btn { position: fixed; bottom: 24px; right: 24px; z-index: 1040; width: 56px; height: 56px; border: 0; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-2); cursor: pointer; }
.ragchat__btn .ico { width: 26px; height: 26px; }
.ragchat__panel { position: fixed; bottom: 90px; right: 24px; z-index: 1039; width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 120px)); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-2); background: var(--surface); display: flex; flex-direction: column; }
.ragchat__panel[hidden] { display: none; }
.ragchat__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--brand); color: #fff; font-weight: 600; }
.ragchat__head button { border: 0; background: none; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.ragchat__panel iframe { flex: 1; width: 100%; border: 0; }

/* Laglistan staplas när själva listan är smal (t.ex. smal skärm med sidomenyn synlig) – inte bara vid mobilbredd.
   Bara på skärm: utskriften har egna kolumner för A4 (laglistan.css). */
@media screen { .lawgroup { container-type: inline-size; } }
@container (max-width: 780px) {
	.lawgroup--laws .lawrow.lawrow--head, .lawgroup--chain .lawrow.lawrow--head { display: none; }
	.lawgroup--laws .lawrow, .lawgroup--chain .lawrow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
	.lawgroup--laws .lawrow > :empty, .lawgroup--chain .lawrow > :empty { display: none; }
	.lawgroup--laws .lawrow__name, .lawgroup--chain .lawrow__name { flex: 1 0 100%; order: -1; }
	.lawgroup--laws .lawrow > :not(.lawrow__name), .lawgroup--chain .lawrow > :not(.lawrow__name) { font-size: .8125rem; }
}

/* Autokomplettering i sökfält (data-suggest i app.js). Under toppraden och sidomenyn (z-index 1020/1030). */
.suggestwrap { position: relative; }
.suggest {
	position: absolute;
	z-index: 1010;
	top: calc(100% + 4px);
	left: 0;
	min-width: 100%;
	width: max-content;
	max-width: min(420px, 90vw);
	max-height: 320px;
	overflow-y: auto;
	margin: 0;
	padding: 4px;
	list-style: none;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-2);
}
.suggest[hidden] { display: none; }
.suggest__item { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 4px; font-size: .875rem; line-height: 1.35; color: var(--text); cursor: pointer; }
.suggest__item:hover, .suggest__item.is-active { background: var(--brand-light); }
.suggest__detail { font-size: .75rem; color: var(--text-muted); }
.suggest mark { padding: 0; background: none; color: inherit; font-weight: 700; }

/* Admin > AI-chatt: chattens fasta grundregler (utfällbara) och historiklistan. */
.chatrules { padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; }
.chatrules summary { font-weight: 600; cursor: pointer; }
.chatrules ul { margin: 8px 0; padding-left: 1.25em; }
.chathistory__summary { max-width: 480px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Checklistor i admin (kryssruta + text på samma rad). */
.lawgroup--assign { --law-cols: 18px minmax(0, 1fr); }
