html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* DO NOT set background-color on body — MudBlazor.min.css already does:
   body { background-color: var(--mud-palette-background) }
   Adding another rule here would override MudBlazor's theme-aware background.
   The initial dark flash during WASM load is handled by index.html #app div. */

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

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

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

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* AppBar select (company impersonation dropdown) — inherits text color from MudAppBar.
   MudAppBar uses white text on dark theme, dark text on light theme.
   Previously hardcoded "color: white" which was invisible on light theme. */
.appbar-select .mud-input {
    color: inherit !important;
}
.appbar-select .mud-input-control .mud-input-label {
    color: inherit !important;
}
.appbar-select .mud-select-input .mud-icon-root {
    color: inherit !important;
}

/* Clickable dashboard cards and table rows — shows pointer cursor on hover */
.cursor-pointer {
    cursor: pointer;
}

/* Large dialog — 85% viewport width/height for complex forms (Companies, Clients, InvoiceTemplates, etc.) */
.dialog-large .mud-dialog {
    width: 85vw;
    max-width: 85vw;
    max-height: 85vh;
}
/* Allow scrolling inside the large dialog content area */
.dialog-large .mud-dialog .mud-dialog-content {
    overflow-y: auto;
}

/* ============================================================================
   AI chat panel
   The bubble classes used to live in an inline <style> inside ChatMessageBubble,
   which meant .chat-bubble was undefined until that component had rendered once
   (the streaming placeholder in ChatPanel uses the same classes). They belong here.
   ============================================================================ */

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
}

.chat-bubble-user {
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-bottom-left-radius: 4px;
}

/* Plain-text message content (user messages, streaming placeholder): keep the
   author's line breaks and never let a long token widen the bubble. */
.chat-bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Rendered markdown (MarkdownView). The generated HTML carries browser default
   margins that are far too large inside a chat bubble, so they are tightened here. */
.markdown-body {
    font-size: 0.875rem;
    line-height: 1.43;
    word-break: break-word;
}
.markdown-body > *:first-child {
    margin-top: 0;
}
.markdown-body > *:last-child {
    margin-bottom: 0;
}
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote,
.markdown-body table {
    margin: 0 0 8px 0;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 12px 0 4px 0;
    font-size: 1rem;
    font-weight: 600;
}
.markdown-body ul,
.markdown-body ol {
    padding-left: 20px;
}
.markdown-body code {
    background-color: var(--mud-palette-background-gray);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.8125rem;
}
/* Code blocks scroll horizontally instead of stretching the bubble on a phone. */
.markdown-body pre {
    background-color: var(--mud-palette-background-gray);
    border-radius: 6px;
    padding: 8px;
    overflow-x: auto;
}
.markdown-body pre code {
    background: none;
    padding: 0;
}
.markdown-body table {
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
.markdown-body th,
.markdown-body td {
    border: 1px solid var(--mud-palette-lines-default);
    padding: 4px 8px;
    text-align: left;
}
.markdown-body img {
    max-width: 100%;
}

/* Drag & drop upload zone in the chat input. Pointer-only: on a touch device there
   is nothing to drag a file from, so the ~72px zone is dead space — the paper-clip
   button in the input row remains the way to attach a file there. */
@media (hover: none) and (pointer: coarse) {
    .chat-dropzone {
        display: none !important;
    }
}

/* ============================================================================
   Responsive / mobile (see DEVGUIDE 7.11)
   Breakpoint follows MudBlazor: xs < 600px. The RCL is hosted by both the
   Blazor WASM web app and the MAUI hybrid app, so these rules cover phones
   in both. Desktop keeps full labels/columns; below 600px the UI collapses
   to icons and fewer columns.
   ============================================================================ */

/* Impersonation select in the AppBar — fixed width on desktop, shrinks on phones
   (was an inline style min-width:220px which overflowed 375px screens). */
.appbar-select {
    min-width: 220px;
}

@media (max-width: 599.98px) {
    /* Generic utility — hide anything nonessential on phones */
    .hide-xs {
        display: none !important;
    }

    /* ResponsiveButton: label hides, StartIcon remains -> icon-only "+" button.
       min-width unset so the button shrinks to the icon; the icon margin is
       removed because there is no label next to it anymore. */
    .btn-responsive .btn-responsive-label {
        display: none;
    }
    .btn-responsive {
        min-width: unset;
    }
    .btn-responsive .mud-button-icon-start {
        margin: 0;
    }

    /* Grid columns marked HideSmall="true" hide on phones. MudBlazor stamps
       mud-table-cell-hide on the column's header, filter-row, and body cells;
       its own CSS only activates the class inside MudTable's card mode, so
       this rule is what actually hides DataGrid columns — at OUR breakpoint. */
    .mud-table-cell-hide {
        display: none !important;
    }

    /* AppBar: app title text and user name give way; logo and avatar icon stay */
    .appbar-title {
        display: none;
    }
    .appbar-username {
        display: none;
    }
    .appbar-select {
        min-width: 90px !important;
        max-width: 28vw;
        margin-right: 8px !important;
    }
    .appbar-logo {
        margin-left: 4px !important;
        margin-right: 4px !important;
    }
    /* Profile button: icon + dropdown arrow only, tight margins */
    .appbar-profile-btn {
        min-width: unset;
        margin-right: 4px !important;
    }
    /* Tighter AppBar gutters — every horizontal pixel counts on 375px */
    .mud-appbar .mud-toolbar {
        padding-left: 4px;
        padding-right: 4px;
    }

    /* Dialogs go full-screen on phones. Opt out with .dialog-keep-size on the
       dialog's Options.BackgroundClass / inline dialog Class when a small
       popup is genuinely wanted. */
    .mud-dialog:not(.dialog-keep-size) {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100% !important;
        height: 100%;
        margin: 0;
        border-radius: 0;
    }
    .mud-dialog:not(.dialog-keep-size) .mud-dialog-content {
        overflow-y: auto;
    }

    /* AI chat drawer takes the whole phone screen — its desktop width (400px, set via
       the MudDrawer Width parameter so MudDrawerContainer can offset the main content)
       would overflow a 375px viewport. !important because MudBlazor writes that width
       into an inline CSS variable; same trick as the full-screen dialog rule above. */
    .mud-drawer.chat-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    /* Wider bubbles on a phone — 80% of a 375px screen wastes too much space. */
    .chat-bubble {
        max-width: 92%;
    }

    /* Drag & drop zone also goes away on a narrow viewport, not just on a coarse
       pointer (see the .chat-dropzone rule above): 72px of a 812px-tall screen for a
       gesture nobody performs on a phone. The paper-clip button stays. */
    .chat-dropzone {
        display: none !important;
    }
}