/* Admin "Søkeindeks" dashboard.
   Picked up automatically by Minifier's recursive scan of css/webshop - there
   is no registration list to add it to. Everything is scoped under
   .admin-searchindex so the page can be restyled without touching the rest of
   the account area. */

.admin-searchindex {
	--si-border: #dee2e6;
	--si-rule: #f1f3f5;
	--si-muted: #6c757d;
	--si-surface: #f8f9fa;
	--si-log-bg: #0f172a;
	--si-log-fg: #cbd5e1;
	padding-bottom: 2rem;
}

.admin-searchindex h3 {
	font-size: 1.4rem;
	font-weight: 600;
	margin-bottom: 1.25rem;
}

/* ---------- sections read as cards, not as one long scroll ---------- */

.admin-searchindex section {
	background: #fff;
	border: 1px solid var(--si-border);
	border-radius: .5rem;
	padding: 1.25rem 1.5rem;
	margin-bottom: 1.5rem;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.admin-searchindex section > h4 {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	font-size: 1.05rem;
	font-weight: 600;
	margin: 0 0 1rem;
	padding-bottom: .6rem;
	border-bottom: 1px solid var(--si-border);
}

.admin-searchindex section > h4 > .form-control {
	margin-left: .75rem;
}

#searchindex-refreshed {
	font-size: .8rem;
	font-weight: 400;
	margin-left: .6rem;
}

/* ---------- status list ---------- */

.admin-searchindex dl.row {
	margin-bottom: 0;
}

.admin-searchindex dl.row > dt,
.admin-searchindex dl.row > dd {
	padding: .55rem 15px;
	margin-bottom: 0;
	border-bottom: 1px solid var(--si-rule);
}

.admin-searchindex dl.row > dt {
	font-weight: 500;
	color: var(--si-muted);
}

.admin-searchindex dl.row > dd {
	word-break: break-word;
}

.admin-searchindex dl.row > dt:nth-last-of-type(1),
.admin-searchindex dl.row > dd:nth-last-of-type(1) {
	border-bottom: 0;
}

.admin-searchindex dl.row code {
	padding: .1rem .35rem;
	background: var(--si-surface);
	border: 1px solid var(--si-border);
	border-radius: .2rem;
}

/* The index path is long enough to stretch the page if it is allowed to. */
.admin-searchindex dl.row small {
	display: inline-block;
	margin-top: .3rem;
	color: var(--si-muted);
	word-break: break-all;
}

/* ---------- freshness bands ---------- */

.admin-searchindex .searchindex-band {
	padding: .35em .6em;
	font-size: .75rem;
	letter-spacing: .03em;
	text-transform: uppercase;
	border-radius: .25rem;
}

.searchindex-band-fresh {background:#28a745;color:#fff}
.searchindex-band-soft-stale {background:#ffc107;color:#212529}
.searchindex-band-hard-stale {background:#dc3545;color:#fff}
.searchindex-band-schema-mismatch {background:#dc3545;color:#fff}
.searchindex-band-missing {background:#dc3545;color:#fff}
.searchindex-band-meta {background:#dc3545;color:#fff}
.searchindex-band-extension {background:#dc3545;color:#fff}

/* ---------- rebuild action and its warning ---------- */

#searchindex-rebuild-form {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 1.25rem;
}

#searchindex-rebuild-form .btn {
	margin-right: .5rem;
}

/* Its own full-width row under the buttons: flex-basis forces the wrap, width
   keeps it edge to edge inside the card rather than shrinking to its text. */
.admin-searchindex-hint {
	flex-basis: 100%;
	width: 100%;
	margin: .85rem 0 0;
	padding: .7rem .9rem;
	font-size: .85rem;
	line-height: 1.5;
	color: #6b5200;
	background: #fff8e6;
	border: 1px solid #ffe49b;
	border-left: 3px solid #f0ad4e;
	border-radius: .3rem;
}

/* ---------- log panels ---------- */

.admin-searchindex-log {
	max-height: 320px;
	margin: 1.25rem 0 0;
	padding: .85rem 1rem;
	overflow: auto;
	font-size: .78rem;
	line-height: 1.55;
	color: var(--si-log-fg);
	background: var(--si-log-bg);
	border-radius: .4rem;
	white-space: pre-wrap;
	word-break: break-word;
}

.admin-searchindex-log:empty {
	display: none;
}

.admin-searchindex-log::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

.admin-searchindex-log::-webkit-scrollbar-track {
	background: #111827;
	border-radius: 0 .4rem .4rem 0;
}

.admin-searchindex-log::-webkit-scrollbar-thumb {
	background: #334155;
	border-radius: 5px;
}

.admin-searchindex-log::-webkit-scrollbar-thumb:hover {
	background: #475569;
}

/* ---------- lookup and test-search forms ---------- */

.admin-searchindex .form-inline .form-control {
	min-width: 18rem;
}

#searchindex-query-summary {
	margin: .75rem 0 0;
}

/* Local table first at full width, ERP below it. The local table carries
   eleven columns, so it scrolls on its own rather than stretching the card;
   min-width:0 is what lets it, since grid columns are flex items whose default
   min-width:auto refuses to shrink below their content. */
#searchindex-query-result > [class^="col-"] {
	min-width: 0;
}

.admin-searchindex-scroll {
	overflow-x: auto;
}

#searchindex-query-result > [class^="col-"] + [class^="col-"] {
	margin-top: 1.25rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--si-rule);
}

/* Shown only once a table is there - the containers start empty, and on a
   browser without :has() the headings simply stay hidden. */
.admin-searchindex-subhead {
	display: none;
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--si-muted);
	margin-bottom: .5rem;
}

#searchindex-query-result > div:has(table) > .admin-searchindex-subhead {
	display: block;
}

/* Names may wrap; scores and ids must not, or the rows lose their alignment. */
.admin-searchindex-result td,
.admin-searchindex-result th {
	white-space: nowrap;
	vertical-align: middle;
}

.admin-searchindex-result td:nth-child(3) {
	white-space: normal;
	min-width: 14rem;
}

/* ---------- tables ---------- */

.admin-searchindex table {
	font-size: .85rem;
}

.admin-searchindex table thead th {
	border-top: 0;
	border-bottom: 2px solid var(--si-border);
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--si-muted);
}

.admin-searchindex tbody tr:hover {
	background: var(--si-surface);
}

#searchindex-stats-table tbody td:last-child {
	width: 8rem;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.admin-searchindex-result table {
	font-size: .85rem;
}

.admin-searchindex-result tr.only-local {background:#e8f4ff}
.admin-searchindex-result tr.only-erp {background:#fff3e0}

@media (max-width: 767.98px) {
	.admin-searchindex section {
		padding: 1rem;
	}

	.admin-searchindex .form-inline .form-control {
		min-width: 0;
		width: 100%;
		margin-bottom: .5rem;
	}
}
