/* Self-hosted Inter — no external CDN so it works offline / on-prem and in the
   single-file deploy (served from wwwroot/fonts via UseStaticFiles). One weight per face. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/inter-700.woff2') format('woff2');
}

/* Page canvas behind short content — must track theme toggles on <html>, not only MudLayout. */
html {
    min-height: 100%;
    background-color: #eef1f8;
    color-scheme: light;
}

html.mud-theme-dark {
    background-color: #12141c;
    color-scheme: dark;
}

body {
    min-height: 100%;
    background-color: inherit;
}

/* ---- Reusable layout utilities (use across pages and the upcoming forms) ---- */

/* Surface-colored top bar: a hairline bottom border replaces the old elevation/solid
   color so it reads flat and modern. Background/text come from the theme appbar tokens. */
.simobel-appbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.simobel-logout-menu-item {
    padding: 4px 8px 8px;
}

.simobel-logout-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 36px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--mud-default-borderradius, 4px);
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}

.simobel-logout-button:hover {
    background: var(--mud-palette-action-default-hover);
}

.simobel-logout-button-icon {
    flex-shrink: 0;
}

.empty-layout {
    position: relative;
    min-height: 100vh;
}

.empty-layout-theme-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
}

/* Page content wrapper: comfortable max-width + responsive gutters. Replaces ad-hoc
   margin/padding utility soup on MudMainContent and individual pages. */
.simobel-page {
    width: 100%;
    max-width: 1440px;
    margin-inline: auto;
    padding: 24px;
}

/* Embedded in the ERP: no app bar is rendered, but MudBlazor pads .mud-main-content
   by the app bar's height regardless — three rules at three breakpoints, all of
   which have to go or the page opens with a band of empty space above its
   heading. Narrower side padding too: the WebView2 window is a panel inside a
   VCL form, not a full browser, so 24px each side is a lot of nothing. */
.mud-main-content.simobel-embebido {
    padding-top: 0;
}

.simobel-embebido .simobel-page {
    padding: 16px;
}

@media (max-width: 600px) {
    .simobel-page {
        padding: 16px 12px;
    }
}

/* Soft surface card for grouping form sections / content blocks. */
.simobel-card {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius, 10px);
    padding: 20px;
}

:root {
    --erp-browse-bg: transparent;
    --erp-insert-bg: #e8f5e9;
    --erp-edit-bg:   #fff8e1;
    --erp-delete-bg: #ffebee;
}

.mud-theme-dark {
    --erp-insert-bg: #1b5e20;
    --erp-edit-bg:   #f57f17;
    --erp-delete-bg: #b71c1c;
}

.erp-form-browse { background: var(--erp-browse-bg); }
.erp-form-insert { background: var(--erp-insert-bg); }
.erp-form-edit   { background: var(--erp-edit-bg); }
.erp-form-delete { background: var(--erp-delete-bg); }

.erp-form-delete .mud-input-control { pointer-events: none; opacity: 0.7; }

/* Config editor */
.config-settings-tab {
    padding-bottom: 88px;
}

.config-section-panels .mud-expand-panel .mud-expand-panel-content {
    padding: 0;
}

.config-settings-table thead th,
.config-settings-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}

.config-save-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* Dashboard — unobtrusive manual-run control on service cards */
.service-card-trigger {
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.mud-card:hover .service-card-trigger:not(:disabled) {
    opacity: 0.85;
}

.service-card-trigger:not(:disabled):hover {
    opacity: 1;
}

/* ── Blazor reconnect overlay ─────────────────────────────────────────────────
   App.razor supplies its own #components-reconnect-modal so the text is Spanish.
   Doing that opts OUT of the overlay blazor.web.js would otherwise build for
   itself, styles included — Blazor then only toggles a state class on the
   element and leaves the appearance entirely to us. With no rules here the div
   was plain flow content: all three messages on screen at all times, on every
   page, stacked over the drawer.

   Hidden by default and shown only for the three states we actually render a
   paragraph for. That way a state class we do not know about (a future runtime
   adding one) leaves the overlay hidden instead of pinning it open — which is
   the failure we are fixing, and the one nobody notices is a bug. */
#components-reconnect-modal {
    display: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-paused,
#components-reconnect-modal.components-reconnect-resume-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    /* Above every MudBlazor layer — drawer and app bar at 1100, dialog and
       popover at 1400, snackbar at 1500. A dead connection outranks all of them:
       everything underneath is unusable until it comes back. */
    z-index: 2000;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(2px);
}

#components-reconnect-modal .components-reconnect-dialog {
    min-width: 280px;
    max-width: min(90vw, 420px);
    padding: 24px 28px;
    border-radius: 8px;
    text-align: center;
    /* MudBlazor palette variables, so the overlay follows the dark-mode toggle
       instead of being a white card on a dark page. */
    background: var(--mud-palette-surface, #fff);
    color: var(--mud-palette-text-primary, #1a1a1a);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
    font-size: 0.95rem;
}

/* Every message hidden; the state class on the modal reveals its own. */
#components-reconnect-modal .components-reconnect-dialog > p {
    display: none;
    margin: 0;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed,
#components-reconnect-modal.components-reconnect-paused .components-reconnect-paused,
#components-reconnect-modal.components-reconnect-resume-failed .components-reconnect-resume-failed,
#components-reconnect-modal.components-reconnect-rejected .components-reconnect-rejected {
    display: block;
}

/* "retrying" is added ALONGSIDE "show", not instead of it, so without this the
   box reads "Reconectando…" and "Reintentando…" one under the other. The
   countdown is the more informative of the two, so it wins. */
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-show {
    display: none;
}

#components-reconnect-modal .components-reconnect-dialog a {
    color: var(--mud-palette-primary, #594ae2);
    font-weight: 600;
    text-decoration: none;
}

#components-reconnect-modal .components-reconnect-dialog a:hover {
    text-decoration: underline;
}
