html, body {
    background-image: url('/images/ruralia-background-winter.png');
    background-size: inherit;
    background-position: center;
    background-attachment: fixed;
    min-height: 100%;
}

/* ── Entity management layout (list/detail pages) ─────────────────────────
   Shared by EntityManagementLayout.razor and pages that render their own
   AdditionalHeaderAction buttons using these classes (Commissioners, Contracts,
   Persons). Kept in the global stylesheet rather than a scoped .razor.css since
   Blazor CSS isolation would not reach markup rendered by those pages. */
.entity-header-btn {
    background: white !important;
    border-radius: 8px !important;
    border: 2px solid var(--mud-palette-primary);
    transition: background-color 0.2s, border-color 0.2s;
}

.entity-header-btn:hover,
.entity-header-btn:hover.mud-icon-button {
    background-color: var(--mud-palette-secondary, #407ec9) !important;
    border-color: var(--mud-palette-secondary, #407ec9) !important;
    color: white !important;
}

.entity-header-btn:hover .mud-icon-root,
.entity-header-btn:hover .mud-primary-text,
.entity-header-btn:hover .mud-default-text {
    color: white !important;
}

.filter-badge-wrapper:hover .mud-badge {
    background-color: var(--mud-palette-secondary) !important;
}

/* Mobile: full-bleed list panel */
@media (max-width: 959.98px) {
    .entity-list-paper {
        border-radius: 0 !important;
        box-shadow: none !important;
        height: calc(100vh - 64px) !important;
    }

    .entity-grid {
        width: 100% !important;
        margin: 0 !important;
    }

    .entity-grid > .mud-grid-item {
        padding: 0 !important;
    }
}

/* ── Global keyboard focus visibility ────────────────────────────────────
   Ensures every interactive element (native and MudBlazor) shows a clear,
   high-contrast focus ring when navigated to via keyboard. Uses :focus-visible
   so mouse/touch interactions don't show the ring, only keyboard/AT navigation. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-nav-link:focus-visible,
.mud-list-item:focus-visible,
.mud-tab:focus-visible,
.mud-chip:focus-visible,
[role="button"]:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(120, 144, 156, 0.4) !important;
    border-radius: 4px;
}

/* MudTextField / MudSelect / MudAutocomplete / MudNumericField etc. all render
   inside a shared .mud-input-control wrapper (label + input/icon row + helper
   text). Highlighting that whole wrapper on :focus-within (rather than just the
   inner <input>) means the adornment icon and helper text are visually included
   in the focus indicator instead of being left out. */
.mud-input-control:focus-within {
    box-shadow: 0 0 0 2px rgba(120, 144, 156, 0.4) !important;
    border-radius: 4px;
}

/* ── MudDataGrid rows: clickable pointer + keyboard focus ─────────────────
   Only rows explicitly opted in via RowClass="mud-table-row-clickable"
   (i.e. grids with a real RowClick action — selection, expand/collapse, etc.)
   get the pointer cursor, matching button affordance. Purely informational
   grids with no row action keep the default cursor. Keyboard focusability
   (tabindex) is added at runtime via datagrid-accessibility.js since
   MudDataGrid doesn't natively support it. */
.mud-table-row-clickable {
    cursor: pointer;
}

.mud-table-row-clickable:focus-visible {
    outline: none !important;
    box-shadow: inset 0 0 0 2px rgba(120, 144, 156, 0.4) !important;
}

/* ── Nearest-road list links (Home page) ──────────────────────────────────
   Renders each row as a real, independently focusable <a> (via MudLink)
   instead of MudList/MudListItem, which uses a roving-tabindex pattern that
   only makes one item tab-stoppable and doesn't reliably activate on Enter.
   Styled to preserve the original list-item look (block row, hover highlight). */
.nearest-road-link {
    display: block;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.nearest-road-link:hover {
    background-color: var(--mud-palette-action-default-hover, rgba(0,0,0,0.04));
}

/* ── Skip to main content link ───────────────────────────────────────────
   Visually hidden off-screen until it receives keyboard focus, at which
   point it becomes visible so keyboard/screen-reader users can bypass the
   repeated navigation menu and jump directly to page content. */
.skip-to-content-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 3000;
    background: var(--mud-palette-primary, #00205b);
    color: #ffffff !important;
    padding: 12px 20px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 6px 0;
}

.skip-to-content-link:focus {
    left: 0;
}

/* ── Layout transparency ─────────────────────────────────────────────────── */
.mud-layout,
.mud-main-content,
.mud-container {
    background: transparent !important;
}

/* ── Surface colour (#f5f5f5) on all content panels ─────────────────────── */
.mud-paper:not(.mud-dialog):not(.mud-appbar):not(.mud-drawer):not(.section-header),
.mud-card {
    background-color: #f5f5f5 !important;
}

/* Expansion panels — must override background shorthand (inline style uses gradient) */
.mud-expansion-panel,
.mud-expansion-panel-header,
.mud-expansion-panel-content,
.mud-expansion-panel-text {
    background: #f5f5f5 !important;
}

/* Tabs — panels and individual tab panel content (tabbar keeps its Color prop) */
.mud-tabs-panels,
.mud-tab-panel {
    background-color: #f5f5f5 !important;
}

/* Default: All tabbars get primary background */
.mud-tabs-tabbar {
    background-color: var(--mud-palette-primary) !important;
}

.mud-tabs-tabbar .mud-tab {
    background-color: transparent !important;
}

/* Tool dialog tabs — override to surface background with neutral text colors */
.tool-dialog-tabs > .mud-tabs-tabbar {
    background-color: var(--mud-palette-surface) !important;
}

.tool-dialog-tabs > .mud-tabs-tabbar .mud-tab {
    color: var(--mud-palette-text-secondary) !important;
}

.tool-dialog-tabs > .mud-tabs-tabbar .mud-tab.mud-tab-active {
    color: var(--mud-palette-text-primary) !important;
}

.tool-dialog-tabs > .mud-tabs-tabbar .mud-tab-slider {
    background-color: var(--mud-palette-text-primary) !important;
}

.mud-table-container,
.mud-data-grid {
    background-color: #f5f5f5 !important;
}

/* ── MudAlert solid backgrounds ─────────────────────────────────────────── */
.mud-alert {
    backdrop-filter: none !important;
    opacity: 1 !important;
}
.mud-alert.mud-alert-filled-info       { background-color: #7c6992 !important; color: #fff !important; }
.mud-alert.mud-alert-filled-success    { background-color: #7a9a01 !important; color: #fff !important; }
.mud-alert.mud-alert-filled-warning    { background-color: #dc8633 !important; color: #fff !important; }
.mud-alert.mud-alert-filled-error      { background-color: #9a3324 !important; color: #fff !important; }

.mud-alert.mud-alert-outlined-info,
.mud-alert.mud-alert-text-info         { background-color: #f0edf4 !important; }
.mud-alert.mud-alert-outlined-success,
.mud-alert.mud-alert-text-success      { background-color: #f0f5e0 !important; }
.mud-alert.mud-alert-outlined-warning,
.mud-alert.mud-alert-text-warning      { background-color: #fdf3e7 !important; }
.mud-alert.mud-alert-outlined-error,
.mud-alert.mud-alert-text-error        { background-color: #f7eeec !important; }
.mud-dialog {
    background-color: #ffffff !important;
}

/* ── AppBar and Drawer keep their theme colours ──────────────────────────── */
.mud-appbar {
    background-color: var(--mud-palette-appbar-background) !important;
}

.mud-drawer {
    background-color: var(--mud-palette-drawer-background) !important;
}

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 #e52390;
}

.validation-message {
    color: #e52390;
}

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

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

.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;
}

/* Wrike HTML content styling - make hyperlinks noticeable */
.wrike-html-content a {
    color: #1976d2;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

.wrike-html-content a:hover {
    color: #0d47a1;
    text-decoration: underline;
}

.wrike-html-content a:visited {
    color: #7b1fa2;
}

.wrike-html-content strong,
.wrike-html-content b {
    font-weight: 700;
}

.wrike-html-content em,
.wrike-html-content i {
    font-style: italic;
}

.wrike-html-content ul,
.wrike-html-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.wrike-html-content li {
    margin: 4px 0;
}

/* Wrike mention styling */
.wrike-mention {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
}

.wrike-mention:hover {
    background-color: #bbdefb;
    text-decoration: none;
}

/* Flip card for Assignees/Followers */
.flip-card {
    perspective: 1000px;
    position: relative;
    min-height: 150px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card-inner.flipped {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flip-card-front {
    position: relative;
}

.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
}

/* ============================================================================
   NAVIGATION APPBAR - Animated underline for buttons
   ============================================================================ */

/* Target all buttons in the nav AppBar */
.nav-appbar .mud-button-root {
    position: relative;
    overflow: visible;
}

/* Create the underline using ::after pseudo-element */
.nav-appbar .mud-button-root::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: white;
    transform: translateX(-50%);
    transition: width 0.3s ease-in-out;
}

/* Expand underline on hover */
.nav-appbar .mud-button-root:hover::after {
    width: 85%;
}

/* Exclude buttons inside dropdown menus from getting the underline */
.menu-dropdown-popover .mud-button-root::after,
.mud-list .mud-button-root::after,
.mud-popover .mud-button-root::after {
    display: none;
}

/* ============================================================================
   RICH TEXT EDITOR TABLE STYLES (Quill/MudExRichTextEdit)
   ============================================================================ */

/* Base table styles */
.ql-table-better,
table.ql-table-better {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

/* Table cell borders and padding */
.ql-table-better td,
.ql-table-better th {
    border: 1px solid #000000;
    padding: 8px;
    min-width: 50px;
}

/* Table block paragraphs inside cells */
.ql-table-block {
    margin: 0;
    padding: 0;
}

/* Center-aligned table content */
.ql-align-center {
    text-align: center;
}

/* Left-aligned table content (default) */
.ql-align-left {
    text-align: left;
}

/* Right-aligned table content */
.ql-align-right {
    text-align: right;
}

/* Selected cell highlight (when editing) */
.ql-cell-selected {
    background-color: rgba(0, 128, 0, 0.2);
}

/* Focused cell highlight (when editing) */
.ql-cell-focused {
    outline: 2px solid #0078d4;
    outline-offset: -2px;
}

/* Ensure temporary elements don't display */
.ql-table-temporary {
    display: none;
}

/* ── Mobile-responsive overrides ───────────────────────────────────────── */

/* Make MudDialogs full-screen on small screens */
@media (max-width: 959.98px) {
    .radio-stack {
        flex-direction: column !important;
    }
    .mud-dialog {
        max-width: 100vw !important;
        max-height: 100vh !important;
        width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
    }

    .mud-dialog .mud-dialog-content {
        max-height: calc(100vh - 120px) !important;
        overflow-y: auto;
    }

    /* MudDataGrid: enable horizontal scroll */
    .mud-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Expansion panels: reduce padding */
    .mud-expand-panel-content .mud-paper {
        padding: 8px !important;
    }

    /* InfoCard: add margin on mobile/tablet */
    .info-card {
        margin: 8px;
    }
}

/* ============================================================
   SlidingIframePanel / SlidingPanel (spm-*) — self-contained panels
   ============================================================ */

/* ── Drawers — fixed to right edge, slide in on open ── */
.spm-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface);
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1201;
    overflow: hidden;
}

.spm-drawer--open {
    transform: translateX(0);
}

.spm-drawer-header {
    background-color: var(--mud-palette-primary);
    flex-shrink: 0;
}

.spm-drawer-content {
    flex: 1;
    overflow: hidden;
}

/* ── Tab buttons — fixed to right edge ── */
.spm-tab {
    position: fixed;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 116px;
    padding: 10px 5px;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 1200;
    transition: width 0.2s ease, height 0.2s ease, background-color 0.2s ease,
                right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.spm-tab--active {
    width: 36px;
    height: 128px;
}

.spm-tab-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--mud-palette-surface);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    margin-top: 4px;
    line-height: 1.1;
}

/* ── Mobile (< 600px): full-screen drawer below the AppBar ── */
@media (max-width: 599.98px) {
    .spm-drawer {
        width: 100vw !important;
        /* MudBlazor AppBar Dense=false is 64px — start below it so the drawer header/× is fully visible */
        top: 64px;
        /* Raise above everything including AppBar so the drawer itself is fully accessible */
        z-index: 1400;
    }

    .spm-drawer-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Override the inline top/right — center tabs vertically around 50% of the viewport.
       --spm-index is set as an inline CSS var by C# (0-based panel index).
       Each tab is 116px tall with 8px gap (124px pitch). The group is offset so
       the stack is centred: translateY(index * 124px - totalHeight/2) where
       totalHeight ≈ 124px per panel. For a single tab this puts it exactly at 50%. */
    .spm-tab {
        right: 0 !important;
        top: auto !important;
        bottom: calc(var(--spm-index, 0) * 124px + 16px) !important;
        z-index: 1399;
    }

    /* Hide the active tab while drawer is open — use × in the drawer header to close */
    .spm-tab--active {
        display: none !important;
    }
}

/* ── Tablet (600–959px): cap drawer width so tabs stay reachable ── */
@media (min-width: 600px) and (max-width: 959.98px) {
    .spm-drawer {
        max-width: 85vw;
    }

    .spm-drawer-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── WrikeTaskPanel mobile tweaks ── */
@media (max-width: 599.98px) {
    /* Reduce outer panel padding so content has more horizontal room */
    .wrike-task-panel-outer {
        padding: 8px !important;
    }
}

