/**
 * Design tokens — shared between the public site and the admin panel.
 * Adapted from the project's CLAUDE.md design system (React/shadcn tokens
 * translated to plain CSS custom properties for this Twig/Bootstrap stack).
 * Loaded LAST in both layouts so it can re-theme Bootstrap's own utility
 * classes (.btn-primary, .bg-primary, ...) without touching the Bootstrap
 * CDN build or the legacy template stylesheets line by line.
 */

:root {
    /* Colors */
    --background: #FAFAF9;
    --foreground: #1C1917;
    --muted-foreground: #57534E;
    --card: #FFFFFF;
    --border: #E7E5E4;

    /* Single brand accent (adapted from the site's existing orange #FF5E15,
       darkened to #C2410C so white text on it passes WCAG AA 4.5:1). */
    --primary: #C2410C;
    --primary-hover: #9A3412;
    --primary-foreground: #FFFFFF;

    --success: #15803D;
    --success-foreground: #FFFFFF;
    --warning: #B45309;
    --warning-foreground: #FFFFFF;
    --destructive: #B91C1C;
    --destructive-hover: #991B1B;
    --destructive-foreground: #FFFFFF;

    /* Dark chrome surface (site sidebar/nav, admin sidebar) — kept as a
       distinct neutral-dark surface, not to be confused with --foreground
       (text color). Replaces the ad-hoc #222222 / #343a40 / #2c3136 mix. */
    --surface-dark: #1C1917;
    --surface-dark-hover: #292524;
    --surface-dark-foreground: #F5F5F4;

    /* Radius */
    --radius-md: 6px;  /* fields, buttons */
    --radius-lg: 8px;  /* cards, modals */
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 3px rgba(28, 25, 23, .08);
    --shadow-lg: 0 10px 25px rgba(28, 25, 23, .15), 0 4px 10px rgba(28, 25, 23, .08);

    /* Typography */
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-sans: 'Inter', sans-serif;

    /* Spacing scale (4px steps) — used by new/updated rules below */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    --space-16: 64px;

    /* Motion */
    --transition-fast: 150ms ease-out;
    --transition-base: 200ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------------- */
/* Typography                                                        */
/* ---------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- */
/* Focus visibility (never remove a focus indicator without          */
/* replacing it — WCAG 2.4.7 / CLAUDE.md a11y rule).                 */
/* ---------------------------------------------------------------- */

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- */
/* Buttons — re-theme Bootstrap's utility classes centrally so every */
/* page (public site, admin, login) shares one accent color.         */
/* ---------------------------------------------------------------- */

.btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(194, 65, 12, .25);
}

.btn-primary,
.bg-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--primary-foreground) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.btn-danger {
    background-color: var(--destructive);
    border-color: var(--destructive);
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: var(--destructive-hover);
    border-color: var(--destructive-hover);
}

.btn:disabled,
.btn.disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Loading state: add class="btn is-loading" and keep the button's own
   label markup — the spinner is inserted purely with CSS. */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1em;
    height: 1em;
    margin: -0.5em 0 0 -0.5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    color: var(--primary-foreground);
    animation: btn-spin .6s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- */
/* Forms                                                              */
/* ---------------------------------------------------------------- */

.form-control,
.form-select,
.custom-select {
    border-radius: var(--radius-md);
    border-color: var(--border);
}

.form-control:focus,
.form-select:focus,
.custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(194, 65, 12, .25);
}

.invalid-feedback {
    color: var(--destructive);
}

.is-invalid {
    border-color: var(--destructive) !important;
}

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

.card {
    border-radius: var(--radius-lg);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background-color: var(--background);
    border-bottom-color: var(--border);
}

/* KPI stat cards used on the admin dashboard (SB Admin 2 pattern) —
   these classes previously had no rule anywhere in the codebase, so the
   4 dashboard cards rendered identical and colorless. Defined here so
   the existing markup finally gets the color-coding it was written for. */
.border-left-primary { border-left: .25rem solid var(--primary) !important; }
.border-left-success { border-left: .25rem solid var(--success) !important; }
.border-left-info { border-left: .25rem solid #0369A1 !important; }
.border-left-warning { border-left: .25rem solid var(--warning) !important; }

/* Clickable KPI cards (dashboard) get a visible hover/focus cue */
a:has(> .card):hover > .card,
a:has(> .card):focus-visible > .card {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.text-xs { font-size: 12px; }
.text-gray-300 { color: var(--border) !important; }
.text-gray-800 { color: var(--foreground) !important; }

/* ---------------------------------------------------------------- */
/* Badges — semantic, never color-only (pair with a short label).    */
/* ---------------------------------------------------------------- */

.badge {
    border-radius: var(--radius-md);
    font-weight: 600;
}

.badge-success { background-color: var(--success); color: var(--success-foreground); }
.badge-warning { background-color: var(--warning); color: var(--warning-foreground); }
.badge-danger { background-color: var(--destructive); color: var(--destructive-foreground); }

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

.table thead th {
    border-top: none;
    background-color: var(--background);
    border-color: var(--border);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted-foreground);
}

.table td, .table th {
    border-color: var(--border);
    vertical-align: middle;
}

/* ---------------------------------------------------------------- */
/* Empty states — table rows with nothing to show get a message and  */
/* a way to act, not a bare "no data" line.                          */
/* ---------------------------------------------------------------- */

.empty-state {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--muted-foreground);
}

.empty-state i {
    font-size: 28px;
    margin-bottom: var(--space-3);
    color: var(--border);
    display: block;
}

.empty-state p {
    margin-bottom: var(--space-3);
}

/* ---------------------------------------------------------------- */
/* Modals & dropdowns — floating elements use the larger shadow.     */
/* ---------------------------------------------------------------- */

.modal-content,
.dropdown-menu {
    border-radius: var(--radius-lg);
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

/* ---------------------------------------------------------------- */
/* Toasts — progressive upgrade of the existing Symfony flash        */
/* messages (app.flashes) into a dismissible, auto-hiding stack.     */
/* No change to how/when flashes are set server-side.                */
/* ---------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: min(360px, calc(100vw - 2 * var(--space-4)));
}

.toast-stack .alert {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: 0;
    animation: toast-in var(--transition-base);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .toast-stack {
        left: var(--space-4);
        right: var(--space-4);
        width: auto;
    }
}
