/* Custom admin pages (dashboard, control panel, media gallery, skills library, socials matrix, jobs).
   Loaded on every admin page through UNFOLD["STYLES"]. Colours are unfold's variables, which core/theme.py builds from
   the design theme. The status colours below are fixed OKLCH values on the design tokens' status hues (success 150,
   warning 70, danger 25; copied, not read from the tokens). Radii use the token scale (sm 6px, md 10px).
   `.dark` is unfold's dark mode class on <html>. */

:root {
  --ae-ok-bg: oklch(95% 0.05 150);   --ae-ok-fg: oklch(38% 0.1 150);
  --ae-warn-bg: oklch(95% 0.06 70);  --ae-warn-fg: oklch(42% 0.1 70);
  --ae-bad-bg: oklch(95% 0.04 25);   --ae-bad-fg: oklch(45% 0.16 25);
  --ae-surface: #fff;
  --ae-line: var(--color-base-200);
  --ae-text: var(--color-base-700);
  --ae-muted: var(--color-base-500);
}
.dark {
  --ae-ok-bg: oklch(32% 0.06 150);   --ae-ok-fg: oklch(88% 0.09 150);
  --ae-warn-bg: oklch(34% 0.06 70);  --ae-warn-fg: oklch(90% 0.09 70);
  --ae-bad-bg: oklch(32% 0.07 25);   --ae-bad-fg: oklch(88% 0.08 25);
  --ae-surface: var(--color-base-900);
  --ae-line: var(--color-base-800);
  --ae-text: var(--color-base-200);
  --ae-muted: var(--color-base-400);
}

.ae-intro { max-width: 65ch; margin: 0 0 16px; line-height: 1.55; color: var(--ae-muted); }
.ae-intro code, .ae-card code, .ae-table code { font-size: 12px; overflow-wrap: anywhere; }
.ae-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 8px 0 16px; }
.ae-bar label { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; font-weight: 500; }
.ae-bar select { min-height: 36px; max-width: 100%; padding: 0 8px; border: 1px solid var(--ae-line);
  border-radius: 6px; background: var(--ae-surface); color: var(--ae-text); }

.ae-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--ae-line); border-radius: 6px; background: var(--ae-surface); color: var(--ae-text);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.ae-btn:hover { border-color: var(--color-base-400); }
.ae-btn:focus-visible { outline: 2px solid var(--color-primary-500); outline-offset: 2px; }
.ae-btn-primary, .ae-btn[aria-current="page"] { background: var(--color-primary-600);
  border-color: var(--color-primary-600); color: #fff; }
.ae-btn-primary:hover, .ae-btn[aria-current="page"]:hover { background: var(--color-primary-700); }
form.ae-inline { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.ae-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.ae-grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.ae-grid-media { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.ae-card { min-width: 0; padding: 12px 16px; border: 1px solid var(--ae-line); border-radius: 10px;
  background: var(--ae-surface); color: var(--ae-text); }
.ae-card h2, .ae-h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.ae-h2 { margin-top: 24px; }
.ae-mt-0 { margin-top: 0; }
.ae-mt-4 { margin-top: 16px; }
.ae-mb-0 { margin-bottom: 0; }
.ae-mb-6 { margin-bottom: 24px; }
a.ae-card { display: block; text-decoration: none; }
a.ae-card:hover { border-color: var(--color-base-400); }
.ae-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--ae-line); }
.ae-row:first-of-type { border-top: 0; }
.ae-grow { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.ae-card .ae-muted { max-width: 70ch; }  /* a note in a card is a paragraph: keep its lines readable */
.ae-muted { display: block; color: var(--ae-muted); font-size: 12px; overflow-wrap: anywhere; }
.ae-stat { font-size: 24px; font-weight: 600; line-height: 1.2; }
.ae-stats { display: grid; grid-template-columns: repeat(var(--ae-cols, 2), minmax(0, 1fr)); gap: 12px 16px; margin: 8px 0; }
.ae-stats-3 { --ae-cols: 3; }  /* a column count that divides the items, so no lone item on the last row */
.ae-health { margin: 0 0 12px; }

.ae-badge { display: inline-block; padding: 2px 8px; border: 1px solid var(--ae-line); border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; }
.ae-ok { background: var(--ae-ok-bg); color: var(--ae-ok-fg); border-color: transparent; }
.ae-warn { background: var(--ae-warn-bg); color: var(--ae-warn-fg); border-color: transparent; }
.ae-bad { background: var(--ae-bad-bg); color: var(--ae-bad-fg); border-color: transparent; }

.ae-table-wrap { overflow-x: auto; border: 1px solid var(--ae-line); border-radius: 10px; background: var(--ae-surface); }
.ae-table { width: 100%; border-collapse: collapse; color: var(--ae-text); }
.ae-table th, .ae-table td { padding: 8px 12px; border-bottom: 1px solid var(--ae-line); text-align: left; vertical-align: top; }
.ae-table thead th { font-weight: 600; white-space: nowrap; }
/* links in tables and cards are tap targets: at least 24px tall (WCAG 2.5.8) */
.ae-table a, .ae-card h2 a, .ae-card p a { display: inline-flex; align-items: center; min-height: 24px; }
.ae-card p a.ae-btn { min-height: 36px; }  /* the rule above would otherwise win over .ae-btn */
.ae-card h2 a { min-height: 32px; }
@media (pointer: coarse) { .ae-card p a.ae-btn, .ae-card h2 a { min-height: 44px; } }
.ae-table tbody tr:last-child td, .ae-table tbody tr:last-child th { border-bottom: 0; }
.ae-pre { margin: 0; padding: 12px; border: 1px solid var(--ae-line); border-radius: 10px; background: var(--ae-surface);
  color: var(--ae-text); white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 12px; }

.ae-media { display: grid; place-items: center; aspect-ratio: 1 / 1; background: var(--color-base-100); }
.dark .ae-media { background: var(--color-base-800); }
.ae-media img, .ae-media video { width: 100%; height: 100%; object-fit: cover; }
.ae-media-card { padding: 0; overflow: hidden; }
.ae-media-card .ae-meta { padding: 8px 12px; font-size: 13px; }

/* unfold's own controls, lifted to the house rules (rule 01): 24px tap targets (WCAG 2.5.8) and a visible keyboard
   focus. Scoped to unfold's stable ids/classes; re-run the design reviewer after upgrading django-unfold. The "..."
   toggle (lg:hidden) is left out: an id selector would beat its class and show it on desktop, where it does nothing. */
#header-inner a:not(.lg\:hidden), .toplinks a, #result_list thead th a, .sortoptions a, .sortremove {
  display: inline-flex; align-items: center; min-height: 24px; min-width: 24px; }
#searchbar-submit { min-height: 24px; min-width: 24px; justify-content: center; }
#result_list input[type="checkbox"], #action-toggle { width: 24px; height: 24px; min-width: 24px; }
#searchbar:focus-visible, #searchbar-submit:focus-visible, .sortremove:focus, #result_list input:focus-visible,
#action-toggle:focus-visible, #content input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-primary-500); outline-offset: 2px; transition: none; }
/* unfold's on/off switch (BooleanField): 24px tall, knob re-centred */
#content input[type="checkbox"].rounded-full { height: 24px; width: 44px; min-width: 44px; }
#content input[type="checkbox"].rounded-full::after { width: 16px; height: 16px; top: 4px; left: 4px; }
#content input[type="checkbox"].rounded-full:checked::after { left: 24px; }
#result_list tbody a { display: inline-flex; align-items: center; min-height: 24px; }
/* unfold's index (the app list, used when the project has no per-site dashboard): section, model and add/change links */
#content .module h2 a.section, #content .module th[scope="row"] a { display: inline-flex; align-items: center; min-height: 24px; }
#content .module td a.changelink, #content .module td a.addlink { height: 24px; min-height: 24px; }

/* the review page: article preview, reviewer panel, actions */
.ae-split { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .ae-split { grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); align-items: start; } }
.ae-article { max-width: 56ch; line-height: 1.6; color: var(--ae-text); }
.ae-article h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.25; }
.ae-article h2, .ae-article h3 { margin: 20px 0 6px; font-size: 18px; }
.ae-article p, .ae-article ul, .ae-article ol, .ae-article blockquote { margin: 0 0 12px; }
.ae-article blockquote { padding-left: 12px; border-left: 3px solid var(--ae-line); color: var(--ae-muted); }
.ae-dek { margin: 0 0 16px; font-style: italic; color: var(--ae-muted); }
.ae-article a { text-decoration: underline; }
.ae-article ins, .ae-card ins { background: var(--ae-ok-bg); color: var(--ae-ok-fg); text-decoration: none; }
.ae-article del, .ae-card del { background: var(--ae-bad-bg); color: var(--ae-bad-fg); }
.ae-field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-weight: 500; }
.ae-field input[type="text"], .ae-field input[type="number"], .ae-field textarea, .ae-field select {
  width: 100%; max-width: 100%; padding: 8px; border: 1px solid var(--ae-line); border-radius: 6px;
  background: var(--ae-surface); color: var(--ae-text); font: inherit; font-weight: 400; }
#content .ae-field input[type="text"], #content .ae-field input[type="number"], #content .ae-field select { min-height: 36px; }
.ae-field textarea { min-height: 96px; resize: vertical; }
.ae-field input:focus-visible, .ae-field textarea:focus-visible, .ae-field select:focus-visible {
  outline: 2px solid var(--color-primary-500); outline-offset: 2px; }
.ae-check { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; }
.ae-check input { width: 24px; height: 24px; min-width: 24px; }
.ae-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.ae-btn-bad { background: var(--ae-bad-bg); color: var(--ae-bad-fg); border-color: transparent; }
.ae-details { margin: 0 0 12px; }
.ae-details summary { display: inline-flex; align-items: center; min-height: 36px; cursor: pointer; font-weight: 600; }
.ae-bar-track { height: 8px; border-radius: 4px; background: var(--color-base-200); overflow: hidden; }
.dark .ae-bar-track { background: var(--color-base-800); }
.ae-bar-fill { height: 100%; background: var(--color-primary-600); }
.ae-scorerow { display: grid; grid-template-columns: 7rem minmax(0, 1fr) 2rem; gap: 8px; align-items: center; margin: 4px 0; }
.ae-list { margin: 0; padding-left: 20px; }
.ae-list li { margin: 2px 0; overflow-wrap: anywhere; }
.ae-list a, .ae-article a { display: inline-flex; align-items: center; min-height: 24px; }
.ae-details summary { padding: 0 4px; }
.ae-details { min-height: 36px; }
/* checkbox lists in forms (unfold draws them 20px): 24px tap targets */
#content input[type="checkbox"]:not(.rounded-full) { width: 24px; height: 24px; min-width: 24px; }
.ae-table-wrap { overflow-x: auto; }
