/*
 * WP-admin content styling for BareDykk DiveSafe's own screens (§31).
 * WP-admin's own chrome (header, notices) stays native WordPress — this file
 * styles content INSIDE `.bds-admin-wrap`, using the same `--bd-*` tokens and
 * the same `.bd-status`/`.bd-empty` class names as the PWA (app/styles/app.css)
 * so both surfaces read as one product. Loaded together with bd-tokens.css
 * (see AdminAssets); never hardcodes a hex value outside that token file.
 *
 * ONE DELIBERATE EXCEPTION (D-85, bottom of this file): the admin menu's own
 * group headings. Everything there is scoped to `#adminmenu .wp-submenu
 * li.bds-menu-group` — a class only DiveSafe's own submenu rows ever carry —
 * so no WordPress chrome outside our section is affected, and because this
 * file only loads on DiveSafe screens, wp-admin at large is untouched.
 */

.bds-admin-wrap {
  font-family: var(--bd-font-body);
  color: var(--bd-text);
  max-width: 1100px;
}

.bds-admin-wrap h1,
.bds-admin-wrap h2,
.bds-admin-wrap h3 {
  font-family: var(--bd-font-head);
}

/*
 * D-41 header row: brand + title on the left, "Til Min side" link + theme
 * toggle on the right (AbstractAdminPage::renderPageHeader()). Wraps on
 * narrow viewports (360px, WCAG 2.2 AA) rather than overflowing.
 */
.bds-admin-wrap .bds-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.bds-admin-wrap .bds-admin-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

/*
 * D-75 pt.2 "midlertidig Safe Dive-lockup" — text-free mask icon + real
 * "Safe Dive"/"by Bare Dykk" HTML text ({@see
 * \BareDykk\DiveSafe\Admin\Support\Html::safeDiveLockup()}'s own doc comment
 * carries the full rationale), shared by every wp-admin page header
 * (`AbstractAdminPage::renderPageHeader()`) and the WooCommerce "Min side"
 * dashboard card (`MyAccountCardRenderer`) — both surfaces load THIS
 * stylesheet inside `.bds-admin-wrap`. LIGHT-SURFACE palette
 * (`--bd-text`/`--bd-orange-text`, theme-following): the PWA's own sibling,
 * `.bd-lockup` in `app/styles/app.css`, is the fixed-"inverse" variant for
 * its permanently-dark surfaces — never mixed into this file.
 */
.bds-admin-wrap .bds-lockup {
  /*
   * `flex`, not `inline-flex`: inside `AbstractAdminPage`'s `<h1
   * class="bds-admin-page-title">` (itself `display:flex`, above) this is a
   * flex item either way, sitting beside the page-title text on one row.
   * Inside `MyAccountCardRenderer`'s plain `.bd-card` (no flex parent) this
   * MUST be block-level so it lands on its own row above the status
   * badge/heading that follows it in source order, instead of wrapping
   * inline beside them the way the single-line `.bd-eyebrow` span it
   * replaces used to.
   */
  display: flex;
  align-items: center;
  gap: 8px;
}

.bds-admin-wrap .bds-lockup__icon {
  display: block;
  flex: none;
  width: 24px;
  height: 24px;
}

.bds-admin-wrap .bds-lockup__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.bds-admin-wrap .bds-lockup__title {
  font-family: var(--bd-font-head);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--bd-text);
}

.bds-admin-wrap .bds-lockup__sub {
  font-family: var(--bd-font-mono);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bd-orange-text);
}

.bds-admin-wrap .bds-admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- D-41 "Til Min side" return-link ---- */

.bds-admin-wrap .bds-admin-header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--bd-touch-min);
  padding: 0 12px;
  border-radius: var(--bd-radius-sm);
  color: var(--bd-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.bds-admin-wrap .bds-admin-header-link:hover {
  color: var(--bd-orange-text);
  background: var(--bd-grey);
}

/* ---- D-41 admin light/dark theme toggle ----
 *
 * Both icons are always in the DOM; only one is shown at a time, keyed on
 * `.bds-admin-wrap[data-theme]` — the same "both rendered, CSS shows one"
 * technique `app/styles/app.css` uses for the PWA header's light/dark brand
 * logo pair, so no JS is required just to paint the right icon.
 */
.bds-admin-wrap .bds-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--bd-touch-min);
  height: var(--bd-touch-min);
  border: none;
  border-radius: var(--bd-radius-sm);
  background: var(--bd-grey);
  color: var(--bd-icon-stroke);
  cursor: pointer;
}

.bds-admin-wrap .bds-theme-toggle:hover {
  background: var(--bd-line);
}

.bds-admin-wrap .bds-theme-toggle__icon {
  display: none;
}

.bds-admin-wrap .bds-theme-toggle__icon--moon {
  display: inline-flex;
}

.bds-admin-wrap[data-theme='dark'] .bds-theme-toggle__icon--moon {
  display: none;
}

.bds-admin-wrap[data-theme='dark'] .bds-theme-toggle__icon--sun {
  display: inline-flex;
}

.bds-admin-wrap .bd-eyebrow {
  font-family: var(--bd-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
  color: var(--bd-muted);
}

/* ---- Status badges (UX-003: colour + icon + text, never colour alone) ---- */

.bds-admin-wrap .bd-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.bds-admin-wrap .bd-status--ok {
  color: var(--bd-ok);
}

.bds-admin-wrap .bd-status--warn {
  color: var(--bd-warn-text);
}

.bds-admin-wrap .bd-status--sale {
  color: var(--bd-sale);
}

.bds-admin-wrap .bd-status--info {
  color: var(--bd-info);
}

/* Same 22px as the `width`/`height` the markup itself carries
 * (`Html::statusBadge()`), so the styled and unstyled renderings of this badge
 * are one component at one size — and 22px IS the design system's icon floor
 * ("hand-drawn SVG line icons … 22-40px", mirrored by the PWA's
 * `app/components/icons/Icons.tsx` SIZING CONVENTION, which names StatusBadge
 * as having no inline-with-text exception). v2.2.1 fourth-round design finding
 * 2, MIDDELS: the previous round made the SVG self-bearing but cast the
 * below-floor 16px into the markup. */
.bds-admin-wrap .bd-status__icon {
  flex: none;
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.bds-admin-wrap .bd-status__label {
  color: var(--bd-text);
}

/*
 * ---- Alerts (D-67 STRAKSTILTAK "Foreløpig oversikt"-banneret + reusable
 * for any future admin info/success/warn/error notice) ----
 *
 * Mirrors the PWA's own `.bd-alert`/`.bd-alert--*` pattern
 * (app/styles/app.css) byte-for-byte in structure — same class names, same
 * `--bd-*` tokens, same four hand-drawn glyphs — so an admin banner and a PWA
 * banner read as one component. Only `--bd-*` tokens; dark mode is automatic
 * (no per-component dark rule, CLAUDE.md).
 *
 * UX-003 IS ENFORCED ON THE CLASS, NOT ON THE CALL SITES (v2.2.1 third-round
 * design finding 2, MIDDELS): the PWA twin got its automatic `::before` glyph
 * in an earlier round, this admin twin did not — so an admin `.bd-alert` with
 * no icon of its own rendered COLOUR + TEXT ONLY, which is exactly the failure
 * mode UX-003 names ("Status vises ALLTID med farge + ikon + tekst — aldri
 * farge alene"). Every variant now carries its own glyph, so
 * `<div class="bd-alert bd-alert--warn">…</div>` is compliant the moment it is
 * written.
 *
 * WHY A MASK RATHER THAN A `background-image` — identical reasoning to
 * app/styles/app.css's own note: the glyph's visible colour is
 * `background-color: currentColor`, i.e. the variant rule's `--bd-*` semantic
 * token, so it is correct in BOTH themes with no dark-mode override. The SVG in
 * `url()` is a MASK, whose ALPHA channel alone is read — the `stroke='black'`
 * literal is an opacity stencil, never a colour on screen, so "aldri hardkodet
 * hex" holds. The four glyphs are the SAME paths as the PWA's `Icons.tsx`
 * InfoIcon / CheckCircleIcon / AlertTriangleIcon / XCircleIcon (24-unit
 * viewBox, 1.8 stroke, round caps and joins) — hand-drawn SVG line icons, never
 * an icon font.
 *
 * ACCESSIBILITY: a `content: ''` pseudo-element contributes nothing to the
 * accessibility tree, so the glyph is inherently `aria-hidden` — the alert's own
 * visible text keeps carrying the meaning, and no redundant announcement can
 * leak into a screen reader.
 */
.bds-admin-wrap .bd-alert {
  /* Fallback glyph for a bare `.bd-alert` with no variant class: an alert
     without a severity is informational, so it gets the same neutral "i" as
     `.bd-alert--info`. Never `none` — that would reopen colour-alone. */
  --bd-alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5'/%3E%3Ccircle cx='12' cy='8' r='0.15' fill='black'/%3E%3C/svg%3E");
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--bd-radius-sm);
  border: 1px solid var(--bd-line);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.bds-admin-wrap .bd-alert::before {
  content: '';
  flex: 0 0 auto;
  /* Top-aligned, not centred: an alert body is often several lines, where a
     vertically centred glyph drifts away from the sentence it belongs to. */
  align-self: flex-start;
  /* 22px is the design system's icon floor — the same size Html::infoIcon()
     defaults to. */
  width: 22px;
  height: 22px;
  /* Optically seats the glyph on the first 0.92rem text line. */
  margin-top: 1px;
  background-color: currentColor;
  -webkit-mask: var(--bd-alert-icon) no-repeat center / contain;
  mask: var(--bd-alert-icon) no-repeat center / contain;
}

/*
 * The call site that ALREADY renders its own `Html::*Icon()` glyph as the
 * alert's first child (`Admin\Pages\CalendarPage` → `Html::infoIcon()` inside
 * `.bd-alert__icon`) keeps its own — the automatic one would be a duplicate.
 * DIRECT-CHILD SCOPED on purpose: a glyph nested deeper (inside a button in the
 * alert's body, say) must NOT strip the alert's own severity icon. Structurally
 * identical to app/styles/app.css's own de-duplication rule, so the two
 * stylesheets stay interchangeable.
 */
.bds-admin-wrap .bd-alert:has(> svg, > .bd-alert__icon)::before {
  content: none;
}

.bds-admin-wrap .bd-alert--info {
  /* Icons.tsx `InfoIcon` — circled "i". */
  --bd-alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5'/%3E%3Ccircle cx='12' cy='8' r='0.15' fill='black'/%3E%3C/svg%3E");
  border-color: var(--bd-info);
  color: var(--bd-info);
}

.bds-admin-wrap .bd-alert--success {
  /* Icons.tsx `CheckCircleIcon` — UX-003's "grønn hake". */
  --bd-alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8.5 12.3l2.4 2.4 4.6-5.4'/%3E%3C/svg%3E");
  border-color: var(--bd-ok);
  color: var(--bd-ok);
}

.bds-admin-wrap .bd-alert--warn {
  /* Icons.tsx `AlertTriangleIcon` — UX-003's "gul trekant". */
  --bd-alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4.2 21 19.6H3L12 4.2z'/%3E%3Cpath d='M12 10v4.2'/%3E%3Ccircle cx='12' cy='17' r='0.15' fill='black'/%3E%3C/svg%3E");
  /* --bd-warn-text, never --bd-warn, for text AND border: --bd-warn is only
     2.94:1 vs --bd-card, under WCAG 1.4.11's 3:1 non-text floor. The `::before`
     glyph inherits the same token through `currentColor`, so it clears that
     floor in both themes for free (same rationale as app/styles/app.css). */
  border-color: var(--bd-warn-text);
  color: var(--bd-warn-text);
}

.bds-admin-wrap .bd-alert--error {
  /* Icons.tsx `XCircleIcon` — UX-003's "rød blokkert". */
  --bd-alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M9 9l6 6M15 9l-6 6'/%3E%3C/svg%3E");
  border-color: var(--bd-sale);
  color: var(--bd-sale);
}

.bds-admin-wrap .bd-alert__icon {
  flex: none;
}

.bds-admin-wrap .bd-alert p {
  margin: 0;
  color: var(--bd-text);
}

/* ---- Cards / sections ---- */

.bds-admin-wrap .bd-card {
  background: var(--bd-card);
  border: 1px solid var(--bd-line);
  border-radius: var(--bd-radius);
  padding: 18px;
  margin-bottom: 16px;
}

.bds-admin-wrap .bd-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.bds-admin-wrap .bd-metric {
  font-family: var(--bd-font-head);
  font-size: 1.8rem;
  font-weight: 700;
}

.bds-admin-wrap .bd-metric-label {
  color: var(--bd-muted);
  font-size: 0.85rem;
}

/* D-82 "fiks det"-knapp på et metrikk-kort
 * ({@see DashboardPage::metric()} → {@see AdminFixItLink}). Spacing only —
 * the button itself is the shared `.button.bds-btn` rule further down, which
 * already carries the 48px touch minimum and the token colours. */
.bds-admin-wrap .bd-metric-action {
  margin-top: 10px;
}

/* ---- Tables ---- */

.bds-admin-wrap table.bds-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bd-card);
  border: 1px solid var(--bd-line);
  border-radius: var(--bd-radius);
  overflow: hidden;
}

.bds-admin-wrap table.bds-table th,
.bds-admin-wrap table.bds-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bd-line);
}

.bds-admin-wrap table.bds-table th {
  font-family: var(--bd-font-mono);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--bd-muted);
  background: var(--bd-grey);
}

/* D-86: numeric cells in the fyllelogg/fakturagrunnlag tables. Tabular figures
 * give every digit the same advance width, so a column of litres lines up on
 * the decimal and can be read down as a column instead of a ragged list — the
 * decision's own wording ("Bruk tabulære tall så kolonnene lar seg lese").
 * Right alignment overrides the `text-align: left` on `table.bds-table td`
 * above, which is why this rule follows it.
 *
 * Deliberately no colour and no token: this is number FORM, not status. A
 * figure's meaning is never carried by the alignment, so the rule is safe in
 * both themes and there is nothing here to duplicate under `[data-theme]`. */
.bds-admin-wrap table.bds-table th.bds-num,
.bds-admin-wrap table.bds-table td.bds-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  text-align: right;
  white-space: nowrap;
}

/* D-86: the period sum row lives in <tfoot>. Without this it renders as just
 * another body row, and "SUM" reads as one more customer. The heavier rule
 * above it is the separator; the weight is the emphasis. `--bd-line-strong`
 * (not a colour literal) keeps it correct in dark mode, and the distinction is
 * never colour alone — the row is also labelled "SUM"/"Sum for perioden". */
.bds-admin-wrap table.bds-table tfoot th,
.bds-admin-wrap table.bds-table tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--bd-line-strong);
}

/* A wide table (ConditionsPage's 8-column vær/hav timeline, FillLogPage's
 * 10-column "Fyllinger i utvalget") scrolls horizontally within its own
 * container instead of breaking the 360px/WCAG 2.2 AA layout — mirrors the
 * design fasit's `.bd-sctable-wrap` pattern
 * (docs/spec/bare-dykk-design-system-v1.0.html §08 "Tables",
 * docs/spec/baredykk-system.css lines 319–320). No token is needed here:
 * overflow behaviour, not colour.
 *
 * `min-width: 0` is what makes the SCROLL actually happen when this wrapper is
 * a grid/flex item: such an item's automatic minimum size is its content's
 * min-content width, so without this the wrapper is stretched wide enough to
 * hold the table and the PAGE scrolls sideways instead of the table.
 *
 * THE FLOOR ON THE TABLE IS THE OTHER HALF, and it is the half `overflow-x`
 * alone never gave us: `table.bds-table` is `width: 100%`, and an auto-layout
 * table happily squeezes down to its MIN-CONTENT width, so at 360px a
 * 10-column table does not overflow at all — it collapses into ten columns one
 * broken word wide. Nothing scrolls and nothing is readable. 560px is the
 * fasit's own figure for `.bd-sctable`; the wrapper is opt-in for wide tables
 * only, so every table that carries it wants at least that much. Tables with
 * more columns than the fasit's five push past the floor on their own (numeric
 * cells are `white-space: nowrap`, see `.bds-num` above) and simply scroll
 * further. */
.bds-admin-wrap .bds-table-wrap {
  overflow-x: auto;
  min-width: 0;
}

.bds-admin-wrap .bds-table-wrap > table.bds-table {
  min-width: 560px;
}

/* A <fieldset> is used purely as a "disable every control at once" wrapper
 * (ChecklistTemplatesPage's "Legg til punkt" when the schema is missing,
 * D-81/vaktfunn D). Reset the UA's default border/padding so the grouping is
 * invisible — the reason is carried by the `.description` note the fieldset is
 * aria-describedby-linked to, not by a box. `min-width: 0` keeps a fieldset
 * from forcing its grid children wider than the viewport (a long-standing
 * fieldset quirk) at 360px. */
.bds-admin-wrap fieldset.bds-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* ---- Empty / error states (design system "§14 .bd-empty") ---- */

.bds-admin-wrap .bd-empty {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--bd-line);
  border-radius: var(--bd-radius);
  background: var(--bd-card);
}

/* `color` is the GLYPH's colour, not just an inherited text colour: the SVG
 * `Html::emptyState()`/`Html::errorState()` render comes from `Html::icon()`,
 * which carries `fill="none" stroke="currentColor"` on the element itself. This
 * rule must never be the only thing painting the icon — a `<svg>` without those
 * two attributes falls back to SVG's own defaults (`fill: black; stroke: none`)
 * and no `color` here can reach it (v2.2.1 fourth-round design finding 1, HØY). */
.bds-admin-wrap .bd-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin-bottom: 12px;
  background: var(--bd-grey);
  color: var(--bd-icon-stroke);
}

.bds-admin-wrap .bd-empty__icon--error {
  color: var(--bd-sale);
}

.bds-admin-wrap .bd-empty p {
  color: var(--bd-muted);
  max-width: var(--bd-maxw-text);
  margin: 8px auto 0;
}

/*
 * ---- D-82 fix-it anchor destinations (v2.2.1 third-round design finding 4) ----
 *
 * A fix-it button whose destination is a section of the SAME page
 * ({@see \BareDykk\DiveSafe\Domain\FixIt\AdminFixItTarget}'s `$fragment`) has to
 * make the arrival visible — otherwise it reads as the pseudo-button it
 * replaced. `scroll-margin-top` keeps the target clear of WP-admin's sticky
 * toolbar, and the ring is the SAME `--bd-focus-ring` token every focusable
 * element already uses, so the landing spot is marked the way this design
 * system marks "here you are", in both themes, with no hardcoded colour.
 */
.bds-admin-wrap :target {
  scroll-margin-top: 48px;
  outline: var(--bd-focus-ring);
  outline-offset: 4px;
  border-radius: var(--bd-radius-sm);
}

/* ---- Buttons: operative surfaces keep the 48px minimum touch target ---- */

.bds-admin-wrap .button.bds-btn {
  min-height: var(--bd-touch-min);
  display: inline-flex;
  align-items: center;
  border-radius: var(--bd-radius-sm);
}

.bds-admin-wrap .bds-btn--danger {
  background: var(--bd-danger-btn-bg);
  border-color: var(--bd-danger-btn-bg);
  color: var(--bd-text-inv);
}

/* ---- Forms ----
 *
 * Product-owner order ("i dag har alt små bokser som er trykt inn i venstre
 * marg … på PC eller Tab er det fint om det bruker skjermen mere effektivt"):
 * `.bds-field` inputs/selects/textareas now fill the width of whatever
 * contains them (a plain form, a `.bds-form-grid` cell, or a narrow `<td>`)
 * instead of the browser's ~20-character default — this alone fixes the
 * "tiny box in the left margin" look everywhere `.bds-field` is already used,
 * not only inside a grid. `.bds-form-grid` (below) is the OPT-IN multi-column
 * layout for a page that wants to use a wide viewport's width; a page that
 * never adds it keeps today's single stacked column, just with full-width
 * controls. */

.bds-admin-wrap .bds-field {
  margin-bottom: 14px;
}

.bds-admin-wrap .bds-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.bds-admin-wrap .bds-field input:not([type="checkbox"]):not([type="radio"]),
.bds-admin-wrap .bds-field select,
.bds-admin-wrap .bds-field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.bds-admin-wrap .bds-field input:not([type="checkbox"]):not([type="radio"]),
.bds-admin-wrap .bds-field select {
  min-height: var(--bd-touch-min);
}

/* WordPress' own `.description` is #646970 — a literal grey that ignores our
 * dark theme and reads as a foreign colour next to `--bd-muted`. The rule used
 * to be scoped to `.bds-field .description`, which left every FREE-STANDING
 * `<p class="description">` (filter-form hints, section notes, the
 * `aria-describedby` note on `.bds-fieldset`) on WP's grey inside our own
 * pages. The scope is the WRAPPER, not the field: `.description` is our markup
 * wherever it appears inside `.bds-admin-wrap`, and it should be tokenised
 * everywhere it appears there. */
.bds-admin-wrap .description {
  color: var(--bd-muted);
}

.bds-admin-wrap .bds-field-error {
  color: var(--bd-sale);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---- Multi-column form layout ----
 *
 * Opt in via {@see \BareDykk\DiveSafe\Admin\Support\FormFieldsTrait::formGridOpen()}
 * (or, for pages that keep their own field-builder methods — DocumentsPage,
 * CoursesPage, SettingsPage — a literal `<div class="bds-form-grid">`
 * wrapper). `auto-fit`/`minmax()` mirrors the existing `.bd-card-grid`
 * pattern above: as many ~260px columns as the viewport fits, one column
 * once it cannot. `.bds-field--full` (a field builder's own `$fullWidth`
 * flag) spans every column — used for textareas/JSON bodies, which rarely
 * make sense split narrow.
 *
 * 782px is WP-admin's OWN responsive breakpoint (the point where the admin
 * menu itself collapses/folds — `wp-admin/css/common.css`), not a new value
 * invented here, so this page's own collapse-to-one-column point lines up
 * with the chrome around it. Below that (incl. 360px, WCAG 2.2 AA) the grid
 * is already a single column via the media query, and every input already
 * fills that column via the `.bds-field` rule above.
 */

.bds-admin-wrap .bds-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 24px;
  align-items: start;
}

.bds-admin-wrap .bds-form-grid > .bds-field {
  margin-bottom: 14px;
}

.bds-admin-wrap .bds-form-grid > .bds-field--full {
  grid-column: 1 / -1;
}

@media (max-width: 782px) {
  .bds-admin-wrap .bds-form-grid {
    grid-template-columns: 1fr;
  }
}

/* UX-002/WCAG: colour is never the only signal an input is invalid — the
 * border pairs with the linked .bds-field-error text (icon+colour+text is
 * covered by the error paragraph itself; this is the field-level pairing). */
.bds-admin-wrap .bds-field input[aria-invalid="true"],
.bds-admin-wrap .bds-field select[aria-invalid="true"],
.bds-admin-wrap .bds-field textarea[aria-invalid="true"] {
  border-color: var(--bd-sale);
}

/* ---- Document preview: broken merge fields must be IMPOSSIBLE to miss ----
 *
 * The admin preview renders the document as a diver will see it. A token that
 * could not be filled is wrapped in <mark> by
 * BareDykk\DiveSafe\Domain\Documents\MergeFieldEngine::renderPreview(). Colour
 * alone is never the signal (UX-003): the token text stays visible inside the
 * mark, and the block-level message above the body names every affected field.
 *
 * Both variants use semantic tokens, so they follow dark mode without their
 * own rules. Text colour is the AA-safe *-text token, never the raw hue.
 */

.bds-admin-wrap .bds-document-preview mark.bds-merge-unknown,
.bds-admin-wrap .bds-document-preview mark.bds-merge-unresolved {
  font-family: var(--bd-font-mono);
  padding: 0 4px;
  border-radius: var(--bd-radius-sm);
  background: transparent;
  border: 1px dashed currentColor;
}

.bds-admin-wrap .bds-document-preview mark.bds-merge-unknown {
  color: var(--bd-sale);
  border-style: solid;
}

.bds-admin-wrap .bds-document-preview mark.bds-merge-unresolved {
  color: var(--bd-warn-text);
}

.bds-admin-wrap .bds-preview-error {
  color: var(--bd-sale);
  margin: 0 0 8px;
}

.bds-admin-wrap .bds-preview-note {
  color: var(--bd-muted);
  margin: 0 0 8px;
}

/* ---- Dive report oversight (D-31 (d)): internal-feedback marking + photo
 * thumbnails ---- */

.bds-admin-wrap .bds-report-feedback-internal {
  border: 1px dashed var(--bd-line);
  border-radius: var(--bd-radius-sm);
  padding: 8px;
  background: var(--bd-grey);
}

.bds-admin-wrap .bds-report-feedback-internal > div {
  margin-top: 6px;
}

.bds-admin-wrap .bds-report-photo {
  list-style: none;
  margin-bottom: 10px;
}

.bds-admin-wrap .bds-report-photo-thumb-slot {
  display: block;
  margin-top: 6px;
}

.bds-admin-wrap .bds-report-photo-thumb {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--bd-line);
  border-radius: var(--bd-radius-sm);
}

/*
 * ---- D-40b "Forhold 2.0" admin/Min side parity ----
 *
 * Server-rendered GET-navigation equivalents of the PWA's `.bd-forhold-*`
 * classes (app/styles/app.css) — same class NAMES, same `--bd-*` tokens, so
 * the two surfaces read as one product even though the admin page renders
 * plain `<a>`/`<dl>` markup instead of React state. Used by both
 * {@see \BareDykk\DiveSafe\Admin\Pages\ConditionsPage} (day nav, view tabs,
 * Oversikt/Ikoner grids, trend, best-period filter/results) and the
 * WooCommerce "Sikkerhet og ansvar" tab's "Sjekk forholdene" card
 * ({@see \BareDykk\DiveSafe\Integration\WooCommerce\SafetyTabRenderer}) —
 * both wrap their content in `.bds-admin-wrap`, so these rules apply to
 * either surface without duplication.
 */

.bds-admin-wrap .bd-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--bd-muted);
}

.bds-admin-wrap .bd-forhold-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.bds-admin-wrap .bd-forhold-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--bd-touch-min);
  padding: 8px 16px;
  border-radius: var(--bd-radius);
  border: 2px solid var(--bd-line-strong);
  background: var(--bd-card);
  color: var(--bd-text);
  font-weight: 600;
  text-decoration: none;
}

.bds-admin-wrap .bd-forhold-tabs a:hover {
  border-color: var(--bd-orange-text);
}

.bds-admin-wrap .bd-forhold-tabs a.is-selected {
  border-color: var(--bd-orange-text);
  background: color-mix(in srgb, var(--bd-orange-text) 12%, var(--bd-card));
  color: var(--bd-orange-text);
}

.bds-admin-wrap .bd-forhold-daynav {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.bds-admin-wrap .bd-forhold-daynav__label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 160px;
  font-weight: 700;
  text-align: center;
}

.bds-admin-wrap .bd-forhold-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 12px;
}

.bds-admin-wrap .bd-forhold-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bds-admin-wrap .bd-forhold-summary-item dt {
  font-family: var(--bd-font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bd-muted);
}

.bds-admin-wrap .bd-forhold-summary-item dd {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.bds-admin-wrap .bd-forhold-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.bds-admin-wrap .bd-forhold-icon-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--bd-line);
  border-radius: var(--bd-radius);
  background: var(--bd-card);
  color: var(--bd-icon-stroke);
}

.bds-admin-wrap .bd-forhold-icon-card__label {
  font-family: var(--bd-font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bd-muted);
}

.bds-admin-wrap .bd-forhold-icon-card__value {
  color: var(--bd-text);
  font-weight: 600;
  font-size: 1rem;
}

.bds-admin-wrap .bd-forhold-trend {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 700;
}

.bds-admin-wrap .bd-forhold-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.bds-admin-wrap .bd-forhold-ranking-rules {
  margin: 0 0 16px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bds-admin-wrap .bd-forhold-result-card {
  border-color: var(--bd-line-strong);
}

/*
 * ---- D-41: dark mode, scoped to the DiveSafe admin container ----
 *
 * WP-admin's OWN chrome (menu, top toolbar, notices) is outside our control
 * and stays native WordPress light mode (D-41 "WP-chrome utenfor forblir
 * standard") — so unlike the PWA shell (which flips `html[data-theme]`,
 * assets/css/bd-tokens.css), the DiveSafe admin toggle flips `data-theme` on
 * `.bds-admin-wrap` ITSELF (AbstractAdminPage::renderThemeToggleButton() +
 * assets/js/admin/theme-toggle.js). Every `--bd-*` custom property therefore
 * has to be RE-DECLARED here, scoped to that same selector — a CSS custom
 * property does not "reach out" to an ancestor's attribute the way a plain
 * descendant selector does; it must be set on (or above) the element that
 * reads it.
 *
 * Values are a DELIBERATE, byte-for-byte copy of assets/css/bd-tokens.css's
 * `html[data-theme='dark']` block, so admin dark mode is pixel-identical to
 * the PWA's. That file is the SOURCE; this block is the copy, and it may never
 * hold a value of its own.
 *
 * THE COPY IS NOW BOUND, NOT MERELY DOCUMENTED (v2.2.1 third-round design
 * finding 3, LAV): `--bd-warn-text` had already drifted — #e2a748 here against
 * the source's #f1c57e (D-64 fasit refresh, 2026-07-21) — so admin dark mode
 * showed a different warning colour from the PWA, two truths for one token.
 * tests/Unit/Assets/AdminDarkTokenParityTest.php now parses BOTH files and
 * fails on any divergence, in either direction, for every token in the block.
 *
 * `background`/`padding` are ADDITIVE (not present in bd-tokens.css's own
 * block, which only ever painted the full-viewport `<html>`/`<body>`): in
 * light mode `.bds-admin-wrap` is intentionally transparent, letting
 * WP-admin's own near-white canvas show through the gaps between cards
 * (already visually close to `--bd-page`). In dark mode that same gap would
 * otherwise stay WP-admin's bright white, so the container paints its own
 * dark canvas across its full box instead — this is the "attribute-flip on
 * the container takes the whole surface" requirement (D-41).
 */
.bds-admin-wrap[data-theme='dark'] {
  --bd-page: #0f1315;
  --bd-card: #191d20;
  --bd-grey: #242a2e;
  --bd-text: #eef2f0;
  --bd-muted: #9aa1a5;
  --bd-orange-text: #fbc172;

  --bd-sale: #e76a52;
  --bd-ok: #52b282;
  --bd-warn: #e2a748;
  --bd-info: #63aace;
  /* See bd-tokens.css's light-mode --bd-danger-btn-bg comment — deliberately
     a fixed darker red, NOT a remap of dark-mode --bd-sale (6.20:1 vs #fff). */
  --bd-danger-btn-bg: #b23320;
  /* D-64 FASIT REFRESH (2026-07-21): --bd-warn-text has its OWN dark-mode
     figure, distinct from --bd-warn. 10.52:1 vs --bd-card, 12.15:1 vs
     --bd-page — see bd-tokens.css's own note. */
  --bd-warn-text: #f1c57e;

  --bd-line: #2c3236;
  --bd-line-strong: #6a7278;
  --bd-deep: #060708;
  --bd-icon-stroke: #fbc172;

  color-scheme: dark;
  background: var(--bd-page);
  padding: 16px;
  border-radius: var(--bd-radius);
}

/*
 * ---- D-60 "Kalender" (senterkalenderen) ----
 *
 * Everything below only reads `--bd-*` tokens, so it works in both themes
 * "for free" through the re-declared custom properties above — no separate
 * dark-mode block is added here (CLAUDE.md "nye komponenter skal virke i
 * begge temaer uten egne dark-regler").
 */

.bds-admin-wrap .bds-calendar-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.bds-admin-wrap .bds-calendar-nav__label {
  font-family: var(--bd-font-head);
}

/* The month grid's own <table> loses the default .bds-table cell padding
 * (each day is its own tappable card, not a data row) while KEEPING the
 * shared border/radius/background chrome. */
.bds-admin-wrap table.bds-calendar {
  table-layout: fixed;
}

.bds-admin-wrap table.bds-calendar th,
.bds-admin-wrap table.bds-calendar td.bds-calendar-day-cell {
  padding: 4px;
  vertical-align: top;
}

.bds-admin-wrap .bds-calendar-day {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 56px;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: var(--bd-radius-sm);
  border: 1px solid transparent;
  color: var(--bd-text);
  text-decoration: none;
  background: var(--bd-card);
}

.bds-admin-wrap .bds-calendar-day:hover {
  border-color: var(--bd-line-strong);
}

.bds-admin-wrap .bds-calendar-day--load-1 {
  background: color-mix(in srgb, var(--bd-info) 12%, var(--bd-card));
}

.bds-admin-wrap .bds-calendar-day--load-2 {
  background: color-mix(in srgb, var(--bd-info) 26%, var(--bd-card));
}

.bds-admin-wrap .bds-calendar-day--load-3 {
  background: color-mix(in srgb, var(--bd-info) 42%, var(--bd-card));
}

.bds-admin-wrap .bds-calendar-day--today {
  border-color: var(--bd-orange-text);
  border-width: 2px;
}

.bds-admin-wrap .bds-calendar-day--selected {
  outline: 2px solid var(--bd-line-strong);
  outline-offset: -2px;
}

.bds-admin-wrap .bds-calendar-day--blank {
  background: transparent;
  border: none;
}

.bds-admin-wrap .bds-calendar-day__date {
  font-family: var(--bd-font-head);
  font-weight: 700;
}

.bds-admin-wrap .bds-calendar-day__bookings,
.bds-admin-wrap .bds-calendar-day__journals {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--bd-font-mono);
  font-size: 0.72rem;
  color: var(--bd-muted);
}

.bds-admin-wrap .bds-calendar-day__journals {
  color: var(--bd-orange-text);
}

.bds-admin-wrap .bds-calendar-stay-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bds-admin-wrap .bds-calendar-dive-day {
  border: 1px solid var(--bd-line);
  border-radius: var(--bd-radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.bds-admin-wrap .bds-calendar-dive-list {
  margin: 4px 0 0;
  padding-left: 20px;
}

/*
 * D-85's admin-submenu group headings USED to live here. They now live in
 * `assets/css/admin-menu.css`, which is enqueued on EVERY wp-admin screen
 * rather than only on `bds-*` ones: this file is DiveSafe-screen-only, so the
 * headings appeared only once the operator was already inside Safe Dive —
 * exactly the case where they are least needed. That file is strictly scoped
 * to `#adminmenu .wp-submenu li.bds-menu-group` and declares the handful of
 * `--bd-*` values it needs on the selector itself, so it can be loaded
 * site-wide in wp-admin without dragging in `bd-tokens.css`'s global base
 * reset.
 */
