# Backend Design System

A complete reference for replicating the UI/UX of this admin panel in a new project. This document covers every layer: HTML framework, CSS, JS libraries, layout structure, component patterns, dark mode, and page conventions.

---

## Table of Contents

1. [CSS & HTML Framework](#1-css--html-framework)
2. [JavaScript Libraries](#2-javascript-libraries)
3. [Build Pipeline](#3-build-pipeline)
4. [Layout Architecture](#4-layout-architecture)
5. [Dark Mode System](#5-dark-mode-system)
6. [Typography & Color Palette](#6-typography--color-palette)
7. [Page Structure Pattern](#7-page-structure-pattern)
8. [UI Component Patterns](#8-ui-component-patterns)
9. [Form Pattern](#9-form-pattern)
10. [Table Pattern](#10-table-pattern)
11. [Alpine.js Patterns](#11-alpinejs-patterns)
12. [Date & Time Picker Setup](#12-date--time-picker-setup)
13. [Blade Component Reference](#13-blade-component-reference)
14. [Replication Checklist](#14-replication-checklist)

---

## 1. CSS & HTML Framework

### Tailwind CSS 3.1

All styling is done exclusively with **Tailwind CSS utility classes**. There is no Bootstrap, no custom CSS grid system. Raw CSS in `app.css` is minimal and only used for:

- Third-party widget overrides (datepicker z-index, Select2 theming)
- Bulk dark mode remapping via the `html.dark main.admin-main` scope

**tailwind.config.js:**
```js
import defaultTheme from 'tailwindcss/defaultTheme';
import forms from '@tailwindcss/forms';

export default {
    darkMode: 'class',          // Dark mode toggled via .dark class on <html>

    content: [
        './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
        './storage/framework/views/*.php',
        './resources/views/**/*.blade.php',
    ],

    theme: {
        extend: {
            fontFamily: {
                sans: ['Figtree', ...defaultTheme.fontFamily.sans],
            },
        },
    },

    plugins: [forms],           // @tailwindcss/forms resets input/select/textarea styling
};
```

Key decisions:
- `darkMode: 'class'` — dark mode is manually toggled, not OS-dependent by default (though OS preference is checked as a fallback on first load)
- `@tailwindcss/forms` plugin is required — it normalises form control appearance so Tailwind utilities apply cleanly to inputs, selects, and textareas
- Font is **Figtree** loaded from `fonts.bunny.net` (privacy-friendly Google Fonts mirror)

---

## 2. JavaScript Libraries

All JS is bundled via Vite. Libraries are imported in `resources/js/app.js`.

### Core libraries

| Library | Version | Role | How used |
|---|---|---|---|
| **Alpine.js** | 3.4 | Reactivity / component state | Dropdowns, modals, sidebar toggle, theme toggle, any inline interactivity |
| **jQuery** | 4.0 | DOM utility | Required by date picker plugins; exposed as `window.$` and `window.jQuery` |
| **Axios** | 1.15 | HTTP | AJAX calls (CSRF header set automatically by `bootstrap.js`) |

### UI enhancement libraries

| Library | Version | Role | Trigger class/selector |
|---|---|---|---|
| **Flatpickr** | 4.6 | Date picker (primary) | `.date-picker` inputs |
| **bootstrap-datepicker** | 1.10 | Date picker (fallback) | `.date-picker` inputs |
| **bootstrap-daterangepicker** | 3.1 | Date range picker | `#some-daterange` inputs |
| **Moment.js** | 2.30 | Date formatting (used by daterangepicker) | Imported globally as `window.moment` |
| **Select2** | 4.1 | Enhanced select boxes | `.some-select` via explicit JS init |

### Initialization pattern

All library inits run on `DOMContentLoaded`. Each init function checks that the library is loaded before proceeding — this prevents crashes if a library is missing:

```js
const initializeDatePickers = () => {
    if (typeof $.fn.datepicker !== 'function') {
        initializeFlatpickrFallback();   // fall back to flatpickr
        return;
    }
    $('.date-picker').datepicker({ format: 'yyyy-mm-dd', autoclose: true, ... });
};

document.addEventListener('DOMContentLoaded', () => {
    initializeDatePickers();
    // other inits...
});
```

### Global window exposure

```js
window.Alpine    = Alpine;
window.flatpickr = flatpickr;
window.$         = $;
window.jQuery    = $;
```

This allows Alpine.js components and inline Blade scripts to access these libraries without importing them separately.

---

## 3. Build Pipeline

**Vite** with `laravel-vite-plugin`.

**vite.config.js:**
```js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,    // Hot reload on Blade file changes
        }),
    ],
});
```

**Entry points:**
- `resources/css/app.css` — Tailwind directives + custom component overrides
- `resources/js/app.js` — All JS imports + Alpine.start()

**In every Blade layout:**
```blade
@vite(['resources/css/app.css', 'resources/js/app.js'])
```

**Commands:**
```bash
npm run dev      # Development server with HMR
npm run build    # Production build (hashed filenames)
```

---

## 4. Layout Architecture

There are two layouts used across the entire admin panel.

### Guest layout — auth pages only

Used for login, register, password reset. A centered card on a plain background.

```
<html>                          bg: #fff (light) / slate-950 (dark)
  <body>                        full height, flexbox centered
    <x-theme-init />            ← reads localStorage before paint (no flash)
    <x-theme-toggle />          ← top-right corner
    [logo + app name]
    <div class="guest-shell">
      <div class="guest-card">  ← white card, max-w-md, shadow
        {{ $slot }}             ← form content
      </div>
    </div>
  </body>
</html>
```

### Backend layout — all admin pages

The `<x-backend-layout>` component is the single layout for every admin page. It accepts an optional `pageTitle` prop.

```
<html class="h-full">
  <body class="h-screen overflow-hidden bg-[#E2E4F0]">  ← light: cool grey; dark: slate-950
    <div x-data="{ sidebarOpen: false }">               ← Alpine controls mobile sidebar

      <!-- Mobile overlay (blocks main content when sidebar is open) -->
      <div x-show="sidebarOpen" @click="sidebarOpen=false" class="fixed inset-0 bg-black/40 md:hidden" />

      <div class="flex h-full flex-col md:flex-row">

        <!-- SIDEBAR (fixed on mobile, relative on desktop) -->
        <aside class="w-64 flex flex-col bg-[#F8F9FB] border-r">
          [Logo + App Name]
          <nav class="flex-1 overflow-y-auto px-4 py-5">
            <x-sidebar.nav />       ← config-driven, permission-filtered
          </nav>
          [Account link + Logout]
          [User avatar card]        ← initials avatar + name + email
        </aside>

        <!-- MAIN CONTENT COLUMN -->
        <div class="flex flex-1 flex-col overflow-hidden bg-white dark:bg-slate-950">

          <!-- TOP HEADER BAR -->
          <header class="shrink-0 border-b bg-white dark:bg-slate-950">
            [Hamburger — mobile only]
            [Theme toggle]
            [Notification bell]
            [User avatar initials]
          </header>

          <!-- PAGE CONTENT -->
          <main class="admin-main flex-1 overflow-y-auto p-5 sm:p-6">
            {{ $slot }}             ← each page's content goes here
          </main>

        </div>
      </div>
    </div>
  </body>
</html>
```

**Key layout classes:**
- `h-screen overflow-hidden` on body — prevents double scrollbars; only `<main>` scrolls
- `overscroll-y-contain` on main — prevents scroll chaining to the browser
- `admin-main` class on `<main>` — used as the dark mode scope selector in CSS
- Sidebar is `w-64` fixed width and does not collapse on desktop; collapses to off-screen on mobile

---

## 5. Dark Mode System

Dark mode is a three-part system: **init script → toggle component → CSS remapping**.

### Part 1 — `<x-theme-init />` (no flash)

A tiny inline `<script>` injected in `<head>` **before** the stylesheet loads. Reads localStorage and applies `.dark` to `<html>` synchronously, preventing a flash of light mode on dark users.

```html
<script>
    (function () {
        const stored = localStorage.getItem('pb-theme');
        const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
        const dark = stored === 'dark' || (stored !== 'light' && prefersDark);
        document.documentElement.classList.toggle('dark', dark);
    })();
</script>
```

Logic: stored preference wins; if no preference stored, falls back to OS setting.

### Part 2 — `<x-theme-toggle />` (button)

An Alpine.js component that toggles the `.dark` class and persists the choice:

```html
<div x-data="{ isDark: false }" x-init="isDark = document.documentElement.classList.contains('dark')">
    <button @click="
        isDark = !isDark;
        document.documentElement.classList.toggle('dark', isDark);
        localStorage.setItem('pb-theme', isDark ? 'dark' : 'light');
    ">
        <svg ...moon... :class="isDark ? 'opacity-0' : 'opacity-100'" />   ← light mode icon
        <svg ...sun...  :class="isDark ? 'opacity-100' : 'opacity-0'" />   ← dark mode icon
    </button>
</div>
```

Storage key: `pb-theme` with values `'dark'` or `'light'`.

### Part 3 — CSS remapping in `app.css`

Rather than adding `dark:` variants to every single Blade file, `app.css` bulk-remaps common light utilities when scoped to `html.dark main.admin-main`:

```css
html.dark main.admin-main .bg-white        { background-color: theme('colors.slate.900'); }
html.dark main.admin-main .bg-gray-50      { background-color: theme('colors.slate.800'); }
html.dark main.admin-main .text-slate-900  { color: theme('colors.slate.100'); }
html.dark main.admin-main .text-gray-700   { color: theme('colors.slate.300'); }
html.dark main.admin-main .border-gray-200 { border-color: theme('colors.slate.600'); }
html.dark main.admin-main input, select, textarea {
    border-color: theme('colors.slate.600');
    background-color: theme('colors.slate.800');
    color: theme('colors.slate.100');
}
/* ...and more */
```

**What this means for Blade authors:** You write light-mode Tailwind classes only. Dark mode is handled automatically for standard colors. You only need explicit `dark:` variants in the sidebar, header, and guest layout (which are outside `admin-main`).

---

## 6. Typography & Color Palette

### Font

**Figtree** — loaded from `fonts.bunny.net`, weights 400/500/600.

```html
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
```

Set as the default sans font in `tailwind.config.js`. No other fonts used.

### Color palette

All colors come from Tailwind's default palette. The project uses:

| Purpose | Light | Dark |
|---|---|---|
| Page background | `bg-[#E2E4F0]` (cool grey) | `dark:bg-slate-950` |
| Sidebar / header background | `bg-[#F8F9FB]` | `dark:bg-slate-900` |
| Content area | `bg-white` | `→ slate-900` (via CSS remap) |
| Primary text | `text-slate-900` | `→ slate-100` |
| Secondary text | `text-slate-500` / `text-gray-600` | `→ slate-400` |
| Borders | `border-gray-200` / `border-[#E5E7EB]` | `→ slate-600` / `slate-700` |
| Primary button | `bg-slate-900 text-white hover:bg-slate-700` | same |
| Danger button | `bg-red-50 text-red-700 hover:bg-red-100` | auto-remapped |
| Success badge | `bg-green-50 text-green-800 border-green-200` | auto-remapped |
| Info badge | `bg-gray-100 text-gray-600` | auto-remapped |
| Edit action link | `bg-blue-50 text-blue-700 hover:bg-blue-100` | auto-remapped |
| User avatar | `bg-blue-100 text-blue-600` | `dark:bg-blue-950 dark:text-blue-400` |

### Text size scale used

| Class | Used for |
|---|---|
| `text-xs` | Labels, badges, table captions, sidebar section headings |
| `text-sm` | Body text, table rows, nav links, form labels |
| `text-base` | App name in sidebar |
| `text-xl` | Page / section headings (`h2`) |
| `text-2xl` | Major stat numbers on dashboard |
| `text-4xl` | Large KPI numbers |

---

## 7. Page Structure Pattern

Every admin page follows this consistent structure inside `<x-backend-layout>`:

```blade
<x-backend-layout>

    {{-- Outer card --}}
    <div class="rounded-lg border bg-white p-6 shadow-sm">

        {{-- Page heading --}}
        <h2 class="mb-4 text-xl font-semibold text-slate-900">Page Title</h2>

        {{-- Flash message --}}
        @if (session('success'))
            <div class="mb-4 rounded border border-green-200 bg-green-50 p-3 text-green-800">
                {{ session('success') }}
            </div>
        @endif

        {{-- Toolbar: description left, actions right --}}
        <div class="mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
            <p class="text-sm text-gray-600">Short description of this section.</p>
            <div class="flex gap-2 sm:items-center">
                <span class="inline-flex rounded-full bg-gray-100 px-3 py-1 text-xs text-gray-600">
                    Total: {{ $items->total() }}
                </span>
                <a href="{{ route('items.create') }}"
                   class="inline-flex justify-center rounded bg-slate-900 px-3 py-2 text-sm text-white hover:bg-slate-700">
                    Add Item
                </a>
            </div>
        </div>

        {{-- Table or form content --}}
        ...

    </div>

</x-backend-layout>
```

**Structural rules:**
- Every page is wrapped in a single white card: `rounded-lg border bg-white p-6 shadow-sm`
- For forms, the card has `max-w-3xl` to keep it readable
- Page `<h2>` is always `text-xl font-semibold text-slate-900`
- Flash success/error messages always appear directly below the heading
- Toolbar row is always `flex-col` on mobile, `flex-row sm:justify-between` on desktop

---

## 8. UI Component Patterns

### Primary action button (link)
```blade
<a href="{{ route('items.create') }}"
   class="inline-flex justify-center rounded bg-slate-900 px-3 py-2 text-sm text-white hover:bg-slate-700">
    Add Item
</a>
```

### Primary submit button
```blade
<button type="submit"
        class="rounded-md bg-slate-900 px-4 py-2 text-white hover:bg-slate-700">
    Save
</button>
```

### Cancel link
```blade
<a href="{{ route('items.index') }}" class="text-gray-600 hover:text-gray-800">Cancel</a>
```

### Edit action (table row)
```blade
<a href="{{ route('items.edit', $item) }}"
   class="rounded bg-blue-50 px-2 py-1 text-blue-700 hover:bg-blue-100">Edit</a>
```

### Delete action (table row, inline form)
```blade
<form action="{{ route('items.destroy', $item) }}" method="POST" class="inline">
    @csrf
    @method('DELETE')
    <button type="submit"
            class="ml-2 rounded bg-red-50 px-2 py-1 text-red-700 hover:bg-red-100"
            onclick="return confirm('Delete this item?')">Delete</button>
</form>
```

### Count badge
```blade
<span class="inline-flex rounded-full bg-gray-100 px-3 py-1 text-xs text-gray-600">
    Total: {{ $items->total() }}
</span>
```

### Flash success message
```blade
@if (session('success'))
    <div class="mb-4 rounded border border-green-200 bg-green-50 p-3 text-green-800">
        {{ session('success') }}
    </div>
@endif
```

### Empty state (inside a table)
```blade
<tr>
    <td colspan="4" class="px-3 py-8 text-center text-gray-500">No items found.</td>
</tr>
```

### Pagination
```blade
<div class="mt-4">
    {{ $items->links() }}
</div>
```

---

## 9. Form Pattern

Forms use a consistent vertical stack layout with `space-y-4`:

```blade
<x-backend-layout>
    <div class="max-w-3xl rounded-lg border bg-white p-6 shadow-sm">
        <h2 class="mb-4 text-xl font-semibold text-slate-900">Create Item</h2>
        <p class="mb-5 text-sm text-gray-600">Fill in the details below.</p>

        <form action="{{ route('items.store') }}" method="POST" class="space-y-4">
            @csrf

            {{-- Text input field --}}
            <div>
                <label class="mb-1 block text-sm font-medium text-gray-700">Field Label</label>
                <input type="text"
                       name="field_name"
                       value="{{ old('field_name') }}"
                       class="w-full rounded-md border-gray-300 focus:border-slate-500 focus:ring-slate-500"
                       placeholder="Placeholder text">
                @error('field_name')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>

            {{-- Textarea --}}
            <div>
                <label class="mb-1 block text-sm font-medium text-gray-700">Description</label>
                <textarea name="description" rows="4"
                          class="w-full rounded-md border-gray-300 focus:border-slate-500 focus:ring-slate-500"
                          placeholder="Optional details...">{{ old('description') }}</textarea>
                @error('description')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>

            {{-- Select --}}
            <div>
                <label class="mb-1 block text-sm font-medium text-gray-700">Category</label>
                <select name="category_id"
                        class="w-full rounded-md border-gray-300 focus:border-slate-500 focus:ring-slate-500">
                    <option value="">Select...</option>
                    @foreach ($categories as $cat)
                        <option value="{{ $cat->id }}" @selected(old('category_id') == $cat->id)>
                            {{ $cat->name }}
                        </option>
                    @endforeach
                </select>
                @error('category_id')
                    <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                @enderror
            </div>

            {{-- Action row --}}
            <div class="flex items-center gap-3">
                <button type="submit"
                        class="rounded-md bg-slate-900 px-4 py-2 text-white hover:bg-slate-700">
                    Save
                </button>
                <a href="{{ route('items.index') }}" class="text-gray-600 hover:text-gray-800">Cancel</a>
            </div>
        </form>
    </div>
</x-backend-layout>
```

**Form rules:**
- Always `max-w-3xl` to prevent over-wide forms
- Every field: `<div>` wrapper → `<label>` → input → `@error`
- Input focus ring: `focus:border-slate-500 focus:ring-slate-500` (matches sidebar accent)
- `old()` helper on every input for validation repopulation
- Error messages: `text-sm text-red-600`

---

## 10. Table Pattern

```blade
<div class="overflow-x-auto rounded-md border border-gray-200">
    <table class="min-w-full text-sm">
        <thead class="bg-gray-50">
            <tr>
                <th class="px-3 py-3 text-left font-semibold text-gray-700">Column A</th>
                <th class="px-3 py-3 text-left font-semibold text-gray-700">Column B</th>
                <th class="px-3 py-3 text-left font-semibold text-gray-700">Actions</th>
            </tr>
        </thead>
        <tbody>
            @forelse ($items as $item)
                <tr class="border-t">
                    <td class="px-3 py-3">{{ $item->column_a }}</td>
                    <td class="px-3 py-3 text-gray-600">{{ $item->column_b }}</td>
                    <td class="px-3 py-3">
                        <a href="{{ route('items.edit', $item) }}"
                           class="rounded bg-blue-50 px-2 py-1 text-blue-700 hover:bg-blue-100">Edit</a>
                        <form action="{{ route('items.destroy', $item) }}" method="POST" class="inline">
                            @csrf @method('DELETE')
                            <button type="submit"
                                    class="ml-2 rounded bg-red-50 px-2 py-1 text-red-700 hover:bg-red-100"
                                    onclick="return confirm('Delete?')">Delete</button>
                        </form>
                    </td>
                </tr>
            @empty
                <tr>
                    <td colspan="3" class="px-3 py-8 text-center text-gray-500">No items found.</td>
                </tr>
            @endforelse
        </tbody>
    </table>
</div>
```

**Table rules:**
- Always wrapped in `overflow-x-auto` for horizontal scroll on small screens
- `min-w-full text-sm` on `<table>`
- `bg-gray-50` header, `font-semibold text-gray-700` header cells
- `border-t` on each `<tr>` (not on `<table>`) — dark mode CSS remaps this automatically
- Cell padding: `px-3 py-3`

---

## 11. Alpine.js Patterns

Alpine.js handles all in-page interactivity. No separate Vue/React components.

### Modal pattern

```blade
{{-- Trigger --}}
<button type="button"
        @click="$dispatch('open-modal', 'modal-name')"
        class="...">
    Open Modal
</button>

{{-- Modal component --}}
<x-modal name="modal-name" :show="$errors->isNotEmpty()">
    <div class="p-6">
        <h2 class="text-lg font-medium text-gray-900">Title</h2>
        <form method="POST" action="{{ route('items.store') }}">
            @csrf
            {{-- fields --}}
            <div class="mt-6 flex justify-end gap-3">
                <x-secondary-button @click="$dispatch('close-modal', 'modal-name')">
                    Cancel
                </x-secondary-button>
                <x-primary-button>Save</x-primary-button>
            </div>
        </form>
    </div>
</x-modal>
```

The `<x-modal>` component manages focus trap, Escape key, and overlay click-to-close automatically.

### Dropdown pattern

```blade
<x-dropdown>
    <x-slot name="trigger">
        <button class="...">Options</button>
    </x-slot>

    <x-dropdown-link href="{{ route('items.edit', $item) }}">Edit</x-dropdown-link>
    <x-dropdown-link href="#" onclick="...">Other Action</x-dropdown-link>
</x-dropdown>
```

### Inline Alpine state

Use `x-data` directly on elements for simple local state:

```blade
<div x-data="{ open: false }">
    <button @click="open = !open">Toggle</button>
    <div x-show="open" x-transition>Content</div>
</div>
```

### x-cloak

Add `[x-cloak] { display: none !important; }` (already in `app.css`) and `x-cloak` to any Alpine element that should be invisible until Alpine initializes — prevents flash of unstyled content.

---

## 12. Date & Time Picker Setup

Three pickers are available. All are initialized from `app.js` on `DOMContentLoaded`.

### Simple date input

Add class `.date-picker` to any `<input>`. The init code tries Bootstrap Datepicker first; falls back to Flatpickr if unavailable.

```blade
<input type="text"
       name="date_field"
       value="{{ old('date_field') }}"
       class="date-picker w-full rounded-md border-gray-300 focus:border-slate-500 focus:ring-slate-500"
       placeholder="YYYY-MM-DD">
```

Format stored/submitted: `YYYY-MM-DD`.

### Datetime input (with time)

Add class `.meeting-attendance-datetime`:

```blade
<input type="text"
       name="datetime_field"
       class="meeting-attendance-datetime w-full rounded-md border-gray-300"
       placeholder="YYYY-MM-DD HH:MM">
```

Format: `Y-m-d H:i` (24-hour).

### Date range picker

Give the input a specific ID. Two hidden inputs receive the machine-readable range:

```blade
<input type="text"
       id="my-daterange"
       data-range-start="{{ $start ?? '' }}"
       data-range-end="{{ $end ?? '' }}"
       class="w-full rounded-md border-gray-300"
       placeholder="Select date range" readonly>
<input type="hidden" name="date_from" id="date_from">
<input type="hidden" name="date_to" id="date_to">
```

Then in `app.js` add an init function targeting `#my-daterange` and filling `#date_from`/`#date_to` on `apply.daterangepicker`.

### Select2 enhanced select

Apply a class (e.g., `.my-select2`), then init in `app.js`:

```js
$('.my-select2').select2({
    placeholder: 'Select option',
    allowClear: true,
    width: '100%',
    dropdownParent: $('body'),
});
```

For dark mode support on Select2, add overrides in `app.css` scoped to `html.dark main.admin-main .your-wrapper-class`.

---

## 13. Blade Component Reference

All components live in `resources/views/components/`.

| Component | Tag | What it renders |
|---|---|---|
| `backend-layout` | `<x-backend-layout>` | Full admin shell (sidebar + header + main) |
| `theme-init` | `<x-theme-init />` | Inline `<script>` for no-flash dark init |
| `theme-toggle` | `<x-theme-toggle />` | Sun/moon icon button |
| `modal` | `<x-modal name="...">` | Alpine.js modal with focus trap |
| `dropdown` | `<x-dropdown>` | Alpine.js dropdown menu |
| `dropdown-link` | `<x-dropdown-link>` | Link item inside dropdown |
| `primary-button` | `<x-primary-button>` | `bg-slate-900` submit button |
| `secondary-button` | `<x-secondary-button>` | White bordered button |
| `danger-button` | `<x-danger-button>` | Red submit button |
| `text-input` | `<x-text-input>` | Styled `<input>` element |
| `input-label` | `<x-input-label>` | Styled `<label>` |
| `input-error` | `<x-input-error :messages="$errors->get('field')" />` | Red error list |
| `nav-link` | `<x-nav-link>` | Top nav link with active state |
| `sidebar.nav` | `<x-sidebar.nav />` | Full config-driven sidebar nav |
| `sidebar.icon` | `<x-sidebar.icon :name="'list'" />` | SVG icon by name |
| `application-logo` | `<x-application-logo />` | App SVG logo |

### Adding a new sidebar icon

Edit `resources/views/components/sidebar/icon.blade.php` and add a `case` to the switch:

```blade
@php $name = $name ?? 'default'; @endphp

@switch($name)
    @case('my-icon')
        <svg ...>...</svg>
        @break
    {{-- existing cases --}}
@endswitch
```

Then use `'icon' => 'my-icon'` in `config/admin-sidebar.php`.

---

## 14. Replication Checklist

Use this when starting a new project to replicate the same UI:

### npm packages
```bash
npm install -D tailwindcss@^3 @tailwindcss/forms @tailwindcss/vite postcss autoprefixer \
               alpinejs vite laravel-vite-plugin

npm install axios jquery flatpickr bootstrap-datepicker \
            bootstrap-daterangepicker moment select2
```

### Config files to copy
- [ ] `tailwind.config.js` — dark mode class, Figtree font, forms plugin
- [ ] `vite.config.js` — entry points + hot reload
- [ ] `postcss.config.js` — if using PostCSS plugin mode

### CSS to copy (`resources/css/app.css`)
- [ ] Tailwind directives
- [ ] `[x-cloak]` rule
- [ ] `.datepicker { z-index: 3000 }` override
- [ ] `html.dark main.admin-main` bulk remapping block (covers bg/text/border/input)
- [ ] `html.dark .guest-shell .guest-card` block

### Blade files to copy
- [ ] `resources/views/components/backend-layout.blade.php`
- [ ] `resources/views/components/theme-init.blade.php`
- [ ] `resources/views/components/theme-toggle.blade.php`
- [ ] `resources/views/components/modal.blade.php`
- [ ] `resources/views/components/dropdown.blade.php`
- [ ] `resources/views/components/dropdown-link.blade.php`
- [ ] `resources/views/components/primary-button.blade.php`
- [ ] `resources/views/components/secondary-button.blade.php`
- [ ] `resources/views/components/danger-button.blade.php`
- [ ] `resources/views/components/text-input.blade.php`
- [ ] `resources/views/components/input-label.blade.php`
- [ ] `resources/views/components/input-error.blade.php`
- [ ] `resources/views/components/sidebar/nav.blade.php`
- [ ] `resources/views/components/sidebar/icon.blade.php`
- [ ] `resources/views/layouts/` (guest layout)
- [ ] `resources/views/partials/favicon.blade.php`
- [ ] `resources/js/app.js` (trim project-specific inits, keep core setup)

### Font
- [ ] Add to `<head>`: `<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />`

### Logo
- [ ] Place logo image at `public/assets/images/logo.png` (referenced in `backend-layout`)

### Page body background
- [ ] The outer body uses `bg-[#E2E4F0]` — this shows as the gap colour behind the white main content and grey sidebar

### Dark mode storage key
- [ ] Storage key is `pb-theme` with values `'dark'` / `'light'` — keep consistent across all projects so the toggle works correctly
