/* ========================================
   BPE Custom Styles - Global Application
   Testing conversion from custom classes to direct MudBlazor targeting
   ======================================== */

.field-label-60 {
    width: 60px;
}

.field-label-100 {
    width: 100px;
}

.field-label-120 {
    width: 120px;
}

.field-label-140 {
    width: 140px;
}

.field-label-150 {
    width: 150px;
}

.mud-picker .mud-input.mud-input-outlined.mud-input-adorned-end {
    padding-right: unset;
}

/* Design system: 8px radius for surfaces */
.mud-card {
    border-radius: 8px;
}

.mud-card-content {
    padding: 8px 16px;
}

.mud-input-control.mud-input-control-margin-dense {
    margin: 0px 0px;
}

/*.mud-input > input.mud-input-root-outlined.mud-input-root-margin-dense {
    padding-top: 1px;
    padding-bottom: 1px;
}*/

/* 4px grid - dense input vertical padding */
.mud-input > input.mud-input-root-outlined.mud-input-root-margin-dense, div.mud-input-slot.mud-input-root-outlined.mud-input-root-margin-dense {
    padding-top: 4px;
    padding-bottom: 4px;
}

.mud-button-outlined-size-small.mud-icon-button {
    padding: 0px;
    max-height: 20px;
}

/* Input controls - outlined variant; 4px grid */
.mud-input > input.mud-input-root-outlined,
div.mud-input-slot.mud-input-root-outlined {
    padding: 4px 8px;
}

/* MudSelect dense padding - targets div instead of input; 4px grid */
.mud-select .mud-select-input {
    padding: 0px 4px;
}

/* Small outlined buttons padding and font size - 4px grid */
.mud-button-outlined-size-small {
    padding: 4px 8px;
    font-size: .7rem;
}

/* Button line-height reset */
.mud-button {
    line-height: unset;
}

/* Radio button icon padding reduction - GLOBAL */
.mud-radio .mud-icon-button {
    padding: 0px;
}

/* Radio button spacing - GLOBAL; 4px grid */
.mud-radio.mud-radio-content-placement-end.mud-radio-with-content {
    margin-right: 8px;
    margin-inline-end: 8px;
}

/* Textarea padding reduction - GLOBAL; 4px grid */
.mud-input > textarea.mud-input-root {
    margin: 0px 0px !important;
    padding: 4px 8px !important;
}

/* Dense table cell padding - GLOBAL; 4px grid */
.mud-table.mud-table-dense .mud-table-row .mud-table-cell {
    padding: 4px;
    padding-inline-end: unset;
    line-height: 1.25rem;
}

    /* Dense table last column spacing removal - GLOBAL */
    .mud-table.mud-table-dense .mud-table-row .mud-table-cell:last-child {
        padding-right: 0px;
        padding-inline-end: 0px;
    }

/* Input control max-width - GLOBAL (instead of .custom-control-container) */
.mud-input-control {
    max-width: fit-content;
}

/* DatePicker icon padding reduction - GLOBAL (instead of .custom-datepicker-icon) */
.mud-picker .mud-icon-button,
.mud-input-adornment .mud-icon-button {
    padding: 0px;
}

/* DatePicker icon positioning - GLOBAL */
.mud-picker .mud-icon-button-edge-end,
.mud-input-adornment .mud-icon-button-edge-end {
    margin-right: unset;
    margin-inline-end: unset;
}

/* Checkbox icon padding reduction - GLOBAL (instead of .custom-checkbox-icon) */
.mud-checkbox .mud-icon-button {
    padding: 0px;
}

/* Checkbox text size reduction - GLOBAL */
.mud-checkbox .mud-typography-body1 {
    font-size: 11px;
}

/* ========================================
   CONDITIONAL/SPECIFIC OVERRIDES
   Keep custom classes for page-specific needs
   ======================================== */

/* Grid item top padding - specific override */
.custom-grid-item-top {
    padding-top: 4px !important;
}

/* Grid item left padding - specific override */
@media (min-width: 992px) {
    .custom-grid-item-left {
        padding-left: 4px !important;
    }
}

/* Reusable section headers - no per-page colors; use for page title and card section header */
.bpe-page-section-title {
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #e0e0e0);
}

.bpe-card-section-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #e0e0e0);
}

/* Explorer search field width — overrides global fit-content on .mud-input-control */
@media (min-width: 601px) {
    .grid-search-box.mud-input-control {
        max-width: 480px;
        width: 100%;
    }
}

/* Explorer grid (large screen / normal table mode) — data label wrapping (4px grid).
   MudBlazor switches to mobile card view at <=600px (sm breakpoint), so these
   rules must only apply above that to avoid breaking desktop column headers. */
@media (min-width: 601px) {
    .mud-table.mud-xs-table .mud-table-cell::before,
    .mud-table.mud-sm-table .mud-table-cell::before,
    .mud-table.mud-md-table .mud-table-cell::before {
        flex-shrink: 0;
        white-space: normal;
        word-break: keep-all;
    }

    /* Let values use remaining width; inline column widths from config should not constrain cards */
    .mud-table.mud-xs-table:not(.preserve-widths) .mud-table-cell,
    .mud-table.mud-sm-table:not(.preserve-widths) .mud-table-cell {
        width: auto !important;
        max-width: none;
    }
}

/* Explorer grid (small screen / mobile card view) — stay within viewport (4px grid) */
@media (max-width: 600px) {
    .bpe-explorer-title {
        text-align: center;
        width: 100%;
    }

    .grid-search-box.mud-input-control {
        max-width: 100% !important;
        width: 100%;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-container,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-container {
        max-width: 100%;
        overflow-x: clip;
    }

    /* Card rows fill full viewport width */
    .bpe-explorer-data-grid.mud-xs-table .mud-table-root,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-root {
        display: block;
        width: 100%;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-body,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-body {
        display: block;
        width: 100%;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-row,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-row {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    /* Center Export to Excel (and other toolbar buttons) */
    .bpe-explorer-data-grid.mud-xs-table .mud-table-toolbar,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-toolbar {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-toolbar .mud-spacer,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-toolbar .mud-spacer {
        display: none;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell {
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding-left: 16px !important;
        /* Override MudBlazor space-between so label+value are not pushed past viewport edges */
        justify-content: flex-start !important;
        align-items: flex-start;
        gap: 8px;
        overflow-wrap: anywhere;
        word-break: break-word;
        /* Separator between each label/value pair */
        border-bottom: 1px solid var(--mud-palette-table-lines, #e0e0e0) !important;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell::before,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell::before {
        flex: 0 1 40%;
        max-width: 40%;
        min-width: 0;
        padding-right: 0;
        padding-inline-end: 0;
        white-space: normal;
        word-break: keep-all;
    }

    /* Selection checkbox cell: give it a "Select" label and align the label + checkbox
       left so the card row is uniform with the other label/value rows. */
    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell:has(.mud-input-control-boolean-input),
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell:has(.mud-input-control-boolean-input) {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 14px 16px !important;
        justify-content: flex-start !important;
        align-items: center;
        overflow: visible !important;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell:has(.mud-input-control-boolean-input)::before,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell:has(.mud-input-control-boolean-input)::before {
        content: "Select";
        font-weight: 500;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell .mud-input-control-boolean-input,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell .mud-input-control-boolean-input {
        width: auto !important;
        justify-content: flex-start !important;
        overflow: visible;
    }

    /* Fix asymmetric (D-shaped) checkbox — symmetric ripple/corners */
    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell:has(.mud-input-control-boolean-input) .mud-checkbox .mud-button-root,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell:has(.mud-input-control-boolean-input) .mud-checkbox .mud-button-root {
        border-radius: 50% !important;
        overflow: visible;
    }

    .bpe-explorer-data-grid.mud-xs-table .mud-table-cell:has(.mud-input-control-boolean-input) .mud-checkbox-input,
    .bpe-explorer-data-grid.mud-sm-table .mud-table-cell:has(.mud-input-control-boolean-input) .mud-checkbox-input {
        border-radius: 2px;
    }
}

/* ========================================
   LAYOUT AND FOOTER (4px grid)
   ======================================== */

.bpe-layout-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.footer-class {
    width: 100%;
    border-radius: 0;
}

.footer-class-inner {
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main layout footer: stack copyright / attribution vertically below md (960px = MudBlazor md) */
.footer-class-inner.footer-class-inner--stack-sm {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    text-align: center;
    height: auto;
    min-height: 60px;
    padding-top: 8px;
    padding-bottom: 8px;
}

@media (min-width: 960px) {
    .footer-class-inner.footer-class-inner--stack-sm {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        gap: 0;
        height: 60px;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* ========================================
   BLAZOR ERROR UI (theme-aware, 4px grid)
   Hidden by default; framework shows via display: block.
   ======================================== */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: var(--mud-palette-error, #dc3545);
    color: white;
    align-items: center;
    justify-content: space-between;
    z-index: 9999;
    font-size: 0.875rem;
}

/* When framework shows the bar (sets display: block), use flex so message and actions don't overlap */
#blazor-error-ui[style*="display: block"] {
    display: flex !important;
}

.blazor-error-ui-message {
    flex: 1 1 auto;
    min-width: 0;
}

.blazor-error-ui-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
}

/* Dashboard layout edit — tile + toolbar styles (button-only stepper, no JS resize) */

/*
 * MudBlazor MudDynamicDropItem (wraps every MudDropContainer ItemRenderer) sets inline:
 *   transform: translate3d(0px, 0px, 0px);
 * Source: MudBlazor 7.x — Components/DropZone/MudDynamicDropItem.razor (div.mud-drop-item).
 * Touch drag updates it via TScripts/mudDragAndDrop.js → moveItemByDifference().
 * Any non-none transform creates a containing block and breaks nested button hover/click.
 * See: https://github.com/MudBlazor/MudBlazor/issues/7047
 */
.bpe-dashboard-drop-zone > .mud-drop-item {
    transform: unset !important;
}

.bpe-dashboard-tile {
    position: relative;
}

/* Toolbar: stop native drag from the draggable .mud-drop-item parent. */
.bpe-tile-toolbar {
    -webkit-user-drag: none;
    user-select: none;
    display: inline-flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.bpe-tile-toolbar * {
    -webkit-user-drag: none;
}

/* Striped table odd-row background: stronger contrast than the default MudBlazor token. */
.mud-table-striped .mud-table-container .mud-table-root .mud-table-body .mud-table-row:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.07);
}

/* Crystal Report HTML output container */
.html-report-wrapper {
    overflow-x: auto;
    max-width: 100%;
    word-break: break-word;
}

.html-report-wrapper table {
    table-layout: auto;
    max-width: 100%;
}

.html-report-wrapper td,
.html-report-wrapper th {
    word-break: break-word;
}

.report-viewer-container {
    position: relative;
    overflow: auto;
    height: 70vh;
}

.report-zoom-toolbar {
    margin-bottom: 4px;
}

/* CommonExplorer — grid, mobile cards, keyboard focus */
.bpe-explorer-focus-ring:focus-visible {
    outline: 2px solid var(--mud-palette-primary, #594ae2);
    outline-offset: 2px;
}

.bpe-explorer-context-menu {
    min-width: 200px;
}

.bpe-explorer-shortcut-hint {
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    margin-left: 4px;
}

.mud-data-grid .mud-table-cell:has(.mud-input-control-boolean-input) {
    min-width: 40px !important;
    max-width: 40px !important;
    overflow: visible !important;
}

.mud-data-grid .mud-table-head-cell:has(.mud-input-control-boolean-input) {
    min-width: 60px !important;
    width: 60px !important;
    max-width: 60px !important;
    padding: 8px !important;
}

.mud-data-grid .mud-table-cell .mud-checkbox-input {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    margin: 0 auto !important;
}

.mud-data-grid .mud-table-cell .mud-input-control-boolean-input {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
}

td.mud-table-cell {
    padding-left: 5px !important;
}

button.mud-button-root.sort-direction-icon {
    padding: 0px !important;
}

span.column-options {
    width: 84px;
    height: 26px;
    max-width: none;
    display: flex !important;
    gap: 0 !important;
}

span.column-options > * {
    margin: 0 !important;
}

.bpe-explorer-loading-bar {
    min-height: 4px;
}

@media (max-width: 599px) {
    .bpe-explorer-date-filter-stack {
        flex-wrap: wrap;
        align-items: flex-start !important;
    }

    .bpe-explorer-date-filter-stack .field-label-100 {
        width: 100%;
    }
}

.bpe-explorer-mobile-card {
    border: 1px solid var(--mud-palette-lines-default, #e0e0e0);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 4px;
    cursor: pointer;
}

.bpe-explorer-mobile-card.selected {
    background-color: rgba(15, 111, 255, 0.12);
}

.bpe-explorer-mobile-card-title {
    font-weight: 600;
    line-height: 1.3;
}

.bpe-explorer-mobile-card-subtitle {
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
}

.bpe-explorer-mobile-card-detail {
    font-size: 0.875rem;
    margin-top: 4px;
}

.bpe-explorer-mobile-card-meta {
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

.bpe-explorer-compact-toolbar .mud-toolbar {
    min-height: 36px;
    padding-top: 4px;
    padding-bottom: 4px;
}

.bpe-explorer-grid-comfortable .mud-table-cell {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.bpe-explorer-command-bar {
    width: 100%;
}

.bpe-explorer-filter-chip {
    cursor: pointer;
}

.bpe-explorer-tree-children {
    margin-left: 16px;
}

