/*
 * Shared ERP form and item-grid standard.
 *
 * This is the reusable visual contract established by GRN. global.js applies
 * these classes to ERP forms and grids automatically. POS and Mobile POS are
 * explicitly excluded so their touch-first interface remains unchanged.
 */
:root {
    --erp-standard-font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    --erp-standard-canvas: #f4f6f9;
    --erp-standard-surface: #fff;
    --erp-standard-ink: #102f5c;
    --erp-standard-heading: #10233f;
    --erp-standard-primary: #175cd3;
    --erp-standard-primary-strong: #1d5fa7;
    --erp-standard-primary-dark: #174f91;
    --erp-standard-primary-soft: #edf5ff;
    --erp-standard-table-border: #d5dfec;
    --erp-standard-table-divider: #dbe5f1;
    --erp-standard-table-heading: #153a70;
    --erp-standard-table-heading-bg: #eaf3ff;
    --erp-standard-table-heading-border: #cfdded;
    --erp-standard-table-row: #fff;
    --erp-standard-table-row-alt: #f2f6fc;
    --erp-standard-table-editable: #c9dbf5;
    --erp-standard-table-focus: #4b82c4;
    --erp-standard-table-focus-ring: rgba(37, 99, 235, .14);
    --erp-standard-approved: #15803d;
    --erp-standard-approved-border: #166534;
    --erp-standard-deleted: #b91c1c;
    --erp-standard-deleted-border: #991b1b;
    --erp-standard-col-remove: 48px;
    --erp-standard-col-number: 20px;
    --erp-standard-col-code: 7%;
    --erp-standard-col-uom: 6%;
    --erp-standard-col-qty: calc(7% - 5px);
    --erp-standard-col-money: 98px;
    --erp-standard-col-total: 108px;
}

body.erp-standard-page {
    font-family: var(--erp-standard-font-family);
    color: var(--erp-standard-heading);
    background: var(--erp-standard-canvas);
}

body.erp-standard-page .erp-standard-form { gap: 12px; }
body.erp-standard-page .erp-standard-form > .erp-standard-form-card,
body.erp-standard-page .erp-standard-form > .erp-standard-lines-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
body.erp-standard-page .erp-standard-form .erp-standard-form-card .form-section { padding: 14px 16px; }
body.erp-standard-page .erp-standard-header-grid { align-items: end; gap: 14px 16px; }
body.erp-standard-page .erp-standard-header-grid .field { min-width: 0; }
body.erp-standard-page .erp-standard-header-grid .field input,
body.erp-standard-page .erp-standard-header-grid .field select { min-height: 42px; }

body.erp-standard-page:not(.pos-body) :is(.field,.erp-standard-field) {
    gap: 5px;
    color: var(--erp-standard-heading);
    font-size: .78rem;
    font-weight: 700;
}
body.erp-standard-page:not(.pos-body) :is(.field,.erp-standard-field) :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 7px 10px;
    color: var(--erp-standard-ink);
    border: 1px solid var(--erp-standard-table-border);
    border-radius: 6px;
    background: var(--erp-standard-surface);
    box-shadow: none;
    box-sizing: border-box;
    font-family: var(--erp-standard-font-family);
    font-size: .8rem;
    font-weight: 600;
}
body.erp-standard-page:not(.pos-body) :is(.field,.erp-standard-field) :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):focus {
    border-color: var(--erp-standard-primary);
    outline: 0;
    box-shadow: 0 0 0 3px var(--erp-standard-table-focus-ring);
}
body.erp-standard-page:not(.pos-body) :is(.field,.erp-standard-field) :is(input,textarea)[readonly],
body.erp-standard-page:not(.pos-body) :is(.field,.erp-standard-field) :is(input,select,textarea):disabled {
    color: #475569;
    border-color: #d8e0eb;
    background: #eef2f7;
    opacity: 1;
}

@media (min-width: 1051px) {
    body.erp-standard-page .erp-standard-header-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

body.erp-standard-page .erp-standard-lines-card {
    display: flex;
    height: 420px;
    min-height: 420px;
    overflow: hidden;
    flex-direction: column;
    border: 1px solid #ccd5e1;
    border-radius: 8px;
    background: var(--erp-standard-surface);
    box-shadow: 0 2px 7px rgba(15, 35, 65, .12);
}
body.erp-standard-page .erp-standard-lines-card .erp-standard-section-heading {
    margin: 0 10px;
    padding: 8px 2px 6px;
    border-bottom: 2px solid var(--erp-standard-primary-strong);
    background: var(--erp-standard-surface);
}
body.erp-standard-page .erp-standard-lines-card .erp-standard-section-heading h2 {
    margin: 0;
    color: var(--erp-standard-heading);
    font-size: .9rem;
    font-weight: 800;
    text-transform: uppercase;
}
body.erp-standard-page .erp-standard-lines-card .erp-standard-section-heading p { display: none; }
body.erp-standard-page .erp-standard-lines-card .erp-standard-add-row {
    min-width: auto;
    padding: 5px 10px;
    border: 0;
    color: var(--erp-standard-primary-dark);
    background: var(--erp-standard-primary-soft);
    box-shadow: none;
}
body.erp-standard-page .erp-standard-lines-card > .erp-standard-table-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    margin: 0;
    padding: 5px 10px 8px;
    overflow: auto;
    flex: 1 1 auto;
    border: 0;
    border-radius: 0;
    background: var(--erp-standard-surface);
    box-sizing: border-box;
    scrollbar-gutter: stable;
}

body.erp-standard-page table.erp-standard-table {
    width: 100%;
    min-width: 1350px;
    overflow: visible;
    table-layout: fixed;
    border: 1px solid var(--erp-standard-table-border);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    background: var(--erp-standard-surface);
    color: var(--erp-standard-ink);
}
body.erp-standard-page table.erp-standard-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
body.erp-standard-page table.erp-standard-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 7px 4px;
    color: var(--erp-standard-table-heading);
    background: var(--erp-standard-table-heading-bg);
    border: 0;
    border-bottom: 1px solid var(--erp-standard-table-heading-border);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .025em;
    text-align: center;
    text-transform: uppercase;
}
body.erp-standard-page table.erp-standard-table tbody tr,
body.erp-standard-page table.erp-standard-table tbody tr:hover { background: var(--erp-standard-table-row); }
body.erp-standard-page table.erp-standard-table tbody tr:nth-child(even),
body.erp-standard-page table.erp-standard-table tbody tr:nth-child(even):hover { background: var(--erp-standard-table-row-alt); }
body.erp-standard-page table.erp-standard-table tbody td {
    height: 50px;
    padding: 5px 4px;
    overflow: hidden;
    color: var(--erp-standard-ink);
    text-overflow: ellipsis;
    white-space: nowrap;
    background: inherit;
    border: 0;
    border-bottom: 1px solid var(--erp-standard-table-divider);
    font-size: .82rem;
}
body.erp-standard-page table.erp-standard-table tbody tr:last-child td { border-bottom: 0; }
body.erp-standard-page table.erp-standard-table .erp-col-editable { background: var(--erp-standard-table-editable); }
body.erp-standard-page table.erp-standard-table td input,
body.erp-standard-page table.erp-standard-table td select {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 6px 8px;
    overflow: hidden;
    color: var(--erp-standard-ink) !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-color: transparent !important;
    border-radius: 3px;
    background: transparent !important;
    box-shadow: none !important;
    box-sizing: border-box;
    font-weight: 600;
}
body.erp-standard-page table.erp-standard-table td.erp-col-editable input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([readonly]):not(:disabled),
body.erp-standard-page table.erp-standard-table td.erp-col-editable select:not(:disabled) {
    color: var(--erp-standard-ink) !important;
    background: transparent !important;
}
body.erp-standard-page table.erp-standard-table td.erp-col-editable input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([readonly]):not(:disabled):hover,
body.erp-standard-page table.erp-standard-table td.erp-col-editable select:not(:disabled):hover { background: rgba(255, 255, 255, .42) !important; }
body.erp-standard-page table.erp-standard-table td.erp-col-editable input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([readonly]):not(:disabled):focus,
body.erp-standard-page table.erp-standard-table td.erp-col-editable select:not(:disabled):focus {
    border-color: var(--erp-standard-table-focus) !important;
    outline: 0;
    background: #fff !important;
    box-shadow: 0 0 0 2px var(--erp-standard-table-focus-ring) !important;
}
body.erp-standard-page table.erp-standard-table .line-number,
body.erp-standard-page table.erp-standard-table .erp-col-number { color: #214677; font-weight: 700; }
body.erp-standard-page table.erp-standard-table .remove-line-button {
    border: 0;
    background: transparent;
    box-shadow: none;
    opacity: .58;
}
body.erp-standard-page table.erp-standard-table .remove-line-button:hover,
body.erp-standard-page table.erp-standard-table .remove-line-button:focus { background: #e8eef7; opacity: 1; }
body.erp-standard-page table.erp-standard-table .remove-line-button img { filter: none; }
body.erp-standard-page table.erp-standard-table .remove-line-button:disabled {
    pointer-events: none;
    cursor: not-allowed;
    opacity: .22;
}
body.erp-standard-page table.erp-standard-table .money-cell { position: relative; vertical-align: middle; }
body.erp-standard-page table.erp-standard-table .money-cell .currency-code {
    position: absolute;
    top: 50%;
    bottom: auto;
    left: 6px;
    z-index: 1;
    display: inline-flex;
    height: 1em;
    align-items: center;
    color: #64748b;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
    pointer-events: none;
    transform: translateY(-50%);
}
body.erp-standard-page table.erp-standard-table .money-cell input {
    padding-right: 6px !important;
    padding-left: 34px !important;
    text-align: right !important;
    white-space: nowrap;
}

/* Semantic column sizes: reuse these classes wherever the same field appears. */
body.erp-standard-page table.erp-standard-table .erp-col-hidden { display: none !important; }
body.erp-standard-page table.erp-standard-table .erp-col-remove {
    width: var(--erp-standard-col-remove) !important;
    min-width: var(--erp-standard-col-remove) !important;
    max-width: var(--erp-standard-col-remove) !important;
    padding-right: 6px !important;
    padding-left: 6px !important;
    text-align: center !important;
}
body.erp-standard-page table.erp-standard-table .erp-col-number {
    width: var(--erp-standard-col-number) !important;
    min-width: var(--erp-standard-col-number) !important;
    max-width: var(--erp-standard-col-number) !important;
    padding-right: 1px !important;
    padding-left: 1px !important;
    text-align: center !important;
}
body.erp-standard-page table.erp-standard-table .erp-col-code { width: var(--erp-standard-col-code) !important; }
body.erp-standard-page table.erp-standard-table .erp-col-description { width: auto !important; }
body.erp-standard-page table.erp-standard-table .erp-col-uom { width: var(--erp-standard-col-uom) !important; }
body.erp-standard-page table.erp-standard-table .erp-col-qty {
    width: var(--erp-standard-col-qty) !important;
    min-width: 65px !important;
    text-align: right !important;
}
body.erp-standard-page table.erp-standard-table .erp-col-tax-type { width: 11% !important; }
body.erp-standard-page table.erp-standard-table .erp-col-money {
    width: var(--erp-standard-col-money) !important;
    min-width: var(--erp-standard-col-money) !important;
    max-width: var(--erp-standard-col-money) !important;
    text-align: right !important;
}
body.erp-standard-page table.erp-standard-table .erp-col-total {
    width: var(--erp-standard-col-total) !important;
    min-width: var(--erp-standard-col-total) !important;
    max-width: var(--erp-standard-col-total) !important;
    text-align: right !important;
}
body.erp-standard-page table.erp-standard-table .erp-col-qty input { text-align: right !important; }

body.erp-standard-page .erp-standard-status.status-approved {
    color: #fff !important;
    background: var(--erp-standard-approved) !important;
    border-color: var(--erp-standard-approved-border) !important;
    -webkit-text-fill-color: #fff;
}
body.erp-standard-page .erp-standard-status.status-deleted {
    color: #fff !important;
    background: var(--erp-standard-deleted) !important;
    border-color: var(--erp-standard-deleted-border) !important;
    -webkit-text-fill-color: #fff;
}

@media (min-width: 901px) {
    html.erp-standard-compact-page { font-size: 64%; }
    body.erp-standard-page .erp-standard-form { gap: 10px; }
    body.erp-standard-page .erp-standard-form .erp-standard-form-card .form-section { padding: 11px 13px; }
    body.erp-standard-page .erp-standard-header-grid { gap: 11px 13px; }
    body.erp-standard-page .erp-standard-header-grid .field { gap: 5px; }
    body.erp-standard-page .erp-standard-header-grid .field input,
    body.erp-standard-page .erp-standard-header-grid .field select {
        min-height: 34px;
        padding: 7px 10px;
        border-radius: 6px;
    }
    body.erp-standard-page .erp-standard-lines-card { height: 336px; min-height: 336px; }
    body.erp-standard-page table.erp-standard-table { min-width: 1080px; }
    body.erp-standard-page table.erp-standard-table .erp-col-remove {
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        padding-right: 5px !important;
        padding-left: 5px !important;
    }
    body.erp-standard-page table.erp-standard-table .remove-line-button {
        width: 28px !important;
        min-width: 28px !important;
        height: 28px !important;
        padding: 6px;
        border-radius: 6px;
    }
    body.erp-standard-page table.erp-standard-table .remove-line-button img { width: 15px; height: 15px; }
}

@media (max-width: 520px) {
    body.erp-standard-page .erp-standard-form { padding-bottom: 76px; }
}
