/* ==========================================================================
   Global styles
   The app uses MudBlazor for its UI framework. These styles cover only:
     - Resets/accessibility tweaks
     - Blazor framework classes (validation, error boundary, reconnect UI)
     - Legal pages (Privacy, Terms) shared styling
     - Small set of cross-page utility classes prefixed `li-` (LightningIntelligence)
   Use MudBlazor theme variables (--mud-palette-*) instead of hardcoded colors.
   ========================================================================== */

/* ==========================================================================
   Utility classes (li- prefix)
   Extracted from repeated inline `Style=...` blocks. Use these instead of
   inlining the same border / monospace styling on every card.
   ========================================================================== */

/* Thin divider-coloured border, used on MudCard Elevation="0" throughout. */
.li-bordered {
    border: 1px solid var(--mud-palette-divider);
}

/* MudPaper Elevation="0" loses its default rounded corners — this restores
   them along with the divider border, so flat paper looks like a card. */
.li-paper-card {
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
}

/* Monospace styling for JSON / schema textareas. */
.li-mono {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
}

/* Monospace styling for <pre> blocks rendering raw content / extracted JSON. */
.li-mono-block {
    font-family: 'Roboto Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Dashed divider-coloured border, used on empty-state placeholders. */
.li-dashed {
    border: 1px dashed var(--mud-palette-divider);
}

/* Clickable card in a grid layout: fills the row height and shows a pointer. */
.li-card-clickable {
    height: 100%;
    cursor: pointer;
}

/* Oversized icon used in empty-state placeholders. */
.li-empty-icon {
    font-size: 4rem;
    opacity: 0.4;
}

/* Vertically scrollable content box, used for raw/JSON preview panels. */
.li-scroll-box {
    overflow: auto;
    max-height: 600px;
}

/* Calm section-header treatment for top-of-card headers across feature pages.
   Replaces the colored MudBlazor palette bars (primary/secondary/info) so multi-
   panel pages stop competing for attention. Pair with a Color.Primary icon
   inside the header for the visual accent. */
.li-section-header {
    background: var(--mud-palette-background-grey);
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* Blazor auto-focuses headings on navigation; suppress the resulting outline. */
h1:focus,
h2:focus,
h3:focus {
    outline: none;
}

/* Keep MudDivider at its natural 1px height inside the sidebar flex column —
   the default `flex: 1 0 auto` causes it to stretch and push nav menus to the
   vertical center. */
.mud-drawer .mud-drawer-content > .mud-divider {
    flex: 0 0 auto;
}

/* Prevent gradient text on HomePage from showing a selection highlight on load. */
.li-gradient-text::selection {
    background: transparent;
}

body {
    font-family: 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

/* ==========================================================================
   Blazor validation classes (emitted by EditForm)
   ========================================================================== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--mud-palette-success);
}

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

.validation-message {
    color: var(--mud-palette-error);
}

/* ==========================================================================
   Blazor error boundary
   ========================================================================== */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5N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1rem 1rem 1rem 3.7rem;
    color: white;
}

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

/* ==========================================================================
   Legal pages (Privacy Policy, Terms of Service)
   Shared styles consumed by PrivacyPolicy.razor and TermsOfService.razor.
   Dark mode is toggled by adding `.legal-dark` to the `.legal-page` root.
   ========================================================================== */
.legal-page {
    --legal-bg: #ffffff;
    --legal-text: #334155;
    --legal-heading: #0f172a;
    --legal-muted: #64748b;
    --legal-border: #e2e8f0;
    --legal-primary: #2563eb;

    font-family: 'Roboto', sans-serif;
    padding-block: 3rem;
    padding-inline: max(1.5rem, calc((100% - 720px) / 2));
    background: var(--legal-bg);
    color: var(--legal-text);
    min-height: 100vh;
}

.legal-page.legal-dark {
    --legal-bg: #0f172a;
    --legal-text: #cbd5e1;
    --legal-heading: #f1f5f9;
    --legal-muted: #94a3b8;
    --legal-border: #334155;
    --legal-primary: #3b82f6;
}

.legal-page .legal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.legal-page .legal-back {
    color: var(--legal-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.legal-page .legal-back:hover {
    text-decoration: underline;
}

.legal-page .legal-theme-btn {
    background: none;
    border: 1px solid var(--legal-border);
    border-radius: 6px;
    padding: 0.3rem;
    cursor: pointer;
    color: var(--legal-muted);
    display: flex;
}

.legal-page h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--legal-heading);
    margin-bottom: 0.25rem;
}

.legal-page h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    color: var(--legal-heading);
}

.legal-page .legal-date {
    color: var(--legal-muted);
    margin-bottom: 2rem;
}

.legal-page p {
    line-height: 1.7;
}

.legal-page a {
    color: var(--legal-primary);
}

/* ==========================================================================
   Blazor reconnection modal
   ========================================================================== */
#components-reconnect-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

#components-reconnect-modal.components-reconnect-hide {
    display: none;
}

#components-reconnect-modal .reconnect-content {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

#components-reconnect-modal.components-reconnect-show .reconnect-loading {
    display: block;
}

#components-reconnect-modal.components-reconnect-show .reconnect-failed,
#components-reconnect-modal.components-reconnect-show .reconnect-rejected {
    display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-loading,
#components-reconnect-modal.components-reconnect-failed .reconnect-rejected {
    display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-failed {
    display: block !important;
}

#components-reconnect-modal.components-reconnect-rejected .reconnect-loading,
#components-reconnect-modal.components-reconnect-rejected .reconnect-failed {
    display: none;
}

#components-reconnect-modal.components-reconnect-rejected .reconnect-rejected {
    display: block !important;
}

/* Self-contained spinner + button styles so the reconnect modal works without
   any UI framework (it runs when the SignalR circuit is broken). */
.reconnect-spinner {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    border: 0.25em solid #2563eb;
    border-right-color: transparent;
    border-radius: 50%;
    animation: reconnect-spin 0.75s linear infinite;
}

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

.reconnect-btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: white;
    background-color: #2563eb;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.reconnect-btn:hover {
    background-color: #1d4ed8;
}
