/*
 * TC Birthday Mailer — admin theme.
 *
 * Visual language follows shadcn/ui (the Laravel 12 React starter-kit look): a near-neutral
 * palette, hairline borders, generous whitespace, one solid primary and everything else
 * quiet. Token values are shadcn's own v4 defaults, converted from OKLCH to hex because this
 * project ships no build step:
 *
 *   oklch(0.145 0 0) -> #0A0A0A   foreground
 *   oklch(0.97  0 0) -> #F5F5F5   muted surface
 *   oklch(0.922 0 0) -> #E5E5E5   border
 *   oklch(0.985 0 0) -> #FAFAFA   sidebar
 *   0.625rem         -> 10px      radius
 *
 * Two deliberate departures:
 *
 * 1. --primary is the Landover green, not shadcn's near-black. It is the only saturated
 *    colour in the interface, which is what keeps the product recognisably theirs while
 *    everything around it stays neutral.
 * 2. --muted-fg is #5D5D5D, not shadcn's #737373. Theirs measures 4.74:1 on white — fine —
 *    but muted text also sits on the #FAFAFA sidebar and #F5F5F5 chips, where it drops
 *    below the 4.5:1 AA floor. #5D5D5D holds 6.58 / 6.31 / 6.04 across all three.
 *
 * Everything is applied through Bootstrap 5.3's own component variables where one exists,
 * so components keep their built-in hover, focus, active and disabled behaviour.
 */

:root {
    /* Neutrals */
    --bg: #FFFFFF;
    --fg: #0A0A0A;
    --muted-bg: #F5F5F5;
    --muted-fg: #5D5D5D;
    --line: #E5E5E5;
    --sidebar-bg: #FAFAFA;

    /* Brand — the one saturated colour in the interface. */
    --brand: #133A25;
    --brand-hover: #1A4E31;
    --brand-active: #0C2418;
    --brand-tint: #E8F1EC;

    --danger: #A4271B;
    --danger-bg: #FDECEA;
    --warn: #8A5300;
    --warn-bg: #FDF4E6;

    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 248px;

    /* Bootstrap, told about all of the above. */
    --bs-primary: #133A25;
    --bs-primary-rgb: 19, 58, 37;
    --bs-link-color: #133A25;
    --bs-link-color-rgb: 19, 58, 37;
    --bs-link-hover-color: #0C2418;
    --bs-link-hover-color-rgb: 12, 36, 24;
    --bs-border-color: #E5E5E5;
    --bs-focus-ring-color: rgba(19, 58, 37, .22);
    --bs-code-color: #133A25;
    --bs-body-font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    --bs-body-color: #0A0A0A;
    --bs-body-bg: #FFFFFF;
    --bs-body-font-size: 0.9375rem;
    --bs-border-radius: 10px;
}

body {
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.006em;
}

/* ============================================================================
   App shell: fixed sidebar, content beside it.
   ============================================================================ */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    inset: 0 auto 0 0;
    position: fixed;
    width: var(--sidebar-w);
}

.sidebar-brand {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 0.625rem;
    height: 60px;
    padding: 0 1rem;
}

/* The logo file has a white background, so it gets a white plate to sit on rather than
   showing as a pale box against the sidebar's tint. */
.sidebar-brand img {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    height: 34px;
    padding: 3px;
    width: auto;
}

.sidebar-brand span {
    color: var(--fg);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.sidebar-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    padding: 0.75rem;
}

.sidebar-label {
    color: var(--muted-fg);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 0.75rem 0.5rem 0.375rem;
    text-transform: uppercase;
}

.nav-item-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: var(--muted-fg);
    display: flex;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    text-decoration: none;
}

.nav-item-link svg {
    flex-shrink: 0;
    height: 16px;
    opacity: 0.85;
    width: 16px;
}

.nav-item-link:hover {
    background: var(--muted-bg);
    color: var(--fg);
}

/* Current page: a filled chip plus a heavier weight and a darker colour, so it is not
   signalled by colour alone (WCAG 1.4.1). */
.nav-item-link.active {
    background: var(--brand-tint);
    color: var(--brand);
    font-weight: 600;
}

.nav-item-link.active svg {
    opacity: 1;
}

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding: 0.75rem;
}

.user-button {
    align-items: center;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--fg);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    text-align: left;
    width: 100%;
}

.user-button:hover {
    background: var(--muted-bg);
}

.avatar {
    align-items: center;
    background: var(--brand);
    border-radius: 50%;
    color: #fff;
    display: flex;
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    height: 30px;
    justify-content: center;
    letter-spacing: 0.02em;
    width: 30px;
}

.user-button-name {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
}

.content-inner {
    margin: 0 auto;
    max-width: 1100px;
    padding: 1.75rem 2rem 4rem;
}

/* Mobile top bar, hidden on desktop. */
.mobile-bar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: none;
    gap: 0.75rem;
    height: 56px;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* ============================================================================
   Page header
   ============================================================================ */

.page-head {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    color: var(--fg);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}

.page-sub {
    color: var(--muted-fg);
    font-size: 0.8125rem;
    margin: 0.3rem 0 0;
}

/* ============================================================================
   Surfaces
   ============================================================================ */

.card {
    --bs-card-bg: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.modal {
    --bs-modal-bg: #fff;
    --bs-modal-border-color: var(--line);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.875rem 1rem;
}

/* ============================================================================
   Buttons — one solid primary, everything else quiet.
   ============================================================================ */

.btn {
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--radius-sm);
    --bs-btn-padding-y: 0.4375rem;
    --bs-btn-padding-x: 0.875rem;
    min-height: 24px;
    min-width: 24px;
}

.btn-sm {
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-padding-y: 0.3125rem;
    --bs-btn-padding-x: 0.625rem;
}

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-hover);
    --bs-btn-hover-border-color: var(--brand-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-active);
    --bs-btn-active-border-color: var(--brand-active);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 19, 58, 37;
}

/* The default secondary action: a hairline outline on white, shadcn's "outline" button. */
.btn-outline-brand,
.btn-outline-secondary {
    --bs-btn-color: var(--fg);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: var(--fg);
    --bs-btn-hover-bg: var(--muted-bg);
    --bs-btn-hover-border-color: var(--line);
    --bs-btn-active-color: var(--fg);
    --bs-btn-active-bg: #EBEBEB;
    --bs-btn-active-border-color: var(--line);
    --bs-btn-disabled-color: var(--muted-fg);
    --bs-btn-disabled-border-color: var(--line);
    --bs-btn-focus-shadow-rgb: 19, 58, 37;
}

.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #8E2117;
    --bs-btn-hover-border-color: #8E2117;
    --bs-btn-active-bg: #7A1C13;
    --bs-btn-active-border-color: #7A1C13;
}

/* Destructive, but quiet until you reach for it: red text on a hairline, red fill on hover. */
.btn-outline-danger {
    --bs-btn-color: var(--danger);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #8E2117;
    --bs-btn-active-border-color: #8E2117;
}

.btn-link {
    --bs-btn-color: var(--muted-fg);
    --bs-btn-hover-color: var(--fg);
    --bs-btn-font-weight: 500;
    text-decoration: none;
}

/* WCAG 2.2: a visible focus ring everywhere, and a 24x24 minimum target (2.5.8). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: none;
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-label {
    color: var(--fg);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.form-control,
.form-select {
    border-color: var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    padding: 0.4375rem 0.75rem;
}

.form-control::placeholder {
    color: #A1A1A1;
}

.form-text {
    color: var(--muted-fg);
    font-size: 0.8125rem;
}

/* ============================================================================
   Tables
   ============================================================================ */

.table-quiet {
    --bs-table-bg: #fff;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0;
}

.table-quiet > thead > tr > th {
    background: #fff;
    border-bottom: 1px solid var(--line);
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 0.625rem 1rem;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
}

.table-quiet > tbody > tr > td {
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.table-quiet > tbody > tr:last-child > td {
    border-bottom: 0;
}

.table-quiet > tbody > tr:hover > td {
    background: #FCFCFC;
}

.table-scroll {
    overflow-x: auto;
}

/* A person's name reads as one unit, so it never wraps; the table scrolls sideways on a
   narrow screen instead. A long email address is capped and wrapped rather than left to
   take the width from every other column — one 60-character address was pushing names
   onto three lines. Nothing is truncated, so nothing is hidden. */
.table-quiet .cell-name {
    white-space: nowrap;
}

.table-quiet .cell-email {
    max-width: 300px;
    word-break: break-word;
}

/* ============================================================================
   Pagination, dropdowns, alerts
   ============================================================================ */

.pagination {
    --bs-pagination-bg: #fff;
    --bs-pagination-color: var(--fg);
    --bs-pagination-font-size: 0.8125rem;
    --bs-pagination-border-color: var(--line);
    --bs-pagination-border-radius: var(--radius-sm);
    --bs-pagination-hover-bg: var(--muted-bg);
    --bs-pagination-hover-color: var(--fg);
    --bs-pagination-hover-border-color: var(--line);
    --bs-pagination-focus-bg: var(--muted-bg);
    --bs-pagination-focus-color: var(--fg);
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-disabled-color: #A1A1A1;
    --bs-pagination-disabled-border-color: var(--line);
}

.dropdown-menu {
    --bs-dropdown-bg: #fff;
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-border-radius: var(--radius);
    --bs-dropdown-font-size: 0.875rem;
    --bs-dropdown-link-hover-bg: var(--muted-bg);
    --bs-dropdown-link-hover-color: var(--fg);
    --bs-dropdown-link-active-bg: var(--muted-bg);
    --bs-dropdown-link-active-color: var(--fg);
    --bs-dropdown-divider-bg: var(--line);
    --bs-dropdown-padding-y: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .07);
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.4375rem 0.625rem;
    width: auto;
}

.dropdown-menu {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.alert {
    --bs-alert-border-radius: var(--radius);
    border-width: 1px;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

.alert-danger {
    --bs-alert-color: var(--danger);
    --bs-alert-bg: var(--danger-bg);
    --bs-alert-border-color: #F5D2CE;
}

.alert-success {
    --bs-alert-color: var(--brand);
    --bs-alert-bg: var(--brand-tint);
    --bs-alert-border-color: #CBE3D6;
}

/* ============================================================================
   Status pills: icon AND word, never colour alone
   ============================================================================ */

.pill {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 0.3rem;
    line-height: 1.4;
    padding: 0.1875rem 0.5rem;
    white-space: nowrap;
}

.pill-sent {
    background: var(--brand-tint);
    border-color: #CBE3D6;
    color: var(--brand);
}

/* Red is reserved for a batch that has given up and needs a human. */
.pill-failed {
    background: var(--danger-bg);
    border-color: #F5D2CE;
    color: var(--danger);
}

.pill-retry {
    background: var(--warn-bg);
    border-color: #F0DFC0;
    color: var(--warn);
}

.pill-muted {
    background: var(--muted-bg);
    border-color: var(--line);
    color: var(--muted-fg);
}

/* ============================================================================
   Misc
   ============================================================================ */

.empty-state {
    color: var(--muted-fg);
    font-size: 0.875rem;
    padding: 3.5rem 1rem;
    text-align: center;
}

.text-muted-token {
    color: var(--muted-fg);
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
}

.stat-label {
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat-value {
    color: var(--fg);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-top: 0.25rem;
}

/* ============================================================================
   Login — no sidebar, centred card
   ============================================================================ */

.login-wrap {
    background: var(--muted-bg);
    display: grid;
    min-height: 100vh;
    padding: 1.5rem;
    place-items: center;
}

.login-card {
    max-width: 400px;
    width: 100%;
}

/* ============================================================================
   Responsive: the sidebar becomes a drawer under 992px
   ============================================================================ */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1045;
    }

    .sidebar.open {
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4);
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .mobile-bar {
        display: flex;
    }

    .content-inner {
        padding: 1.25rem 1rem 3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar {
        transition: none;
    }
}
