/**
 * Magna AI — back-end panel styles.
 *
 * ══════════════════════════════════════════════════════════════════════════════
 * ★ THIS SHEET IS SELF-CONTAINED, AND THAT IS A RULE, NOT A STYLE PREFERENCE.
 * ══════════════════════════════════════════════════════════════════════════════
 *
 * Every colour is declared in the :root block below. This sheet depends on NO
 * other stylesheet — not a theme, not a sibling plugin's admin CSS, not a shared
 * "gold series" file. A panel that depends on another plugin's sheet inherits
 * that plugin's future edits, and the resulting breakage appears HERE while the
 * cause lives THERE. One sheet, one owner.
 *
 * The .aisg- prefix namespaces every selector. WordPress admin CSS is global, so an
 * un-prefixed rule leaks — and a leak is diagnosed in the wrong codebase.
 */

:root {
	--aisg-bronze-1: #c2714a;
	--aisg-bronze-2: #d4845c;
	--aisg-bronze-3: #e09a72;
	--aisg-steel-1: #2c5f6e;
	--aisg-steel-2: #3a7a8c;
	--aisg-steel-3: #4a8fa0;
	--aisg-ink: #0f172a;
	--aisg-ink-2: #16213a;
	--aisg-line: rgba(255, 255, 255, 0.10);
	--aisg-text: #e2e8f0;
	--aisg-dim: rgba(255, 255, 255, 0.58);
	--aisg-ok: #4ade80;
	--aisg-warn: #fbbf24;
	--aisg-error: #f87171;
	--aisg-radius: 16px;
	--aisg-pad: 20px;
	--aisg-gap: 5px;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */

.aisg-wrap {
	margin: 0 0 0 8px;
	width: calc(100% - 24px);
	color: var(--aisg-text);
}

.aisg-wrap * { box-sizing: border-box; }

.aisg-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 44px;
	margin: 0; /* the 44px bar is flush left; the shell carries the offset */
	padding: 0 14px;
	border: 1px solid var(--aisg-line);
	border-radius: var(--aisg-radius);
	background: linear-gradient(135deg, var(--aisg-ink) 0%, var(--aisg-ink-2) 100%);
}

.aisg-topbar-left,
.aisg-topbar-right { display: flex; align-items: center; gap: 10px; }

.aisg-brand-mark { color: var(--aisg-bronze-2); font-size: 16px; line-height: 1; }

/* Plain text, no container — the series name is not a badge. */
.aisg-brand {
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.8px;
	text-transform: uppercase;
	color: inherit;
	line-height: 1;
}

.aisg-version,
.aisg-topbar-note {
	font-size: 11px;
	color: var(--aisg-dim);
	letter-spacing: 0.4px;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.aisg-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: var(--aisg-gap);
	margin: 10px 0 0;
}

.aisg-tab {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 10px 16px;
	border: 1px solid var(--aisg-line);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.02);
	color: var(--aisg-dim);
	font-size: 13px;
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.aisg-tab:hover,
.aisg-tab:focus {
	background: rgba(255, 255, 255, 0.06);
	color: var(--aisg-text);
	border-color: rgba(255, 255, 255, 0.2);
}

.aisg-tab.is-active {
	background: linear-gradient(135deg, var(--aisg-bronze-1) 0%, var(--aisg-bronze-3) 100%);
	border-color: transparent;
	color: #fff;
	font-weight: 600;
}

.aisg-tab-icon { font-size: 14px; line-height: 1; }

/* ── Body ──────────────────────────────────────────────────────────────── */

.aisg-body { margin-top: 12px; }

.aisg-footbar {
	margin-top: 18px;
	padding: 10px 2px;
	font-size: 11px;
	color: var(--aisg-dim);
	border-top: 1px solid var(--aisg-line);
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

/*
 * ★ `.aisg-card` BASE REMOVED — OWNED BY THE SHELL SHEET (2026-10-09).
 *
 * This block used to declare `margin-bottom`, `border-radius`, a steel-gradient
 * background and `overflow: hidden`. The shell sheet declares a glass
 * `rgba(255,255,255,0.03)` background and a CT-variable radius. Because this
 * sheet loads later, the back end showed the STEEL GRADIENT while the front end
 * showed the GLASS — the same `.aisg-card` class, two different surfaces.
 *
 * The only property here that the shell sheet genuinely lacks is
 * `margin-bottom`, so ONLY that is kept, matching the shell's `--grid-gap`
 * rhythm. Everything else is the shell sheet's job now.
 */
.aisg-card {
	margin-bottom: var(--aisg-gap);
}

/*
 * ★ `.aisg-card-header` BASE REMOVED (2026-10-09) — THIS WAS STILL DRIFTING.
 *
 * Caught by the FINAL ownership audit, after the first sweep had already been
 * called done: this block survived with `display: flex`, `align-items: center`,
 * `gap`, `padding: 14px` and a `border-bottom` — i.e. a SECOND full definition
 * of the same class the shell sheet defines as `display: flex` /
 * `align-items: center` / `justify-content: space-between` /
 * `margin-bottom: var(--spacing-md)`, with NO padding and NO divider.
 *
 * They are not interchangeable: the shell version puts the title left and the
 * icon RIGHT (`space-between`), this one packed them together with a `gap` and
 * drew a horizontal rule the shell never draws. So the back end showed a
 * divider-and-tightly-packed header while the front end showed a spread one —
 * exactly the class of defect this task exists to remove, and it survived the
 * first pass because the crude selector check did not distinguish a BASE from a
 * MODIFIER.
 *
 * Nothing here is kept: the shell sheet's definition is the intended one, and
 * this sheet adds no property to it.
 */

/*
 * ★ `.aisg-card-header h2` REMOVED — THE SHELL SHEET COVERS h2/h3/h4 NOW
 * (2026-10-09). It was styled ONLY here, so the `<h2>` card titles in
 * `AISG_Unified_Admin::render_dashboard()` were unstyled on the front end.
 * Deleting it here and covering h2/h3/h4 in the shell sheet fixes both
 * surfaces with one rule. `.aisg-card-icon` is likewise now owned there.
 */
.aisg-card-icon { line-height: 1; }


/*
 * ── Metric value MODIFIERS ───────────────────────────────────────────────
 *
 * ★ THIS SHEET NO LONGER OWNS THE BASES (2026-10-09).
 *
 * It used to declare `.aisg-card`, `.aisg-card-header`, `.aisg-cards-grid`,
 * `.aisg-grid-3` and `.aisg-metric-value` — and so did the shell sheet that
 * always loads alongside it. Two sheets, one set of selectors, and because this
 * one loads later ITS version silently won on the back end while the front end
 * got the other. Two surfaces, two looks, one class name.
 *
 * The bases now live in ONE place (the shell sheet). What stays here is what
 * this sheet genuinely adds: the SEMANTIC MODIFIERS a bare metric cannot
 * express (ok / error / undecided), plus component styles with no equivalent
 * there. Those are additions, not overrides — they carry no base properties, so
 * they cannot reintroduce the drift.
 *
 * ★ AND THAT IS WHY THIS SHEET STILL DECLARES NO EXTERNAL DEPENDENCY, as
 * §11 of the batch-1 gate requires: it reads only its own `--aisg-*` tokens,
 * which are declared in its own `:root` below. Removing the duplicate bases
 * REMOVED its last reason to care what loads before it.
 */
.aisg-metric-value.aisg-ok { color: var(--aisg-ok); }
.aisg-metric-value.aisg-error { color: var(--aisg-error); }

.aisg-muted { color: var(--aisg-dim); font-size: 12px; }

/* ── Notices ───────────────────────────────────────────────────────────── */

.aisg-notice {
	margin: 10px 0 0;
	padding: 9px 12px;
	border-radius: 8px;
	border-left: 3px solid var(--aisg-steel-3);
	background: rgba(255, 255, 255, 0.04);
	font-size: 12px;
	line-height: 1.55;
	color: var(--aisg-dim);
}

.aisg-notice-warn {
	border-left-color: var(--aisg-warn);
	color: #f7e2b0;
}

.aisg-notice-ok {
	border-left-color: var(--aisg-ok);
	color: #c9f5d8;
	margin-bottom: 12px;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */

.aisg-form .aisg-card { margin-bottom: var(--aisg-gap); }

.aisg-field { display: block; margin-bottom: 16px; }

.aisg-field-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}

.aisg-label {
	display: block;
	margin-bottom: 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.3px;
	color: var(--aisg-text);
}

.aisg-input {
	width: 100%;
	max-width: 520px;
	padding: 9px 12px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.04);
	color: #fff;
	font-size: 13px;
}

.aisg-input:focus {
	outline: none;
	border-color: var(--aisg-steel-3);
	box-shadow: 0 0 0 2px rgba(74, 143, 160, 0.25);
}

.aisg-help {
	display: block;
	margin-top: 5px;
	font-size: 11px;
	line-height: 1.55;
	color: var(--aisg-dim);
}

.aisg-help-inset { margin: 0 0 16px 2px; max-width: 620px; }

.aisg-toggle {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-bottom: 8px;
	font-size: 13px;
	color: var(--aisg-text);
	cursor: pointer;
}

.aisg-toggle input { margin-top: 2px; }

.aisg-actions { margin: 0 0 20px; }

.aisg-btn {
	display: inline-block;
	padding: 9px 20px;
	border: 1px solid var(--aisg-line);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.06);
	color: var(--aisg-text);
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
}

.aisg-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.aisg-btn-primary {
	border-color: transparent;
	background: linear-gradient(135deg, var(--aisg-bronze-1) 0%, var(--aisg-bronze-3) 100%);
	color: #fff;
	font-weight: 600;
}

/* ── Table ─────────────────────────────────────────────────────────────── */

.aisg-table { width: 100%; border-collapse: collapse; font-size: 12px; }

.aisg-table th {
	padding: 8px 10px;
	text-align: left;
	font-weight: 600;
	color: var(--aisg-dim);
	border-bottom: 1px solid var(--aisg-line);
	letter-spacing: 0.3px;
}

.aisg-table td {
	padding: 8px 10px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.05);
	color: var(--aisg-text);
}

.aisg-table code { color: var(--aisg-steel-3); background: none; }

.aisg-badge {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 20px;
	font-size: 11px;
	font-weight: 600;
}

.aisg-badge-ok { background: rgba(74, 222, 128, 0.16); color: var(--aisg-ok); }
.aisg-badge-error { background: rgba(248, 113, 113, 0.16); color: var(--aisg-error); }

/* ── Batch 2: Knowledge tab ─────────────────────────────────────────────── */

/*
 * ★ WHY THE METRICS STRIP IS .aisg-metrics (PLURAL) AND NOT A GRID CLASS.
 *
 * The individual .aisg-metric card already exists above. The wrapper only needs
 * to lay three of them out in a row and wrap on a narrow screen — so it declares
 * that and nothing else. Reusing the card rule as the wrapper would nest a card
 * inside a card and double the border, which reads as a rendering bug.
 */
.aisg-metrics {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin: 0 0 16px;
}

.aisg-metric-label {
	display: block;
	margin-top: 4px;
	font-size: 11px;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	color: var(--aisg-dim);
}

.aisg-badge-warn { background: rgba(251, 191, 36, 0.16); color: var(--aisg-warn); }

/* A dimmed cell holds derived topics — useful, never the primary column. */
.aisg-dim { color: var(--aisg-dim); font-size: 12px; }

.aisg-text { color: var(--aisg-text); line-height: 1.6; margin: 0 0 16px; }

/* On a phone a three-up metric row squeezes to unreadable numbers. */
@media (max-width: 782px) {
	.aisg-metrics { grid-template-columns: 1fr; }
}

/* ── Batch 3: Consent Console ───────────────────────────────────────────── */

/*
 * ★ THE METRICS ROW GROWS, SO IT STOPS BEING A FIXED THREE-UP GRID.
 *
 * Batch 2's .aisg-metrics was `repeat(3, …)`. The Consent tab renders one card
 * per level (five) plus `undecided` (six), so a hardcoded 3-column grid would
 * wrap into an uneven second row and read as a layout bug. `auto-fit` lets the
 * same class serve both tabs with no per-tab override — and the batch-2 page is
 * unchanged, because three items still fit three columns.
 */
.aisg-metrics {
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

/* The scale is read once, so it folds away by default and remembers nothing. */
.aisg-details {
	margin: 0 0 16px;
	padding: 10px 14px;
	border: 1px solid var(--aisg-line);
	border-radius: 10px;
}
.aisg-details summary {
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	color: var(--aisg-text);
}
.aisg-details .aisg-table { margin-top: 10px; }

.aisg-select {
	max-width: 100%;
	padding: 5px 8px;
	border-radius: 8px;
	border: 1px solid var(--aisg-line);
	background: rgba(255, 255, 255, 0.06);
	color: var(--aisg-text);
	font-size: 12px;
}
.aisg-select:disabled { opacity: 0.6; cursor: progress; }

.aisg-input {
	width: 100%;
	min-width: 90px;
	padding: 5px 8px;
	border-radius: 8px;
	border: 1px solid var(--aisg-line);
	background: rgba(255, 255, 255, 0.06);
	color: var(--aisg-text);
	font-size: 12px;
}

/*
 * ★ "NOT DECIDED" IS NOT AN ERROR, SO IT MUST NOT LOOK LIKE ONE.
 *
 * An undecided object is already safe — the effective level is staffonly. So it
 * gets the WARN (amber) token rather than the error (red) one: red would tell the
 * operator something is broken, and would train them to clear the colour rather
 * than to make a decision. Amber reads as "there is work here", which is true.
 */
.aisg-badge-new { background: rgba(251, 191, 36, 0.16); color: var(--aisg-warn); }

.aisg-row-undecided > td:first-child { border-left: 3px solid rgba(251, 191, 36, 0.5); }

/* The status line lives under the table and is the only place a save reports. */
.aisg-consent-status { display: block; margin: 10px 0 0; min-height: 18px; }

/*
 * ★ .aisg-help-error IS REFERENCED BY THE ADMIN JS and had no rule, so the
 * "this failed" state rendered identically to "this succeeded" — the worst
 * possible pair to make indistinguishable.
 */
.aisg-help-error { color: var(--aisg-error); font-weight: 600; }

/* A consent row's dropdown and note sit in narrow cells; keep them legible. */
.aisg-consent-table td { vertical-align: middle; }
.aisg-consent-table td:nth-child(4) { min-width: 190px; }
.aisg-consent-table td:nth-child(5) { min-width: 140px; }

/* ── Swatch ────────────────────────────────────────────────────────────── */

.aisg-swatch {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border-radius: 10px;
	border: 1px solid var(--aisg-line);
	font-size: 12px;
}

.aisg-swatch-dot {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--aisg-bronze-1), var(--aisg-bronze-3));
}

.aisg-swatch-label {
	font-weight: 600;
	color: var(--aisg-ink-1);
}

/* ── Consent Console — the four gaps the class cross-check found (2026-09-29) ──
 *
 * ★ WHY THESE ARE HERE AND NOT "ADDED LATER". `verify-identity.php` compares the
 *   classes the panel EMITS against the classes the two sheets DEFINE. These four
 *   were emitted once each and defined nowhere, so they rendered at the browser's
 *   default: .aisg-consent-level and .aisg-consent-note are read by an operator
 *   while deciding what the guide may say, and an unstyled them made the decision
 *   row look identical to a decorative one.
 */

/* The per-object level cell. Monospaced so the five levels line up in a column,
   which is what makes an inconsistent grant visible at a glance. */
.aisg-consent-level {
	display: inline-block;
	min-width: 84px;
	padding: 2px 8px;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.06);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 11px;
	letter-spacing: 0.3px;
}

.aisg-consent-note {
	display: block;
	margin-top: 4px;
	font-size: 11px;
	line-height: 1.5;
	color: var(--aisg-ink-3);
}

/* A metric tile in its UNDECIDED state — distinct from ok/error, because
   "nobody has chosen yet" is not a failure and must not read as one. */
.aisg-metric-undecided .aisg-metric-value,
.aisg-metric-value.aisg-metric-undecided {
	color: var(--aisg-ink-3);
	font-style: italic;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
	/*
	 * ★ THIS OVERRIDE STAYS, BUT THE BASE MOVED (2026-10-09).
	 *
	 * `grid-template-columns` for `.aisg-grid-3` is now declared in the shell
	 * sheet (which always loads). A responsive override must still be able to
	 * collapse it after that base, so the selector is kept here — an override is
	 * an ADDITION at a narrower width, not a second base definition.
	 */
	.aisg-grid-3 { grid-template-columns: minmax(0, 1fr); }
	.aisg-cards-grid-3,
	.aisg-cards-grid-4 { grid-template-columns: minmax(0, 1fr); }
	.aisg-cards-grid-2,
	.aisg-cards-grid-1-2,
	.aisg-cards-grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 782px) {
	.aisg-wrap { margin-left: 0; width: 100%; }
	.aisg-topbar { height: auto; min-height: 44px; padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
	.aisg-field-row { grid-template-columns: minmax(0, 1fr); }
	.aisg-tab { padding: 9px 12px; font-size: 12px; }
	.aisg-input { max-width: 100%; }
}

/*
 * ★ `.aisg-card-body` PADDING/TEXT REMOVED — OWNED BY THE SHELL SHEET
 * (2026-10-09). These two rules re-declared padding and paragraph size for a
 * class the shell sheet already defines. The shell's version is the CT one
 * (`flex: 1` + `min-width: 0` + 14px/1.5). The duplicate here made `.aisg-card-body`
 * text 13px/1.65 on the back end and 14px/1.5 on the front end — a one-pixel
 * difference nobody would name but everybody would see as "the front end looks
 * off". The `.aisg-card-body` rules that genuinely ADD to the base (the
 * `.aisg-setup-guide` display override in the shell sheet) are untouched.
 *
 * ★ WHAT REMAINS HERE IS ONLY STATE, NOT BASE — a modifier is an addition, so
 * these cannot re-open the drift.
 */
.aisg-card-pending { border-style: dashed; }

.aisg-card-error { border-color: rgba(248, 113, 113, 0.45); }
