html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
}

/* Isolate Telerik Report Viewer from RTL layout */
.telerik-report-viewer-container,
.telerik-report-viewer-container * {
    direction: ltr !important;
    text-align: left !important;
}
.telerik-report-viewer-container .trv-report-page * {
    direction: inherit !important;
    text-align: inherit !important;
}

/* Skip navigation link for accessibility */
.skip-nav {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-nav:focus {
    top: 0;
}

h1:focus {
    outline: none;
}

.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.sidebar {
    background-color: #f8f9fa;
}

.top-row {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.top-row a {
    margin-left: 1.5rem;
    text-decoration: none;
}

.content {
    padding-top: 1.1rem;
}

.nav-menu {
    padding: 1rem;
}

.nav-item {
    padding: 0.5rem 0;
}

.nav-link {
    color: #333;
    text-decoration: none;
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.nav-link:hover {
    background-color: #e9ecef;
}

.nav-link.active {
    background-color: #0d6efd;
    color: white;
}

.card {
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .page {
        flex-direction: row;
    }

    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }
}

/* ===== Login Page Styles ===== */

.login-background {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    margin: 0;
    box-sizing: border-box;
    transition: background 0.4s ease;
}

/* Two-panel card */
.login-panel {
    display: flex;
    width: 100%;
    max-width: 960px;
    min-height: 560px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Left: branding panel */
.login-brand {
    position: relative;
    width: 42%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 40px;
    overflow: hidden;
}

.login-brand-content {
    position: relative;
    z-index: 1;
}

.login-brand-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
}

.login-brand-divider {
    width: 48px;
    height: 3px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    margin: 24px 0;
}

.login-brand-footer {
    position: relative;
    z-index: 1;
}

/* Decorative circles */
.login-brand-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.login-brand-circle-1 {
    width: 200px;
    height: 200px;
    bottom: -60px;
    right: -60px;
}

.login-brand-circle-2 {
    width: 120px;
    height: 120px;
    top: -30px;
    right: 40px;
}

/* Right: form panel */
.login-form-side {
    flex: 1;
    background: var(--mud-palette-surface, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.login-form-inner {
    width: 100%;
    max-width: 380px;
}

.login-button {
    text-transform: none !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.5px;
    border-radius: 10px !important;
    height: 50px !important;
}

/* Tablet */
@media (max-width: 768px) {
    .login-panel {
        flex-direction: column;
        max-width: 480px;
        min-height: auto;
    }

    .login-brand {
        width: 100%;
        padding: 32px 32px 24px;
    }

    .login-brand-circle-1,
    .login-brand-circle-2 {
        display: none;
    }

    .login-form-side {
        padding: 32px;
    }
}

/* RTL: mirror the breadcrumb separator chevron (PageHeader renders a fixed
   ChevronRight; in Arabic the trail flows right-to-left so the glyph must flip). */
[dir="rtl"] .mud-breadcrumb-separator .mud-icon-root {
    transform: scaleX(-1);
}

/* RTL: mirror the WizardPage Back/Next arrow glyphs (Web.Shared archetype has no
   direction context, so the host flips the directional icons). */
[dir="rtl"] .wizard-nav-arrow .mud-icon-root {
    transform: scaleX(-1);
}

/* ===== Global Search (top AppBar) =====
   The MudAutocomplete in the AppBar sits on the dark primary color, so MudBlazor's
   default placeholder/border tones are nearly invisible. Force light/translucent
   colors for readable contrast. */

.global-search input.mud-input-root,
.global-search .mud-input-slot.mud-input-root,
.global-search .mud-input .mud-input-slot {
    color: var(--mud-palette-appbar-text) !important;
    caret-color: var(--mud-palette-appbar-text);
}

.global-search input.mud-input-root::placeholder,
.global-search .mud-input-slot.mud-input-root::placeholder,
.global-search .mud-input .mud-input-slot::placeholder {
    color: color-mix(in srgb, var(--mud-palette-appbar-text) 82%, transparent) !important;
    opacity: 1 !important;
    font-weight: 400;
}

.global-search .mud-input.mud-input-outlined .mud-input-outlined-border {
    border-color: color-mix(in srgb, var(--mud-palette-appbar-text) 50%, transparent) !important;
}

.global-search:hover .mud-input.mud-input-outlined .mud-input-outlined-border {
    border-color: color-mix(in srgb, var(--mud-palette-appbar-text) 78%, transparent) !important;
}

.global-search .mud-input.mud-input-outlined.mud-focused .mud-input-outlined-border {
    border-color: var(--mud-palette-appbar-text) !important;
    border-width: 1.5px;
}

.global-search .mud-input-adornment .mud-icon-root,
.global-search .mud-input-adornment .mud-input-adornment-icon-button,
.global-search .mud-input-adornment .mud-icon-button {
    color: color-mix(in srgb, var(--mud-palette-appbar-text) 85%, transparent);
}

/* ===== Blazor Reconnect Modal ===== */

#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

#components-reconnect-modal.show {
    display: flex;
}

.toledo-reconnect-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 48px;
    border-radius: 16px;
    background: var(--mud-palette-surface, #fff);
    color: var(--mud-palette-text-primary, #333);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.toledo-reconnect-text {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Roboto', 'Segoe UI', sans-serif;
}

/* Reconnect modal language toggle — driven purely by the html[lang] attribute that
   LanguageService stamps, because the Blazor circuit is down while this modal shows. */
.toledo-reconnect-text-ar {
    display: none;
}

html[lang^="ar"] .toledo-reconnect-text-en {
    display: none;
}

html[lang^="ar"] .toledo-reconnect-text-ar {
    display: inline;
}

.toledo-reconnect-spinner {
    width: 40px;
    height: 40px;
    color: var(--mud-palette-primary, #1976d2);
    animation: toledo-spin 1s linear infinite;
}

@keyframes toledo-spin {
    100% { transform: rotate(360deg); }
}

/* Mobile */
@media (max-width: 480px) {
    .login-background {
        padding: 0;
    }

    .login-panel {
        border-radius: 0;
        min-height: 100vh;
        min-height: 100dvh;
        max-width: 100%;
    }

    .login-brand {
        padding: 24px 20px 20px;
    }

    .login-form-side {
        padding: 24px 20px;
    }
}

/* ============================================================================
   Home dashboard tiles — uniform height & width across every breakpoint
   ============================================================================

   MudGrid already gives every MudItem an identical flex-basis width (xs=12
   on mobile, sm=6 on tablet, md=4 on desktop). MudGrid's wrapper has
   `align-items: stretch` so each row's MudItems take the height of the
   tallest item in that row.

   The card inside each MudItem just needs to:
   - fill 100% of the item's width (auto-stretch on block-level child)
   - fill 100% of the item's height (so all cards in a row align)
   - flow its internal slots (header / content / actions) as a column so
     actions stick to the bottom regardless of description length

   Important: do NOT put `d-flex` on the parent MudItem — that turns its
   default block-flow into row-flex, which collapses the card to content
   width (flex-shrink: 1 default).
   ============================================================================ */

.home-tile-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.home-tile-card .mud-card-content {
    display: flex;
    flex-direction: column;
}

.home-tile-card .mud-card-actions {
    margin-top: auto;
}

@media (max-width: 599px) {
    .home-tile-card {
        min-height: 180px;
    }
}

/* ---- Home launcher tiles — one clickable tile per accessible page ---------
 * Compact icon+title tiles grouped by category (ScreenCatalog). Each tile is a
 * real <a> (keyboard-operable: Enter navigates) wrapping the styled paper; hover
 * or keyboard focus lifts the paper and tints the border. */
.home-launch-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
    border-radius: var(--mud-default-borderradius);
}

.home-launch-link:focus-visible {
    outline: none;
}

.home-launch-tile {
    height: 100%;
    min-height: 110px;
    cursor: pointer;
    text-align: center;
    border: 1px solid transparent;
    transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
}

.home-launch-tile:hover,
.home-launch-link:focus-visible .home-launch-tile {
    border-color: var(--mud-palette-primary);
    box-shadow: var(--mud-elevation-6);
    transform: translateY(-2px);
}

/* ---- User form — Roles tab: selectable role cards -----------------------
 * Replaces the bare MudCheckBox list. Each role is a full-card click target
 * (the whole card toggles the bound checkbox) with a clear hover + selected
 * border so the selection state is obvious regardless of the small checkbox
 * glyph. Theme-agnostic: colours come from MudBlazor palette vars, so every
 * theme (incl. Neumorphism, which restyles these in neumorphism.css) inherits. */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}
.role-card {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px 14px 6px;
    border: 1.5px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    background-color: var(--mud-palette-surface);
    cursor: pointer;
    /* Constant border width + box-shadow for the "thicker" selected edge avoids
       a 0.5px reflow on hover/select. */
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.role-card:hover {
    border-color: var(--mud-palette-primary);
    background-color: var(--mud-palette-action-default-hover, rgba(0, 0, 0, .04));
}
.role-card:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}
.role-card.role-card-selected {
    border-color: var(--mud-palette-primary);
    background-color: var(--mud-palette-primary-hover, rgba(0, 0, 0, .04));
    box-shadow: 0 0 0 1px var(--mud-palette-primary) inset;
}
.role-card .mud-checkbox {
    margin: 0;
    flex: 0 0 auto;
}
.role-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 9px;
    min-width: 0;
}
.role-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.role-card-name {
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    line-height: 1.2;
}
.role-card-desc {
    font-size: .82rem;
    color: var(--mud-palette-text-secondary);
    line-height: 1.35;
}
.role-card-meta {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
    opacity: .85;
}
.role-card-system {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 1px 7px;
    border-radius: 9999px;
    color: var(--mud-palette-warning);
    border: 1px solid var(--mud-palette-warning);
    line-height: 1.6;
}
.role-card-inactive {
    opacity: .6;
}
/* The card is the click target; keep the embedded read-only checkbox from
   swallowing pointer events so a click anywhere on the card toggles. */
.role-card .mud-checkbox {
    pointer-events: none;
}
