/* App-level styles. Component look & theming come from NeoUI (components.css + theme). */

/* Tailwind's reset makes <button> use the default cursor — restore the pointer for interactives. */
button:not(:disabled),
[role="button"]:not(:disabled),
summary,
label[for] {
    cursor: pointer;
}
button:disabled {
    cursor: not-allowed;
}

/* --- Utility shims --- NeoUI's compiled CSS only ships the Tailwind utilities it uses itself,
   so a few we rely on are missing. These (unlayered) supply them. */
.h-14 { height: 3.5rem; }
.w-60 { width: 15rem; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-5xl { max-width: 64rem; }
.space-y-1 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
.w-56 { width: 14rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-y-5 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.25rem; }
.space-y-8 > :not([hidden]) ~ :not([hidden]) { margin-top: 2rem; }
.tracking-wider { letter-spacing: 0.05em; }
.max-h-\[85vh\] { max-height: 85vh; }
.max-h-\[70vh\] { max-height: 70vh; }

/* Opacity color utilities (NeoUI's compiled CSS ships only the solid variants). */
.bg-primary\/10 { background-color: color-mix(in oklab, var(--primary) 10%, transparent); }
.bg-muted\/30 { background-color: color-mix(in oklab, var(--muted) 30%, transparent); }
.bg-muted\/40 { background-color: color-mix(in oklab, var(--muted) 40%, transparent); }
.bg-muted\/50 { background-color: color-mix(in oklab, var(--muted) 50%, transparent); }
.bg-card\/50 { background-color: color-mix(in oklab, var(--card) 50%, transparent); }
.hover\:bg-muted\/40:hover { background-color: color-mix(in oklab, var(--muted) 40%, transparent); }
.hover\:bg-muted:hover { background-color: var(--muted); }
.text-muted-foreground\/70 { color: color-mix(in oklab, var(--muted-foreground) 70%, transparent); }
.border-border\/60 { border-color: color-mix(in oklab, var(--border) 60%, transparent); }

/* Subtle hero tint (replaces the unshipped bg-gradient-to-br + from/via/to stops). */
.app-hero { background-image: linear-gradient(to bottom right, color-mix(in oklab, var(--primary) 12%, var(--card)), var(--card) 60%); }

/* --- Compact, Stripe/Shopify-style buttons globally ---
   NeoUI's <Button> is shadcn-style (`inline-flex`, sized via `.h-9`) and has NO data-slot, so we target
   `button.inline-flex` (specificity beats the `.h-9` utility). Our own triggers use `flex`/`block`, untouched. */
button.inline-flex,
[data-slot="button"] {
    height: 1.85rem;
    min-height: 1.85rem;
    padding-block: 0;
    padding-inline: 0.8rem;
    font-size: 0.8125rem;
    font-weight: 500;
    gap: 0.4rem;
}
/* Square icon-buttons (shadcn `size-9`) keep a square footprint at the compact height. */
button.inline-flex.size-9, button.inline-flex.size-8 { width: 1.85rem; padding-inline: 0; }

/* --- Subtle, built-in animations --- */
@keyframes ether-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ether-pop-in  { from { opacity: 0; transform: scale(0.98) translateY(4px); } to { opacity: 1; transform: none; } }
main { animation: ether-fade-in 0.18s ease-out; }
/* Dashboard widgets / stat cards: staggered entrance (delay set inline per index). */
.ether-widget { animation: ether-pop-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
.app-modal-backdrop { animation: ether-fade-in 0.12s ease-out; }
.app-modal-panel { animation: ether-pop-in 0.16s cubic-bezier(0.16, 1, 0.3, 1); }
.app-pop { animation: ether-pop-in 0.12s ease-out; }
/* Smooth the common interactive transitions everywhere. */
a, button, button.inline-flex, [role="button"], .app-nav-item, [data-slot="card"] {
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* --- Glassmorphism: frosted, translucent surfaces (toggle off with html.no-glass) --- */
.app-glass {
    background-color: color-mix(in oklab, var(--card) 60%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
}
/* Floating glass surfaces (popovers, menus, panels): mostly-opaque frost so content/buttons behind don't
   bleed through (a faint blurred tint reads as glass without showing a hard edge of the element underneath). */
.app-glass-float {
    background-color: color-mix(in oklab, var(--card) 88%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.25), inset 0 1px 0 0 color-mix(in oklab, white 30%, transparent);
}
/* Translucent modal panel — NO backdrop-filter here (it would make a containing block that breaks
   position:fixed popovers inside the modal). The frost comes from the blurred backdrop below. */
.app-modal-glass { background-color: color-mix(in oklab, var(--card) 86%, transparent); }
html.no-glass .app-modal-glass { background-color: var(--card); }
html.no-glass .app-glass,
html.no-glass .app-glass-float { background-color: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }

/* --- Text selection highlight (themed) ---
   NeoUI's `::selection` reads --selection / --selection-foreground, which the theme leaves undefined, so
   `var(--selection)` was invalid and selected text (incl. in inputs/textareas) showed no highlight. Define the
   variables AND set ::selection directly here (app.css loads last, so it wins). */
:root {
    --selection: color-mix(in oklab, var(--primary) 30%, transparent);
    --selection-foreground: var(--foreground);
}
::selection { background-color: var(--selection); color: var(--selection-foreground); }
::-moz-selection { background-color: var(--selection); color: var(--selection-foreground); }

/* --- Checkboxes & radios: themed, consistent --- */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 1rem; height: 1rem; cursor: pointer; }

/* --- File inputs: style the native "Choose file" button --- */
input[type="file"] { font-size: 0.8125rem; color: var(--muted-foreground); }
input[type="file"]::file-selector-button {
    margin-right: 0.75rem; border: 1px solid var(--border); background: var(--secondary); color: var(--secondary-foreground);
    padding: 0.4rem 0.8rem; border-radius: 0.375rem; font-size: 0.8125rem; font-weight: 500; cursor: pointer;
    transition: background-color 0.15s ease;
}
input[type="file"]::file-selector-button:hover { background: var(--muted); }

/* --- Spinner (used by the Loader component) --- */
@keyframes ether-spin { to { transform: rotate(360deg); } }
.app-spinner { display: inline-block; width: 1.15rem; height: 1.15rem; border: 2px solid color-mix(in oklab, var(--muted-foreground) 35%, transparent); border-top-color: var(--primary); border-radius: 9999px; animation: ether-spin 0.6s linear infinite; }
.app-spinner-lg { width: 1.75rem; height: 1.75rem; border-width: 3px; }

/* --- Compact mode (toggled from the theme panel): tighten the whole UI, not just tables --- */
html.compact { font-size: 0.94rem; }
html.compact main { padding: 1rem; }
html.compact h1 { font-size: 1.35rem; }
html.compact [data-slot="card"] [data-slot="card-content"],
html.compact [data-slot="card"] [data-slot="card-header"],
html.compact [data-slot="card"] [data-slot="card-footer"] { padding: 0.85rem 1rem; }
html.compact button.inline-flex, html.compact [data-slot="button"] { height: 1.6rem; min-height: 1.6rem; padding-inline: 0.6rem; font-size: 0.75rem; }
html.compact .app-nav-item { padding-top: 0.3rem; padding-bottom: 0.3rem; }
html.compact th, html.compact td { padding-top: 0.3rem; padding-bottom: 0.3rem; }
html.compact input, html.compact select, html.compact textarea { min-height: 2rem; }
html.compact .h-9 { height: 2rem; }
html.compact .space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
html.compact .space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.6rem; }
html.compact .p-6 { padding: 1rem; }
html.compact .pt-6 { padding-top: 1rem; }

/* --- Dark sidebar option (independent of page light/dark) --- */
html.sidebar-dark .app-sidebar { background-color: oklch(0.21 0.01 256); color: oklch(0.92 0.004 256); border-color: oklch(0.3 0.009 256); }
html.sidebar-dark .app-sidebar .text-muted-foreground { color: oklch(0.7 0.013 256); }

/* Overlay helpers (bg-black/50 opacity utility isn't in NeoUI's compiled set). */
.app-modal-root { position: fixed; inset: 0; }
.app-modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); -webkit-backdrop-filter: blur(10px) saturate(140%); backdrop-filter: blur(10px) saturate(140%); }
html.no-glass .app-modal-backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(0, 0, 0, 0.5); }
.app-overlay { position: fixed; inset: 0; z-index: 40; }

/* Blazor validation messages (EditForm) */
.validation-message {
    color: var(--destructive, #ef4444);
    font-size: 0.8125rem;
}

/* Blazor error UI */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    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: #b32121;
    padding: 1rem;
    color: white;
}

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

/* WASM load spinner (shown before the app boots) */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #2563eb;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }
