﻿/* Shared AG Grid palette follows Employee Operations' grids.css reference. */
.erpx-unified-ag-grid {
    --ag-background-color: #fff;
    --ag-foreground-color: #181d1f;
    --ag-header-background-color: #f1f5f9;
    --ag-header-foreground-color: #2e3370;
    --ag-header-cell-hover-background-color: #e9edf4;
    --ag-odd-row-background-color: #fafafa;
    --ag-row-hover-color: #f0eff8;
    --ag-selected-row-background-color: #e9e7f5;
    --ag-border-color: #e5e7eb;
    --ag-row-border-color: #dcdedf;
    --ag-header-column-separator-color: #dcddea;
    --ag-header-column-resize-handle-color: #9599b8;
    border-radius: 12px;
}

.erpx-unified-ag-grid :is(.ag-header, .ag-header-cell, .ag-header-row,
    .ag-header-viewport, .ag-pinned-left-header, .ag-pinned-right-header) {
    background: #f1f5f9 !important;
    color: #2e3370 !important;
}

.erpx-unified-ag-grid :is(.ag-header-cell-text, .ag-header-icon,
    .ag-icon, .ag-header-cell-menu-button, .ag-header-cell-filter-button) {
    color: #2e3370 !important;
}

.erpx-unified-ag-grid .ag-header-cell-label {
    font-weight: 700;
}

.erpx-unified-ag-grid .ag-row-odd:not(.ag-row-pinned) {
    background: #fafafa;
}

.erpx-unified-ag-grid .ag-row-hover:not(.ag-row-pinned) {
    background: #f0eff8;
}

.erpx-unified-ag-grid .ag-row-selected:not(.ag-row-pinned) {
    background: #e9e7f5;
}

.erpx-grid-shell {
    border-color: #e5e7eb;
    border-radius: 12px;
}

.erpx-grid-shell > .erpx-grid-toolbar {
    min-height: 48px;
    padding: 7px 9px;
    background: #f1f5f9;
    border-color: #e5e7eb;
    gap: 10px;
    flex-wrap: wrap;
}

.erpx-grid-toolbar .erpx-grid-columns-button {
    min-height: 34px;
    border-radius: 8px;
    color: #2e3370;
    border-color: #dcddea;
    background: #fff;
}

.inventory-item-editor .item-main-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 18px;
}

.inventory-item-editor :is(.item-master-header, .item-master-tabs) {
    padding: clamp(14px, 1.4vw, 20px);
    min-width: 0;
}

.inventory-item-editor .item-basics-title {
    margin: 0 0 16px;
    color: var(--primary-dark);
    font-size: .95rem;
    font-weight: 800;
}

.inventory-item-editor .compact-alert {
    padding: 8px 12px;
    font-size: .8rem;
    line-height: 1.6;
}

.inventory-item-editor .item-main-grid .check-field {
    min-height: 38px;
    margin: 0;
    background: #fafbfc;
    font-size: .82rem;
}

.inventory-item-editor .erp-form-grid > * {
    min-width: 0;
}

.inventory-item-editor .item-main-grid :is(.form-control, .form-select, .searchable-select-control) {
    min-height: 38px;
    border-radius: 6px;
    font-size: .85rem;
}

.inventory-item-editor .editor-tabs {
    gap: 6px;
    padding: 5px;
    margin: 0 0 18px;
    background: #f1f5f9;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.inventory-item-editor .editor-tabs button {
    flex-shrink: 0;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    color: #59607c;
}

.inventory-item-editor .editor-tabs button.active {
    color: #2e3370;
    background: #fff;
    box-shadow: 0 2px 6px #181d1f12;
}

.inventory-item-editor .editor-tabs button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.inventory-item-editor .inventory-ag-grid {
    max-height: none;
}

.inventory-item-editor .unit-defaults-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafbfc;
}

.inventory-items-filter {
    grid-template-columns: minmax(240px, 2fr) minmax(180px, 1fr) 130px auto;
    gap: 14px;
}

@media (max-width: 1000px) {
    .inventory-item-editor .item-main-grid,
    .inventory-items-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .inventory-item-editor .item-main-grid :is(.form-control, .form-select, .searchable-select-control) {
        min-height: 44px;
    }
    .inventory-item-editor .item-main-grid,
    .inventory-item-editor .unit-defaults-grid,
    .inventory-items-filter {
        grid-template-columns: minmax(0, 1fr);
    }

    .inventory-item-editor .item-main-grid .span-2 {
        grid-column: auto;
    }

    .inventory-item-editor .grid-section-title {
        flex-wrap: wrap;
    }
}

/* Compact, system-wide confirmation dialog. */
.swal2-popup.erpx-swal-popup {
    grid-template-columns: 58px minmax(0, 1fr) 32px !important;
    width: min(445px, calc(100vw - 32px)) !important;
    padding: 20px 20px 16px !important;
    border-radius: 9px !important;
    text-align: start !important;
}

.erpx-swal-popup .swal2-icon {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    align-self: start !important;
    width: 42px !important;
    height: 42px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: #fff3ce !important;
    color: #df8b13 !important;
    font-size: 0.72rem !important;
}

.erpx-swal-popup .swal2-title {
    grid-column: 2 !important;
    grid-row: 1 !important;
    align-self: center !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #1f2522 !important;
    font-size: 1.08rem !important;
    line-height: 1.45 !important;
    text-align: start !important;
}

.erpx-swal-popup .swal2-html-container {
    grid-column: 1 / 4 !important;
    grid-row: 3 !important;
    margin: 12px 0 0 !important;
    padding: 0 !important;
    color: #737b77 !important;
    font-size: 0.93rem !important;
    max-height: none !important;
    overflow: visible !important;
    line-height: 1.65 !important;
    text-align: start !important;
}

.erpx-swal-popup .swal2-close {
    grid-column: 3 !important;
    grid-row: 1 !important;
    position: static !important;
    align-self: start !important;
    justify-self: end !important;
    width: 28px !important;
    height: 28px !important;
    margin: 0 !important;
    color: #626b67 !important;
    font-size: 1.35rem !important;
}

.erpx-swal-popup .swal2-actions {
    grid-column: 1 / 4 !important;
    grid-row: 7 !important;
    direction: ltr !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 14px 0 0 !important;
    padding: 0 !important;
}

.erpx-swal-popup .swal2-actions button {
    min-width: 64px !important;
    min-height: 38px !important;
    margin: 0 !important;
    padding: 8px 16px !important;
    font-size: 0.88rem !important;
}

.erpx-swal-popup .erpx-swal-confirm {
    border: 1px solid #35266f !important;
    color: #35266f !important;
    background: whitesmoke !important;
}

.erpx-swal-popup .erpx-swal-cancel {
    border: 1px solid #c94747 !important;
    color: #b93434 !important;
    background: #fff !important;
}

@media (hover: hover) {
    .erpx-swal-popup .erpx-swal-confirm:hover {
        border-color: #35266f !important;
        color: #fff !important;
        background: #35266f !important;
    }

    .erpx-swal-popup .erpx-swal-cancel:hover {
        border-color: #c94747 !important;
        color: #a72d2d !important;
        background: #fff0f0 !important;
    }
}


.inventory-item-editor .item-identity-grid { grid-template-columns: 180px minmax(0,1fr) minmax(0,1fr); }
.inventory-item-editor .item-supplier-field { grid-column: span 2; }
@media(max-width:600px) { .inventory-item-editor .item-identity-grid { grid-template-columns: minmax(0,1fr); } .inventory-item-editor .item-supplier-field { grid-column:auto; } .inventory-item-editor .item-code-field { max-width:200px; } }
.erpx-notices { margin-inline:0; max-width:calc(100vw - 32px); }
.erpx-notice { width:100%; min-width:0; overflow-wrap:anywhere; }
/* Employee Operations grid typography and action controls. */
.erpx-unified-ag-grid {
    --ag-font-family: var(--font-ui);
    --ag-font-size: 14px;
    --ag-wrapper-border-radius: 4px;
    border-radius: 4px;
}
.erpx-unified-ag-grid .ag-root-wrapper { border-radius: 4px; }
.erpx-unified-ag-grid .ag-cell .erpx-grid-action {
    display: inline-grid; place-items: center; flex: 0 0 38px;
    width: 38px; height: 38px; min-width: 38px; min-height: 38px;
    margin-inline: 3px; padding: 0; border-radius: 10px;
    border: 1px solid #b9d8cc; background: #f2faf7; color: #176b4b;
    vertical-align: middle; box-shadow: none;
}
.erpx-unified-ag-grid .ag-cell .erpx-grid-action[data-erpx-grid-action=view] {
    background: #eaf7f2; border-color: #b9ddcf; color: #087858;
}
.erpx-unified-ag-grid .ag-cell .erpx-grid-action[data-erpx-grid-action=delete] {
    background: #fff8f8; border-color: #efb4b4; color: #b43a3a;
}
.erpx-unified-ag-grid .erpx-grid-action svg {
    width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.erpx-unified-ag-grid .ag-cell .erpx-grid-action:hover { background: #e2f5ed; }
.erpx-unified-ag-grid .ag-cell .erpx-grid-action[data-erpx-grid-action=delete]:hover { background: #feeaea; }
.erpx-unified-ag-grid .ag-cell .erpx-grid-action:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
html[data-theme=dark] .erpx-unified-ag-grid .ag-cell .erpx-grid-action {
    color: #36d39f; border-color: #346052; background: #173b30;
}
html[data-theme=dark] .erpx-unified-ag-grid .ag-cell .erpx-grid-action[data-erpx-grid-action=delete] {
    color: #f18c8c; border-color: #704040; background: #402525;
}
.erpx-ag-list-cell :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea) {
    width: 100%; max-width: 100%; min-width: 0; height: 34px;
    background: var(--control-bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px;
}
@media screen { table.erpx-ag-source { display: none !important; } }
@media print { table.erpx-ag-source { display: table !important; } }
.erpx-unified-ag-grid .ag-cell .erpx-grid-action[hidden] { display: none !important; }
.erpx-unified-ag-grid .ag-cell .erpx-grid-action:disabled { opacity: .45; cursor: not-allowed; }

/* Column layout matches Fixed Assets. */
.grid-layout-header { padding: 0 !important; }
.grid-layout-header .ag-header-cell-comp-wrapper { width: 100%; height: 100%; }
.grid-layout-panel { width: 100%; height: 100%; }
.grid-layout-panel > summary { display: flex; align-items: center; justify-content: center; height: 100%; list-style: none; cursor: pointer; color: var(--primary); font-size: 15px; }
.grid-layout-panel > summary::-webkit-details-marker { display: none; }
.grid-layout-panel > summary:hover, .grid-layout-panel[open] > summary { background: var(--surface-soft); }
.grid-layout-panel > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
.grid-layout-popover { z-index: 2100; position: fixed; width: 310px; max-width: calc(100vw - 32px); max-height: calc(100vh - 24px); background: var(--canvas); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 8px 24px #0002; overflow: auto; }
.grid-layout-popover > header { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 10px; }
.grid-layout-popover strong { flex: 1; }
.grid-layout-popover button { border: 0; border-radius: 4px; background: transparent; color: var(--primary); padding: 5px; font: inherit; cursor: pointer; }
.grid-layout-popover > p { margin: 0; padding: 10px; font-size: 10px; color: var(--text-muted); }
.grid-layout-columns { max-height: 300px; overflow-y: auto; }
.grid-layout-column { display: flex; align-items: center; gap: 6px; padding: 7px 10px; font-size: 11px; }
.grid-layout-column:hover { background: var(--surface-soft); }
.grid-layout-column > i { cursor: grab; color: var(--text-muted); }
.grid-layout-column label { display: flex; align-items: center; gap: 7px; flex: 1; }
.grid-layout-column input { accent-color: var(--primary); }
.grid-layout-column .grid-column-width { width: 55px; padding: 4px; background: var(--canvas); color: var(--text); border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.grid-layout-popover > footer { padding: 8px 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.grid-layout-popover small { color: var(--success); font-size: 10px; }

.grid-layout-popover[hidden] { display: none !important; }
@media print { .grid-layout-popover, .grid-layout-header { display: none !important; } }

.erpx-unified-ag-grid { --ag-font-size: 11px; --ag-wrapper-border-radius: 0; border-radius: 0; }
.grid-layout-popover .grid-column-width { min-height: 0; height: auto; }

.grid-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px;
    color: var(--text-secondary);
    text-align: center;
    pointer-events: none;
}

.grid-empty-state svg {
    width: 150px;
    max-width: 100%;
    height: 100px;
}

.grid-empty-state p {
    margin: 0;
    font-size: 13px;
    line-height: 1.8;
    white-space: normal;
}

.grid-empty-line { stroke: #eceef0; stroke-width: 2; }
.grid-empty-light { fill: #fff; }
.grid-empty-furniture { fill: #e2e3e5; }
.grid-empty-shadow { fill: #ececf1; }
.grid-empty-back { fill: #51418d; }
.grid-empty-paper { fill: #f4f3f9; }
.grid-empty-folder { fill: #37286d; }
html[data-theme="dark"] .grid-empty-line { stroke: #373044; }
html[data-theme="dark"] .grid-empty-light { fill: #2b243c; }
html[data-theme="dark"] .grid-empty-furniture { fill: #383145; }
html[data-theme="dark"] .grid-empty-shadow { fill: #171221; }
html[data-theme="dark"] .grid-empty-back { fill: #a18acb; }
html[data-theme="dark"] .grid-empty-paper { fill: #e0d9ec; }
html[data-theme="dark"] .grid-empty-folder { fill: #8066b2; }

/* Shared pagination layout for every paginated AG Grid. */
.erpx-unified-ag-grid .ag-paging-panel { min-height: 48px; padding: 6px 12px; }
.erpx-unified-ag-grid .ag-paging-panel-content { display: flex; gap: 12px; flex-wrap: wrap; }
.erpx-unified-ag-grid .ag-paging-page-size { order: 0; margin: 0; }
.erpx-unified-ag-grid .ag-paging-row-summary-panel { order: 1; margin-inline: auto; white-space: nowrap; }
.erpx-unified-ag-grid .ag-paging-page-summary-panel { order: 2; gap: 3px; margin: 0; }
.erpx-unified-ag-grid .ag-paging-page-size .ag-picker-field-wrapper { min-width: 88px; }
.erpx-unified-ag-grid .ag-paging-button { width: 30px; height: 30px; border-radius: 6px; }
.erpx-unified-ag-grid .ag-paging-button:not(.ag-disabled):hover { background: var(--ag-row-hover-color); }
.erpx-unified-ag-grid .ag-paging-number { width: 64px; }
.erpx-unified-ag-grid .ag-paging-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.unified-pager.zatca-grid-pager { display: grid; margin-top: 0; }
.invoice-item-description { display: block; font-size: inherit; font-weight: 600; line-height: 1.7; }
@media (max-width: 650px) {
    .erpx-unified-ag-grid .ag-paging-panel { height: auto; }
    .erpx-unified-ag-grid .ag-paging-page-summary-panel { flex-basis: 100%; justify-content: center; }
}
/* Document state remains readable in selected/hovered rows and both themes. */
.erpx-unified-ag-grid .ag-cell.erpx-state-draft {
    color: #805100;
    background-color: #fff4d6;
    font-weight: 700;
}
.erpx-unified-ag-grid .ag-cell.erpx-state-posted {
    color: #086347;
    background-color: #ddf5e9;
    font-weight: 700;
}
html[data-theme='dark'] .erpx-unified-ag-grid .ag-cell.erpx-state-draft {
    color: #ffe09b;
    background-color: #44351b;
}
html[data-theme='dark'] .erpx-unified-ag-grid .ag-cell.erpx-state-posted {
    color: #9ce8c5;
    background-color: #173c31;
}
.erpx-unified-ag-grid .ag-cell:is(.erpx-state-draft,.erpx-state-posted) :is(span,div) {
    color: inherit;
}
.erpx-unified-ag-grid .ag-cell:is(.erpx-state-draft,.erpx-state-posted) :is(.status-pill,.badge) {
    color: inherit !important;
    background: transparent !important;
    border-color: transparent !important;
}

/* Compact shared footer; controls retain a usable click area on touch screens. */
.zatca-grid-pager,
.unified-pager,
.erpx-unified-ag-grid .ag-paging-panel {
    font-size: 12px;
    line-height: 1.4;
}
.zatca-grid-pager :is(label, select, input, nav, .zatca-range),
.unified-pager :is(label, select, input, nav) { font-size: inherit; }
.zatca-grid-pager { gap: 8px; padding: 6px 12px; min-height: 44px; }
.zatca-grid-pager select { min-width: 76px; width: auto; height: 32px; padding: 3px 8px; }
.zatca-grid-pager .zatca-page-position input { width: 52px; min-width: 52px; height: 30px; }
.accounting-document-totals[hidden] { display: none !important; }
.erpx-accounting-entry-grid .ag-row-pinned { font-weight: 700; background: var(--surface-soft); }
@media (max-width: 650px) {
    .zatca-grid-pager { grid-template-columns: minmax(0, 1fr); justify-items: center; }
    .zatca-grid-pager > * { min-width: 0; max-width: 100%; }
    .zatca-grid-pager nav { grid-column: 1; flex-wrap: wrap; justify-content: center; }
    .zatca-grid-pager :is(select, input, nav a) { min-height: 36px; }
    .zatca-grid-pager select { font-size: 16px; }
    .app-shell main { min-width: 0; }
    .app-shell :is(.form-grid, .filter-grid, .document-header-grid, .document-form-grid) { grid-template-columns: minmax(0, 1fr); }
    .app-shell :is(.form-grid, .filter-grid, .document-header-grid, .document-form-grid) > * { min-width: 0; max-width: 100%; }
    .app-shell :is(.form-grid, .filter-grid, .document-header-grid, .document-form-grid) :is(input, select, textarea) { max-width: 100%; }
}
.erpx-unified-ag-grid .ag-cell.erpx-stock-shortage { color: #a32132; background: #ffedf0; }
html[data-theme='dark'] .erpx-unified-ag-grid .ag-cell.erpx-stock-shortage { color: #ffadb6; background: #4c2028; }
