# Admin Design System

The design language for the admin backend. One stylesheet defines every colour,
radius, spacing step, type size, shadow and transition; everything else consumes
it through CSS custom properties.

**Source of truth:** `public/backend/assets/css/design-system.css`
**Loaded from:** `resources/views/admin/layouts/css.blade.php` — last in the
chain, after Bootstrap 4.3.1, the legacy theme (`site.min.css`, `bakeology.css`,
`row.css`, `v1.css`, `custom.css`, `inner.css`) and the vendor widgets
(toastr, SweetAlert, Dropify, Nestable), so it can normalise all of them.

This is a **light-only** system. There is no dark mode and no `prefers-color-scheme`
override. If dark mode is added later, redefine the semantic tokens in section 1
under a `[data-theme="dark"]` block — no component rule should need to change.

---

## 1. Principles

1. **Change values in the token block, never in a component.** If you find
   yourself typing a hex code or a pixel radius in a Blade file, the token you
   need either exists or should be added.
2. **One accent.** Indigo `#5b6af0` is the only brand colour. Colour that isn't
   the accent or a neutral must mean something: green = success, red = destructive,
   amber = warning, blue = informational.
3. **Six radii, no more.** Every rounded corner in the admin maps to one of the
   six steps below.
4. **Every focusable element shows a ring.** Same ring, same offset, everywhere.
5. **Density over decoration.** This is a working CMS. Prefer a 13px table row
   and a clear hierarchy to large type and heavy shadows.

---

## 2. Colour

### Brand

| Token | Value | Use |
|---|---|---|
| `--ds-accent` | `#5b6af0` | Primary buttons, links, active nav, focus |
| `--ds-accent-hover` | `#4a59d4` | Hover / pressed |
| `--ds-accent-active` | `#3f4dbb` | Active (pressed) fill |
| `--ds-accent-tint` | `#eceeff` | Active nav background, soft badges |
| `--ds-accent-tint-hover` | `#d8dcfd` | Hover on a tinted surface |
| `--ds-accent-border` | `#c7d2fe` | Outline-button border, drop targets |

### Neutrals

`--ds-white`, `--ds-grey-25`, `-50`, `-100`, `-200`, `-300`, `-400`, `-500`,
`-600`, `-700`, `-800`, `-900`. Use the semantic aliases below in components;
reach for a raw grey only when no semantic token fits.

### Semantic surfaces and text

| Token | Value | Use |
|---|---|---|
| `--ds-bg` | `#f5f6fa` | App canvas behind cards |
| `--ds-surface` | `#ffffff` | Cards, modals, table body |
| `--ds-surface-sunk` | `#f9fafb` | Table headers, input addons, footers |
| `--ds-surface-hover` | `#fafafb` | Table row hover |
| `--ds-border` | `#e5e7eb` | Default 1px divider, input border |
| `--ds-border-strong` | `#d1d5db` | Input border on hover |
| `--ds-border-subtle` | `#f3f4f6` | Row separators inside a card |
| `--ds-text` | `#000000` | Body copy, table cells |
| `--ds-text-heading` | `#000000` | Headings, card and modal titles |
| `--ds-text-muted` | `#000000` | Secondary copy, help text |
| `--ds-text-subtle` | `#000000` | Placeholders, disabled, meta |
| `--ds-text-invert` | `#ffffff` | Text on a filled or dark surface |

**There is no grey text in this system.** Text is black on light surfaces and
white on dark ones — nothing in between. The four token names above all resolve
to black; they are kept distinct so intent stays readable at the call site and
so a future change (say, softening secondary copy) is a one-line edit.

Because colour can no longer carry hierarchy, **hierarchy comes from size,
weight, case and tracking.** A table head label and a table cell are both black
at 14–15px; the head is what it is because it's 600 weight, uppercase, with
`.04em` tracking. Lean on those levers, not on a lighter colour.

Grey still does real work — it is just never text: `--ds-grey-50/100` for hover
and sunk backgrounds, `--ds-grey-200/300` for borders and icon strokes,
`--ds-grey-300/400` for scrollbars. Disabled states use **opacity**, not a
grey fill.

### Status

Each status has four tokens — base, `-hover`, `-tint` (background) and
`-border`. Use base on text or a filled button; use tint + border for a soft
badge or alert.

| Status | Base | Hover | Tint | Border |
|---|---|---|---|---|
| `--ds-success` | `#16a34a` | `#15803d` | `#f0fdf4` | `#bbf7d0` |
| `--ds-danger` | `#dc2626` | `#b91c1c` | `#fef2f2` | `#fecaca` |
| `--ds-warning` | `#d97706` | `#b45309` | `#fffbeb` | `#fde68a` |
| `--ds-info` | `#2563eb` | `#1d4ed8` | `#eff6ff` | `#bfdbfe` |

### Category accent

`--ds-purple` `#9333ea` / `--ds-purple-tint` `#fdf4ff` — **decorative only.** Use it
to tell dashboard tiles apart when a status colour would falsely imply
success, warning or error. Never use it to communicate state.

---

## 3. Radius

Six steps. Pick by component, not by eye.

| Token | Value | Use |
|---|---|---|
| `--ds-radius-xs` | `4px` | Tag chips, checkbox |
| `--ds-radius-sm` | `6px` | Icon buttons, small controls, thumbnails, pagination |
| `--ds-radius-md` | `8px` | Buttons, inputs, selects, dropdowns, alerts |
| `--ds-radius-lg` | `12px` | Cards, panels, table cards |
| `--ds-radius-xl` | `16px` | Modals, overlays |
| `--ds-radius-pill` | `999px` | Badges, counters, switches |
| `--ds-radius-circle` | `50%` | Avatars, status dots |

---

## 4. Spacing

4px base scale. Use these for padding, margin and gap.

`--ds-space-1` 4 · `-2` 8 · `-3` 12 · `-4` 16 · `-5` 20 · `-6` 24 · `-8` 32 · `-10` 40

Standard paddings: card body `--ds-space-5`, card header `--ds-space-3`
vertical / `--ds-space-5` horizontal, table cell `--ds-space-3` / `--ds-space-4`.

---

## 5. Type

Font: `--ds-font` — `'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif`.

**Nothing in the admin renders below 14px.**

| Token | Size | Use |
|---|---|---|
| `--ds-text-2xs` | 14px | Sidebar section eyebrows |
| `--ds-text-xs` | 14px | Table head labels, badges |
| `--ds-text-sm` | 14px | Meta, help text, breadcrumbs |
| `--ds-text-md` | 15px | Dense UI default — buttons, table cells, nav |
| `--ds-text-base` | 16px | Body, form inputs, modal copy |
| `--ds-text-lg` | 18px | Card titles, modal titles, page title in the shell |
| `--ds-text-xl` | 20px | Page title |
| `--ds-text-2xl` | 24px | Dashboard stat figures |

The 14px floor collapses what used to be four separate small steps
(10/11/12/13px), so **`2xs`, `xs` and `sm` are all 14px**. They stay as three
names because they mark three different intents, but they no longer differ
visually by size — the distinction is carried by weight, case and tracking
instead. If you need a genuinely smaller step later, the floor is the thing to
revisit.

Weights: `--ds-weight-normal` 400 · `-medium` 500 · `-semibold` 600 · `-bold` 700.
Headings are 600. Table head labels are 600 uppercase with `.04em` tracking —
that treatment, not a smaller size, is what separates them from cell text.

Line height: `--ds-leading-tight` 1.25 (headings) · `--ds-leading-body` 1.55 (copy).

---

## 6. Elevation

| Token | Use |
|---|---|
| `--ds-shadow-xs` | Cards at rest (nearly flat — borders do the work) |
| `--ds-shadow-sm` | Sidebar, topbar |
| `--ds-shadow-md` | Dropdowns, toasts |
| `--ds-shadow-lg` | Off-canvas sidebar on mobile |
| `--ds-shadow-xl` | Modals |

Cards are separated by a 1px border first and a shadow second. Do not stack a
heavy shadow on a bordered card.

---

## 7. Focus

```css
--ds-ring:         0 0 0 3px rgba(91, 106, 240, .28);
--ds-ring-danger:  0 0 0 3px rgba(220, 38, 38, .24);
--ds-ring-success: 0 0 0 3px rgba(22, 163, 74, .24);
```

Applied globally to `a`, `button`, `input`, `select`, `textarea`, `.btn` and
`.form-control` via `:focus-visible`. Destructive and success controls use their
matching ring. **Never set `outline: none` without providing a ring.**

---

## 8. Motion

`--ds-ease` `cubic-bezier(.4,0,.2,1)` · `--ds-dur-fast` 140ms · `--ds-dur-mid` 240ms.

Use `fast` for hover and colour changes, `mid` for entrances and layout shifts.
Animate `background-color`, `border-color`, `color`, `box-shadow`, `opacity`,
`transform` — never `width`, `height` or `padding`.

`prefers-reduced-motion: reduce` is honoured globally; do not add motion that
carries meaning on its own.

---

## 9. Controls

Every interactive control shares one height so rows of mixed controls align.

| Token | Value | Use |
|---|---|---|
| `--ds-control-h-sm` | 32px | `.btn-sm`, icon buttons, pagination |
| `--ds-control-h` | 38px | Default button, input, select, search |
| `--ds-control-h-lg` | 44px | `.btn-lg` |
| `--ds-control-px` | 16px | Default button horizontal padding |

---

## 10. Components

### Buttons

```html
<button class="btn btn-primary">Save changes</button>
<a href="…" class="btn btn-outline-danger">Cancel</a>
<button class="btn btn-sm btn-secondary">Filter</button>
```

- One button per screen carries `.btn-primary`. Everything else is
  `.btn-secondary` or an outline variant.
- Destructive actions use `.btn-danger` (confirmed action) or
  `.btn-outline-danger` (an escape route such as Cancel).
- Buttons are `inline-flex` with an 8px gap, so an icon plus a label needs no
  extra markup.
- Label buttons with the verb that happens: "Publish" → toast "Published".
  Never "Submit".

### Forms

Inputs, selects and textareas share `--ds-control-h`, `--ds-radius-md` and the
accent focus ring. `.input-group-text` is a quiet grey prefix, not a second
button; the whole group borders in accent when anything inside it is focused.
Validation messages use `.text-danger` at `--ds-text-sm`.

### Cards

`.card` → `--ds-radius-lg`, 1px `--ds-border`, `--ds-shadow-xs`.
`.card-header` holds the section title at `--ds-text-md` / 600.
`.card-body` pads `--ds-space-5`.

### Tables

Header row sits on `--ds-surface-sunk` with 11px uppercase labels. Body rows
separate with `--ds-border-subtle` and tint to `--ds-surface-hover` on hover.
The last row drops its border so it doesn't double up with the card edge.

### Badges

Pill shaped, tint background + matching border + darker text. Never a saturated
fill — badges are status, not actions.

### Secondary text

Help text, meta, timestamps and captions are **black at 14px**, not grey. To
push something down the hierarchy, drop it to `--ds-text-sm` and
`--ds-weight-normal` and let the surrounding content carry more weight. Do not
reintroduce a lighter colour.

### Empty states

`.ac-empty-state` — icon in `--ds-grey-300`, a title stating what's absent, and
one line that invites the next action ("Add your first user to get started").
An empty screen is an invitation, not an apology.

---

## 11. List-view patterns (`.ac-*`)

Every admin index page is built from one of three shared patterns, defined once
in sections 13–16 of the stylesheet. **They are not per-page CSS — do not
re-declare them in a Blade `<style>` block.**

| Pattern | Classes | Used by |
|---|---|---|
| **Table list** | `.ac-toolbar` `.ac-search` `.ac-card` `.ac-table` `.ac-row` `.ac-td` `.ac-btn-icon` | Users, Contacts |
| **Sortable list** | `.ac-list` `.ac-item` `.ac-drag` `.ac-item-body` `.ac-thumb-wrap` `.ac-meta` `.ac-badge` `.ac-actions` | About, Events, News, Services, Sliders, Teams |
| **Preview modal** | `.ac-modal--preview` `.ac-modal-close-row` `.ac-preview-img` `.ac-detail-row` | About, Sliders |

Shared across all three: `.ac-modal-backdrop` / `.ac-modal` (delete confirm),
`.ac-empty-state`, `.ac-empty-search`, `.ac-pagination`.

The sortable list overrides jQuery Nestable's `.dd3-handle` and
`.dd-placeholder`; those `!important` flags are required to beat the plugin's
own stylesheet and should stay.

---

## 12. Adding a new page

1. Extend `admin.layouts.app`.
2. Use `.block-header` for the page title and breadcrumb.
3. Wrap content in `.card`, or use the `.ac-*` table / sortable list pattern.
4. Use Bootstrap 4 classes for buttons, forms and tables — the system already
   restyles them.
5. If you need a rule that doesn't exist, add it to `design-system.css` using
   tokens. Only put CSS in a Blade file when it is genuinely used on one page
   and one page only.

---

## 13. What changed, and why

The admin previously carried three competing accent colours (cyan `#17C2D7`
from the original theme, indigo `#5b6af0` in the layout shell, violet `#6c63ff`
in the list views), six border radii doing the same job, and ~1,600 lines of the
`.ac-*` component CSS copy-pasted across eight list views. This consolidation:

- **Unified the accent on indigo `#5b6af0`** — the colour the sidebar and topbar
  already used on every screen. The cyan `.btn-primary` / `.btn-outline-primary`
  rules were deleted from `inner.css` and `custom.css`.
- **Removed `transform: scale(.85)` from `.btn-primary`** in `custom.css`. It
  shrank the painted button while leaving the click target at full size, so
  buttons had an invisible margin of clickable space around them.
- **Collapsed 6 radii → 6 named steps**, mapping the stray 7px and 9px values
  onto `--ds-radius-sm` and `--ds-radius-md`.
- **Extracted the duplicated `.ac-*` blocks** from all eight list views into the
  stylesheet, cutting ~1,600 lines of copy-paste. The views now carry only markup.
- **Gave every control the same 38px height** so buttons, inputs and search
  fields line up in a toolbar.
- **Added a consistent focus ring** on every focusable element; several
  components previously set `box-shadow: none` on focus, leaving keyboard users
  with no visible focus at all.
- **Fixed `pointer-news: none`** in the search-icon rule — a mangled
  `pointer-events` that meant the icon swallowed clicks meant for the input.
- **Dropped the infinite `pulse` animation** on the unread-enquiry badge.
  Permanent motion is a distraction in a tool people work in all day, and it
  ignored reduced-motion preferences; the badge now reads as unread through
  colour and weight.
- **Tokenised the remaining page-level CSS** — the dashboard tiles
  (`.db-*`) and the enquiry detail sheet (`.ac-view-modal`) now read from tokens
  instead of literals. The detail-sheet rules were scoped under `.ac-view-modal`
  so they can no longer leak onto the shared `.ac-modal--preview` pattern.
- **Aligned SweetAlert confirm colours** with the system palette
  (`#dc3545` → `--ds-danger`, `#28a745` → `--ds-success`). The stylesheet
  deliberately styles `.sweet-alert button.confirm` *without* `!important`, so
  the per-call `confirmButtonColor` still wins — a delete dialog stays red.
- **Confirmed no dark-mode code remained.** There were no `dark_version`,
  `prefers-color-scheme` or theme-toggle remnants in the admin views, scripts or
  stylesheets. The dead `.light_version` / `.theme-cyan` selectors in the legacy
  theme never matched anything (no such class is on `<body>`) and were left in
  place rather than risk touching the 13k-line minified theme file.

### Type and text revision

A later pass raised every type step by 2px with a hard 14px floor, and removed
grey from text entirely:

- **Type scale +2px, floored at 14px.** `2xs`/`xs`/`sm` all land on 14px and are
  now distinguished by weight, case and tracking rather than size.
- **All text is black or white.** The four `--ds-text-*` tokens resolve to
  `#000000`; `--ds-text-invert` stays white for filled and dark surfaces.
  Grey remains in use for backgrounds, borders, icon strokes and scrollbars.
- **Disabled states moved to opacity.** `.page-item.disabled .page-link` no
  longer greys its label; it dims the whole control instead.
- **Inline `font-size: 12px` and `color: gray`** were stripped from the form
  views (About, Events, News, Services, Sliders, Testimonials, Settings, Policy,
  Terms). Card-section labels now inherit `--ds-text-md` from `.card-header`;
  image-guidance text is `--ds-text-sm` in black.
- **Shell typography tokenised.** The sidebar, topbar and upload overlay no
  longer carry literal px sizes.

Two consequences worth knowing:

- **Placeholders are now black**, so they read at the same strength as a real
  value. If empty fields start looking filled, that's the trade-off — the fix
  would be an explicit exception for `::placeholder`.
- **Status and accent colours were kept.** Badge, alert and link text still use
  their semantic colour, because turning them black would destroy the meaning
  the colour carries. The instruction was read as removing *grey* text, not all
  colour. Say the word if you want those flattened too.

### Known follow-ups

- `resources/views/admin/login.blade.php` is a self-contained page with its own
  stylesheet (`public/backend/login/style.css`) and SVG animation. It was left
  untouched — bringing it onto the system is a separate piece of work.
- `site.min.css` (13k lines) still ships a large amount of dead theme CSS.
  It is fully overridden, but pruning it would meaningfully cut page weight.
