@import '/_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css';

/* =========================================================
   01. Base Shell
   ========================================================= */

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden !important;
}

body {
    --body-font: "Segoe UI Variable", "Segoe UI", sans-serif;
    font-family: var(--body-font);
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    margin: 0;
}

/* =========================================================
   02. ERP Fixed Application Layout
   Purpose:
   - Disable browser/page-level scroll
   - Keep top header fixed
   - Keep content area bounded
   - Allow only internal page components to scroll
   ========================================================= */

#app {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden !important;
}

.page,
fluent-layout {
    width: 100%;
    height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

fluent-layout {
    display: flex !important;
    flex-direction: column !important;
}

fluent-header {
    flex: 0 0 auto !important;
}

/* =========================================================
   03. Main Shell Area
   Purpose:
   - Left navigation + body content layout
   - No page scroll here
   ========================================================= */

.main,
fluent-main,
fluent-stack.main {
    height: auto !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    color: var(--neutral-foreground-rest);
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    overflow: hidden !important;
}

/* =========================================================
   04. Body Content Area
   Purpose:
   - Bounded content area
   - Listing pages can create their own internal scroll
   ========================================================= */

.body-content,
fluent-body-content,
fluent-body-content.body-content {
    width: 100%;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    align-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.content {
    width: 100%;
    height: 100%;
    min-width: 0 !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    padding: 0 !important;
    align-self: stretch !important;
    overflow: hidden !important;
}

    /* =========================================================
   05. Flex Child Safety
   Purpose:
   - Required for internal scroll inside nested flex layouts
   ========================================================= */

    .page > *,
    .main > *,
    .body-content > *,
    .content > *,
    fluent-body-content > * {
        min-width: 0 !important;
        min-height: 0 !important;
    }

/* =========================================================
   06. Left Navigation
   Purpose:
   - Left menu can scroll independently
   ========================================================= */

.navmenu-icon {
    display: none;
}

nav.sitenav {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.manage {
    width: 100dvw;
}

/* =========================================================
   07. Footer
   ========================================================= */

footer,
fluent-footer {
    height: 22px;
    min-height: 22px;
    flex: 0 0 22px;
    padding: 2px 10px;
    display: flex;
    align-items: center;
    background: var(--neutral-layer-4);
    color: var(--neutral-foreground-rest);
    font-size: 11px;
    overflow: hidden;
}

    footer a {
        color: var(--neutral-foreground-rest);
        text-decoration: none;
    }

        footer a:focus {
            outline: 1px dashed;
            outline-offset: 3px;
        }

        footer a:hover {
            text-decoration: underline;
        }

/* =========================================================
   08. Common UI
   ========================================================= */

.alert {
    border: 1px dashed var(--accent-fill-rest);
    padding: 5px;
}

code {
    color: #c02d76;
}

/* =========================================================
   09. Blazor Error UI
   ========================================================= */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    margin: 20px 0;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::before {
        content: "An error has occurred. ";
    }

/* =========================================================
   10. Loading Progress
   ========================================================= */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text::after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* =========================================================
   11. Normalize Fluent Inputs
   ========================================================= */

.fluent-text-field input,
.fluent-combobox,
.fluent-select,
.fluent-combobox input {
    height: 36px !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

/* =========================================================
   12. Mobile Layout
   Purpose:
   - Mobile allows normal page scroll
   ========================================================= */

@media (max-width: 600px) {
    html,
    body {
        overflow: auto !important;
    }

    #app,
    .page,
    fluent-layout {
        height: auto !important;
        min-height: 100dvh !important;
        overflow: auto !important;
    }

    .header-gutters {
        margin: 0.5rem 3rem 0.5rem 1.5rem !important;
    }

    [dir="rtl"] .header-gutters {
        margin: 0.5rem 1.5rem 0.5rem 3rem !important;
    }

    .main,
    fluent-main,
    fluent-stack.main {
        height: auto !important;
        min-height: 100dvh !important;
        flex-direction: column !important;
        row-gap: 0 !important;
        overflow: auto !important;
    }

    .body-content,
    fluent-body-content,
    fluent-body-content.body-content {
        height: auto !important;
        overflow: visible !important;
    }

    .content {
        height: auto !important;
        overflow: visible !important;
    }

    footer,
    fluent-footer {
        height: auto;
        min-height: 22px;
    }

    nav.sitenav {
        width: 100%;
        height: 100%;
    }

    #main-menu {
        width: 100% !important;
    }

        #main-menu > div:first-child:is(.expander) {
            display: none;
        }

    .navmenu {
        width: 100%;
    }

    #navmenu-toggle {
        appearance: none;
    }

        #navmenu-toggle ~ nav {
            display: none;
        }

        #navmenu-toggle:checked ~ nav {
            display: block;
        }

    .navmenu-icon {
        cursor: pointer;
        z-index: 10;
        display: block;
        position: absolute;
        top: 15px;
        left: unset;
        right: 20px;
        width: 20px;
        height: 20px;
        border: none;
    }

    [dir="rtl"] .navmenu-icon {
        left: 20px;
        right: unset;
    }
}
/* =========================================================
   ERP Listing Final Scroll Fix
   Purpose:
   - Disable page/browser level scroll
   - Keep header/menu fixed
   - Allow only listing grid body to scroll
   ========================================================= */

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden !important;
}

#app,
.page,
fluent-layout {
    width: 100%;
    height: 100dvh !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

fluent-layout {
    display: flex !important;
    flex-direction: column !important;
}

.main,
fluent-main,
fluent-stack.main {
    flex: 1 1 0 !important;
    width: 100%;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    overflow: hidden !important;
}

.body-content,
fluent-body-content,
fluent-body-content.body-content {
    flex: 1 1 0 !important;
    width: 100%;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.content {
    flex: 1 1 0 !important;
    width: 100%;
    height: 100%;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

    .content > * {
        min-width: 0 !important;
        min-height: 0 !important;
    }

nav.sitenav {
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

@media (max-width: 720px) {
    html,
    body,
    #app,
    .page,
    fluent-layout,
    .main,
    fluent-main,
    fluent-stack.main,
    .body-content,
    fluent-body-content,
    fluent-body-content.body-content,
    .content {
        height: auto !important;
        overflow: auto !important;
    }
}/* =========================================================
   01. ERP Master Page Shell
   Purpose:
   - Outer page does not scroll
   - Header and toolbar stay fixed
   - Only grid rows scroll internally
   ========================================================= */

.erp-master-page {
    width: 100%;
    height: calc(100vh - 78px);
    min-width: 0;
    min-height: 0;
    max-width: none;
    box-sizing: border-box;
    padding: 4px 8px;
    background: #f5f7fb;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   02. Top Title + Toolbar Panel
   ========================================================= */

.erp-master-panel {
    flex: 0 0 auto;
    min-width: 0;
    margin-bottom: 6px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5eaf3;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.erp-master-title-row {
    min-height: 38px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #eef5ff 100%);
    border-bottom: 1px solid #edf1f7;
}

.erp-master-title-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.erp-master-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.erp-master-title-line h1 {
    margin: 0;
    color: #0f172a;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.erp-master-title-line span {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    background: #eef6ff;
    color: #175cd3;
    border: 1px solid #b8dbff;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}

.erp-master-breadcrumb {
    color: #667085;
    font-size: 10.5px;
    white-space: nowrap;
    padding-right: 6px;
}

/* =========================================================
   03. Main Grid Card
   Purpose:
   - Filter fixed at top
   - Grid scroll in middle
   - Footer fixed at bottom
   ========================================================= */

.erp-master-grid-card {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #e5eaf3;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

/* =========================================================
   04. Filter Panel Area
   ========================================================= */

.erp-master-grid-card ::deep .erp-filter-panel {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.erp-master-grid-card ::deep .erp-filter-body {
    flex: 0 0 auto;
    padding: 6px 10px;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: end;
    gap: 10px;
    background: #fbfcff;
    border-bottom: 1px solid #edf1f7;
}

/* =========================================================
   05. KPI Summary Boxes
   ========================================================= */

.erp-master-kpis {
    width: 280px;
    min-width: 280px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid #edf1f7;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
}

.erp-master-kpis div {
    padding: 5px 7px;
    border-right: 1px solid #edf1f7;
}

.erp-master-kpis div:last-child {
    border-right: none;
}

.erp-master-kpis span {
    display: block;
    color: #667085;
    font-size: 9.5px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.erp-master-kpis strong {
    display: block;
    color: #0f3d75;
    font-size: 15px;
    line-height: 1;
}

/* =========================================================
   06. Filter Controls
   ========================================================= */

.erp-master-filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px auto;
    align-items: end;
    gap: 10px;
}

.erp-master-filter-grid.advanced {
    display: grid;
    grid-template-columns: 130px 130px 130px minmax(260px, 1fr) 100px auto;
    align-items: end;
    gap: 8px;
}

.erp-master-filter-field,
.erp-master-filter-grid.advanced .erp-master-filter-field,
.erp-master-filter-grid.advanced ::deep .erp-master-filter-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    font-size: 10.5px;
    font-weight: 650;
    color: #344054;
}

.erp-master-filter-field fluent-search,
.erp-master-filter-grid.advanced .erp-master-filter-field fluent-search {
    width: 100%;
}

.erp-filter-select,
.erp-master-filter-grid.advanced ::deep .erp-filter-select,
.erp-master-filter-grid.advanced .erp-filter-select,
.erp-rows-select,
.erp-master-filter-grid.advanced .erp-rows-select {
    width: 100%;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #d6e0ed;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    font-size: 12px;
    outline: none;
}

.erp-filter-select:focus,
.erp-master-filter-grid.advanced ::deep .erp-filter-select:focus,
.erp-master-filter-grid.advanced .erp-filter-select:focus,
.erp-rows-select:focus,
.erp-master-filter-grid.advanced .erp-rows-select:focus {
    border-color: #0078d4;
    box-shadow: 0 0 0 1px rgba(0, 120, 212, 0.18);
}

.erp-master-inline-actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 6px;
}

.erp-master-inline-actions fluent-button {
    min-width: 58px;
}

/* =========================================================
   07. Grid Scroll Area
   Purpose:
   - This is the only vertical scroll area
   ========================================================= */

.erp-master-grid-scroll {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    isolation: isolate;
    background: #ffffff;
}

/* =========================================================
   08. Fluent DataGrid Width / Visibility Fix
   ========================================================= */

.erp-master-grid-scroll ::deep fluent-data-grid {
    width: 100%;
    min-width: 100%;
    height: auto;
    min-height: 100%;
    overflow: visible !important;
    display: table;
}

.erp-master-grid {
    font-size: 12px;
}

/* =========================================================
   09. Sticky Grid Header
   ========================================================= */

.erp-master-grid-scroll ::deep fluent-data-grid-row[row-type="header"] {
    position: sticky !important;
    top: 0 !important;
    z-index: 50 !important;
    background: #ffffff !important;
    box-shadow: 0 1px 0 #dbe5f1;
}

.erp-master-grid-scroll ::deep fluent-data-grid-cell[cell-type="columnheader"] {
    position: sticky !important;
    top: 0 !important;
    z-index: 51 !important;
    background: #ffffff !important;
    color: #0f172a;
    font-weight: 750;
}

.erp-master-grid-scroll ::deep fluent-data-grid-row[row-type="header"] fluent-data-grid-cell {
    background: #ffffff !important;
    color: #0f172a;
    font-weight: 750;
}

/* =========================================================
   10. Grid Compact Rows
   ========================================================= */

.erp-master-grid ::deep fluent-data-grid-row {
    min-height: 28px;
}

.erp-master-grid ::deep fluent-data-grid-cell,
.erp-master-grid ::deep fluent-data-grid-column {
    min-height: 28px;
    padding-top: 2px;
    padding-bottom: 2px;
    align-items: center;
}

.erp-master-grid ::deep fluent-checkbox {
    width: 15px;
    height: 15px;
}

.erp-master-grid ::deep svg {
    width: 14px;
    height: 14px;
}

/* =========================================================
   11. Empty Grid Message
   ========================================================= */

.erp-master-empty-state {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667085;
    font-size: 13px;
    background: #ffffff;
    border-top: 1px solid #edf1f7;
}

/* =========================================================
   12. Grid Footer / Pagination
   ========================================================= */

.erp-master-grid-footer {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #edf1f7;
    font-size: 11.5px;
    color: #667085;
    background: #fbfcff;
}

.erp-master-pager-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =========================================================
   13. Loading State
   ========================================================= */

.erp-master-loading {
    flex: 1 1 auto;
    min-height: 0;
    padding: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    color: #667085;
}

/* =========================================================
   14. Row Action Buttons
   ========================================================= */

.erp-row-actions {
    display: flex;
    align-items: center;
    gap: 1px;
}

.erp-row-actions ::deep fluent-button {
    width: 23px;
    height: 23px;
}

/* =========================================================
   15. Badges
   ========================================================= */

.erp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 19px;
    border-radius: 999px;
    padding: 0 7px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid transparent;
}

.erp-badge.success {
    background: #ecfdf3;
    color: #027a48;
    border-color: #abefc6;
}

.erp-badge.info {
    background: #eef6ff;
    color: #175cd3;
    border-color: #b8dbff;
}

.erp-badge.danger {
    background: #fef3f2;
    color: #b42318;
    border-color: #fecdca;
}

.erp-badge.neutral {
    background: #f2f4f7;
    color: #475467;
    border-color: #e4e7ec;
}

/* =========================================================
   16. Scrollbar
   ========================================================= */

.erp-master-grid-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.erp-master-grid-scroll::-webkit-scrollbar-thumb {
    background: #c8d3e1;
    border-radius: 10px;
}

.erp-master-grid-scroll::-webkit-scrollbar-track {
    background: #f3f6fa;
}

/* =========================================================
   17. Responsive
   ========================================================= */

@media (max-width: 1366px) {
    .erp-master-grid-card ::deep .erp-filter-body {
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .erp-master-filter-grid.advanced {
        grid-template-columns: 125px 125px 125px minmax(240px, 1fr) 95px auto;
        gap: 8px;
    }
}

@media (max-width: 1280px) {
    .erp-master-grid-card ::deep .erp-filter-body {
        grid-template-columns: 1fr;
    }

    .erp-master-kpis {
        width: 100%;
        min-width: 0;
    }

    .erp-master-filter-grid,
    .erp-master-filter-grid.advanced {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .erp-rows-select {
        max-width: 160px;
    }

    .erp-master-inline-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .erp-master-page {
        height: auto;
        min-height: calc(100vh - 44px);
        padding: 7px;
        overflow: auto !important;
    }

    .erp-master-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .erp-master-title-line {
        flex-wrap: wrap;
    }

    .erp-master-title-line h1 {
        white-space: normal;
    }

    .erp-master-breadcrumb {
        padding-right: 0;
        white-space: normal;
    }

    .erp-master-kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    .erp-master-filter-grid,
    .erp-master-filter-grid.advanced {
        grid-template-columns: 1fr;
    }

    .erp-master-grid-card {
        min-height: 420px;
    }

    .erp-master-grid-scroll {
        min-height: 280px;
    }

    .erp-master-grid-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
}

/* =========================================================
   Menu Management
   ========================================================= */

.erp-page {
    height: 100%;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    background: #f8fafc;
}

.erp-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
}

    .erp-page-header h3 {
        margin: 0;
        font-size: 18px;
        color: #111827;
    }

    .erp-page-header p {
        margin: 3px 0 0 0;
        font-size: 13px;
        color: #6b7280;
    }

.erp-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
}

    .erp-filter-bar label {
        font-size: 13px;
        color: #374151;
    }

    .erp-filter-bar input {
        width: 90px;
        height: 32px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        padding: 0 8px;
    }

.erp-primary-btn,
.erp-secondary-btn {
    height: 34px;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 13px;
}

.erp-primary-btn {
    background: #111827;
    color: #ffffff;
    border: 1px solid #111827;
}

.erp-secondary-btn {
    background: #ffffff;
    color: #111827;
    border: 1px solid #d1d5db;
}

.erp-message {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
}

.erp-loading {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    color: #6b7280;
}
/* Read-only radio groups (Fluent V5 clears the selection of a disabled
   fluent-radio-group, so read-only ones stay enabled but cannot be clicked). */
.erp-radio-locked {
    pointer-events: none;
    opacity: 0.7;
}
