@import "helper.css";
@import "components/app-loading-progress.css";
@import "components/global.css";
@import "components/button.css";
@import "components/app-bar.css";
@import "components/date-picker.css";
@import "components/dialog.css";
@import "components/table.css";
@import "components/card.css";
@import "components/input.css";
@import "components/nav-menu.css";

/* Dialogs on mobile: "height: 100%" of a fixed element is the layout viewport, which includes the area
   behind the browser's address bar, so the bottom of fullscreen dialogs (and their buttons) was cut off.
   Use the dynamic viewport height instead and let only the content scroll. */
.mud-dialog-container {
    height: 100dvh;
}

/* MudBlazor keeps the transform of the dialog's opening animation (fill mode "both"). A transformed element positions
   and clips its position: fixed descendants, so a picker with PickerVariant.Dialog that is opened from a dialog was
   squeezed into that dialog and cut off. Dropping the transform after the animation lets it cover the viewport again.
   The selector has to win against MudBlazor's own .mud-dialog rule, which is loaded after this file. */
.mud-dialog-container > .mud-dialog {
    animation-fill-mode: backwards;
}

.mud-dialog.mud-dialog-fullscreen {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
}

.mud-dialog.mud-dialog-fullscreen .mud-dialog-content {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.mud-dialog.mud-dialog-fullscreen .mud-dialog-actions {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* ===== Dark mode =====
   data-theme is set on <html> by theme.js / ThemeService. MudBlazor switches its own --mud-palette-* variables;
   the tokens below cover hardcoded accent colors in component CSS. They are only defined in dark mode and are
   used with the light color as fallback, e.g. color: var(--bk-dark-red, #B91C1C), so light mode stays unchanged. */
:root[data-theme="dark"] {
    --bk-dark-green: #6EE7B7;
    --bk-dark-amber: #FCD34D;
    --bk-dark-red: #FCA5A5;
    --bk-dark-blue: #7DD3FC;
    --bk-dark-indigo: #A5B4FC;
    --bk-dark-violet: #C4B5FD;
    --bk-dark-pink: #F9A8D4;
    /* Heatmaps / activity levels: low activity must stay dim on a dark background */
    --bk-dark-day-0: #334155;
    --bk-dark-heat-1: #065F46;
    --bk-dark-heat-2: #059669;
    --bk-dark-heat-3: #34D399;
    --bk-dark-heat-4: #6EE7B7;
    --bk-dark-heat-mix: #10B981;
}

/* Loading screen before Blazor has started (theme.js has already set data-theme) */
:root[data-theme="dark"] body {
    background: #0B1310;
}

:root[data-theme="dark"] .loading-progress-text {
    color: #10B981;
}

:root[data-theme="dark"] .loading-logo {
    filter: drop-shadow(0 0.75rem 1.5rem rgba(0, 0, 0, 0.5));
}

/* The bar Blazor shows when the app itself crashed (index.html). It replaces the yellow default of MudBlazor. */
#blazor-error-ui {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 12px;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid #FCA5A5;
    background: #FEF2F2;
    color: #7F1D1D;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
    font-size: 0.92rem;
    font-weight: 500;
}

/* Blazor shows the bar by setting display: block */
#blazor-error-ui[style*="block"] {
    display: flex !important;
}

#blazor-error-ui .blazor-error-ui__emoji {
    font-size: 1.3rem;
    line-height: 1;
}

#blazor-error-ui .blazor-error-ui__text {
    flex: 1 1 auto;
    min-width: 0;
}

#blazor-error-ui .reload {
    flex: 0 0 auto;
    padding: 6px 14px;
    border-radius: 999px;
    background: #B91C1C;
    color: #FFFFFF;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

#blazor-error-ui .dismiss {
    position: static;
    flex: 0 0 auto;
    padding: 4px;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}

:root[data-theme="dark"] #blazor-error-ui {
    border-color: #7F1D1D;
    background: #2A1215;
    color: #FECACA;
}

/* Printing a page (e.g. the annual report of the finances): only the content, without the app bar and the navigation */
@media print {
    /* Paper is white: print with the light palette even in dark mode, otherwise the light text and dark lines
       of the dark theme come out grey and blotchy. Values match PaletteLight in BaseLayout.razor. */
    :root {
        --mud-palette-text-primary: #0F172A !important;
        --mud-palette-text-secondary: #475569 !important;
        --mud-palette-background: #FFFFFF !important;
        --mud-palette-background-gray: #F0F5F2 !important;
        --mud-palette-surface: #FFFFFF !important;
        --mud-palette-lines-default: #E2E8F0 !important;
        --mud-palette-lines-inputs: #CBD5E1 !important;
        --mud-palette-table-lines: #E2E8F0 !important;
        --mud-palette-divider: #E2E8F0 !important;
        --mud-palette-primary: #059669 !important;
        --mud-palette-success: #047857 !important;
        --mud-palette-error: #B91C1C !important;
        --bk-dark-green: initial;
        --bk-dark-amber: initial;
        --bk-dark-red: initial;
        --bk-dark-blue: initial;
        --bk-dark-indigo: initial;
        --bk-dark-violet: initial;
        --bk-dark-pink: initial;
    }

    html,
    body {
        background: #FFFFFF !important;
        color: #0F172A !important;
    }

    .mud-appbar,
    .mud-drawer,
    .mud-drawer-overlay,
    .mud-snackbar-provider,
    .no-print {
        display: none !important;
    }

    .mud-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
}
