/*
 * app.css
 * ═══════════════════════════════════════════════════════════════════
 *
 * WHAT BELONGS HERE
 * ─────────────────
 * Rules that MudBlazor has no concept of:
 *   • Blazor boot / error UI
 *   • Loading progress bar
 *   • Global resets that MudBlazor does not handle
 *   • Tiny utilities used across many components (.line-clamp-2 etc.)
 *
 * WHAT DOES NOT BELONG HERE
 * ──────────────────────────
 * • Component colours      → use MudBlazor theme (AppTheme.razor)
 * • Component spacing      → use MudBlazor Class/Style props or mud-* utilities
 * • Layout widths/heights  → use layout.css (below)
 * • Dashboard-specific     → use dashboard.css (below)
 *
 * WHY NOT DELETE THIS FILE?
 * ──────────────────────────
 * Blazor's boot loader, error boundary, and validation messages are
 * rendered outside the MudBlazor component tree and cannot be themed
 * through MudThemeProvider. They need plain CSS.
 *
 * ═══════════════════════════════════════════════════════════════════
 */

/* ── Base ──────────────────────────────────────────────────────────── */
/* Dark start-up screen (index.html sets html.boot-dark). The theme's variables
   win once the app loads, so switching to light later still works; the
   fallbacks are the dark palette's background and text. */
html.boot-dark body {
    background-color: var(--mud-palette-background, #0b1120);
    color: var(--mud-palette-text-primary, #f3f4f6);
}

html,
body {
    height: 100%;
    /* Font is intentionally NOT set here — MudBlazor injects Roboto via
       its stylesheet. Setting a different font here would conflict. */
}

h1:focus {
    outline: none;
}

/* Leaflet's panes (z-index 400) and controls (1000) would otherwise stack above
   the sticky navbar (100) and its search dropdown (200). Isolating each map keeps
   those z-indexes inside it, so maps stay within their cards. */
.leaflet-container {
    isolation: isolate;
}

/* ── Blazor error UI (outside MudBlazor tree — must stay in CSS) ───── */
#blazor-error-ui {
    background: red;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--mud-palette-error);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ── Start-up screen (index.html; shown until the app mounts) ─────────
   Also seen on sign-out, which reloads the app on purpose to clear every
   cached service. No percentage: on a cached reload it sits at 100% while
   the app starts, which looks stuck. The theme isn't loaded yet, so every
   colour has a fallback (the brand green, light and dark greys). */
.boot-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding-top: 20vh;
    font-family: "Roboto", "Segoe UI", system-ui, sans-serif;
}

.boot-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.boot-brand svg {
    width: 2rem;
    height: 2rem;
    fill: var(--mud-palette-primary, #16a34a);
}

.loading-progress {
    display: block;
    width: 3.5rem;
    height: 3.5rem;
    animation: boot-spin 0.9s linear infinite;
}

.loading-progress circle {
    fill: none;
    stroke: var(--mud-palette-lines-default, #e5e7eb);
    stroke-width: 0.35rem;
}

/* A quarter-ring arc that spins (circumference of r=40% of 3.5rem ≈ 8.8rem). */
.loading-progress circle:last-child {
    stroke: var(--mud-palette-primary, #16a34a);
    stroke-linecap: round;
    stroke-dasharray: 2.2rem 8rem;
}

.boot-status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--mud-palette-text-secondary, #6b7280);
}

html.boot-dark .loading-progress circle:first-child {
    stroke: var(--mud-palette-lines-default, #334155);
}

html.boot-dark .boot-status {
    color: var(--mud-palette-text-secondary, #9ca3af);
}

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

@media (prefers-reduced-motion: reduce) {
    .loading-progress { animation-duration: 3s; }
}

/* ── Blazor form validation (outside MudBlazor validation components) ─ */
.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--mud-palette-primary);
}

.invalid {
    outline: 1px solid var(--mud-palette-error);
}

.validation-message {
    color: var(--mud-palette-error);
    font-size: 0.8rem;
    margin-top: 2px;
}

/* ── Global utilities ──────────────────────────────────────────────── */
/* Used across many components — safe to keep global */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

code {
    color: #c02d76;
}

/* wwwroot/css/
  app.css          — Blazor boot/error UI only. Nothing else.
  tokens.css        — :root { --color-primary, --space-2, --radius-md, ... } design tokens
  layout.css        — ONLY shell/structural rules: shared across all authorized layouts
  dashboard.css      — Feature-specific classes (MetricCard, feature/store cards) */

/* Text for screen readers only (e.g. "(current view)" on the active order view). */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
