/* Customers module — builds on enterprise-data-table.css */

.customers-page {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem 0.45rem;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.customers-page__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    flex-shrink: 0;
}

.customers-page__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ent-navy, #03142e);
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.customers-page__subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ent-muted, #64748b);
    font-weight: 600;
}

.customers-page__alert {
    margin: 0;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    background: #fff8e8;
    border: 1px solid #f0d48a;
    color: #8a5a00;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.customers-page__error {
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
}

.customers-page__error button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

/* Reusable account balance + chart (Customers, Invoice dialog, etc.) */
.cust-balance {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    gap: 0.65rem;
    align-items: stretch;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--ent-border, #d0d8e4);
    border-radius: 8px;
    background: #fff;
    flex-shrink: 0;
    min-width: 0;
    box-sizing: border-box;
}

.cust-balance--fill {
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    padding: 0.5rem 0.75rem;
}

.cust-balance__stats {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.cust-balance__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid #c9d4e4;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
}

.cust-balance__table th,
.cust-balance__table td {
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
    line-height: 1.25;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}

.cust-balance__table tr:last-child th,
.cust-balance__table tr:last-child td {
    border-bottom: none;
}

.cust-balance__table th {
    width: 48%;
    text-align: left;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
}

.cust-balance__table td {
    text-align: right;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    background: #fff;
}

.cust-balance__table td.num.is-pos { color: #15803d; }
.cust-balance__table td.num.is-neg { color: #b91c1c; }

.cust-balance__row--emphasis th,
.cust-balance__row--emphasis td {
    background: #f1f5f9;
}

.cust-balance__row--emphasis td.is-pos {
    background: #ecfdf5;
}

.cust-balance__row--emphasis td.is-neg {
    background: #fef2f2;
}

.cust-balance__chart {
    --cab-h: 168px;
    height: var(--cab-h);
    min-height: var(--cab-h);
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
}

.cust-balance--fill .cust-balance__chart {
    flex: 1 1 auto;
}

/* HTML column chart — invoice balances only (navy), Angular account-balance look */
.cab-chart {
    --cab-navy: #000080;
    display: grid;
    grid-template-columns: 2.85rem minmax(0, 1fr);
    gap: 0.15rem 0.4rem;
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.cab-chart__yaxis {
    position: relative;
    height: calc(100% - 1.35rem);
    margin-bottom: 1.35rem;
}

.cab-chart__ytick {
    position: absolute;
    right: 0;
    transform: translateY(50%);
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    line-height: 1;
    white-space: nowrap;
}

.cab-chart__area {
    position: relative;
    height: 100%;
    min-width: 0;
    width: 100%;
    border-left: 1px solid #d0d8e4;
    border-bottom: 1px solid #d0d8e4;
    box-sizing: border-box;
}

.cab-chart__grid {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 1.35rem;
    pointer-events: none;
}

.cab-chart__gridline {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid #e2e8f0;
}

.cab-chart__bars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    gap: 0.5rem;
    padding: 0.45rem 0.4rem 0;
    box-sizing: border-box;
    width: 100%;
    overflow: visible;
}

.cab-chart__col {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.cab-chart__plot {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-top: 0.85rem; /* room for pill overhang */
    box-sizing: border-box;
}

.cab-chart__bar {
    position: relative;
    width: 78%;
    max-width: none;
    /* Inline height % is set in CustomerAccountBalance — keep min tiny so
       $3 / $170 / $590 scale correctly (old 1.85rem min flattened them). */
    min-height: 2px;
    background: var(--cab-navy);
    border-radius: 3px 3px 0 0;
}

/* Value pill sits on the top edge of the bar */
.cab-chart__tag {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, -42%);
    z-index: 2;
    padding: 0.28rem 0.45rem;
    border-radius: 3px;
    background: var(--cab-navy);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.15;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 64, 0.28);
}

.cab-chart__lbl {
    flex: 0 0 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    font-weight: 700;
    color: #334155;
    line-height: 1;
    white-space: nowrap;
}

.cust-balance__empty,
.cust-balance__loading {
    grid-column: 1 / -1;
    color: var(--ent-muted, #64748b);
    font-size: 0.875rem;
    padding: 0.35rem 0;
}

.cust-balance__empty--error {
    color: #b91c1c;
}

.cust-balance__empty--chart {
    grid-column: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 80px;
}

@media (max-width: 900px) {
    .cust-balance,
    .cust-balance--fill {
        grid-template-columns: 1fr;
    }

    .cust-balance--fill .cust-balance__chart {
        min-height: 140px;
    }
}

/* Legacy class aliases → enterprise dialog helpers */
.cust-dlg-body,
.ent-dialog__body.cust-dlg-body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.cust-dlg-body__grid {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cust-dlg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
}

.cust-dlg-msg { /* alias */ }
.cust-dlg-msg,
.ent-dialog__msg {
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.cust-dlg-msg--error,
.ent-dialog__msg--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.cust-dlg-msg--ok,
.ent-dialog__msg--ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.cust-dlg-msg--info,
.ent-dialog__msg--info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.cust-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.65rem;
    flex-shrink: 0;
}

.cust-form-grid .full { grid-column: 1 / -1; }

.cust-company-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.cust-company-row__field {
    flex: 1 1 auto;
    min-width: 0;
}

.cust-company-row__btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 2.25rem;
}

.cust-form-grid label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 0.2rem;
}

.cust-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
}

.cust-check-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    margin: 0;
}

.cust-editor-body {
    padding: 0.15rem 0.1rem 0.35rem;
}

.cust-flag-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem 0.45rem;
    padding: 0.55rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.cust-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0 !important;
    padding: 0.35rem 0.4rem;
    min-height: 2rem;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    color: #334155 !important;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.cust-flag:hover {
    background: #e8eef5;
}

.cust-flag:has(input:checked) {
    background: #e0ebf5;
    color: #0f4c75 !important;
}

.cust-flag input {
    width: 1rem;
    height: 1rem;
    margin: 0 0.15rem 0 0;
    flex-shrink: 0;
    accent-color: #0f4c75;
    cursor: pointer;
}

.cust-flag span {
    line-height: 1.2;
    margin-left: 0.1rem;
}

.customer-editor-dialog .cust-editor-notes textarea,
.customer-editor-dialog .cust-editor-notes.e-input-group,
.customer-editor-dialog .cust-editor-notes .e-input {
    min-height: 7.5rem;
}

@media (max-width: 720px) {
    .cust-flag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .cust-form-grid { grid-template-columns: 1fr; }
    .cust-flag-grid { grid-template-columns: 1fr; }
}

/* Dialog list tables share enterprise table */
.ent-dialog .ent-table-host {
    flex: 1 1 0;
    min-height: 0;
}

.ent-dialog .cust-dlg-body__grid .ent-table-host {
    height: 100%;
}

/* Customers main grid host fills remaining height; header chrome from iffys-sf-grid.css */
.customers-page .iffys-sf-grid-host {
    flex: 1 1 0;
    min-height: 0;
}

/* Ensure customers page does not restyle Syncfusion headers (legacy ent-table rules stay on .ent-table only) */
.customers-page .iffys-sf-grid-host .e-grid .e-headercell,
.customers-page .iffys-sf-grid-host .e-grid .e-headertext {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.customers-page .ent-table-host {
    border-radius: 6px;
    border-color: #9eb0c4;
}

.customers-page .ent-table {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.customers-page .ent-table thead th {
    background: #0f4c75;
    color: #fff;
    border-bottom: 1px solid #0a3552;
    font-size: var(--ent-font, 0.90rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    padding: 0.45rem 0.55rem;
}

.customers-page .ent-table tbody td {
    font-size: var(--ent-font, 0.90rem);
    font-weight: 400;
    color: #1a1a1a;
    padding: 0.32rem 0.55rem;
    line-height: 1.3;
    border-bottom: 1px solid #e2e8f0;
}

.customers-page .ent-table tbody tr:nth-child(even) {
    background: #f5f7fa;
}

.customers-page .ent-table tbody tr:hover {
    background: #e8f1f8;
}

.customers-page .ent-table tbody tr.is-selected {
    background: #d9eaf7;
}

.customers-page .cust-name-cell {
    font-weight: 600;
    color: #0f172a;
}

.customers-page .cust-locked-cell {
    width: 3.6rem;
    min-width: 3.6rem;
}

.customers-page .cust-locked-icon {
    color: #b42318;
    font-size: 1.25rem;
    line-height: 1;
}

.customers-page .cust-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.customers-page .cust-sortable:hover {
    color: #dbeafe;
}

/* Compact columns stay single-line; large text columns wrap */
.customers-page .cust-grid tbody tr {
    height: auto;
    min-height: 34px;
}

.customers-page .cust-grid tbody td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 14rem;
    vertical-align: top;
}

.customers-page .cust-grid tbody td.wrap,
.customers-page .cust-grid tbody td.cust-name-cell {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-overflow: unset;
    overflow: visible;
    max-width: 18rem;
}

.customers-page .cust-grid tbody td.actions,
.customers-page .cust-grid tbody td.cust-locked-cell {
    max-width: none;
    overflow: visible;
}

@media (min-width: 1920px) {
    .customers-page .ent-table thead th,
    .customers-page .ent-table tbody td {
        font-size: var(--ent-font-lg, 1rem);
    }
}

.tablet-layout .customers-page .ent-table thead th,
.tablet-layout .customers-page .ent-table tbody td {
    font-size: var(--ent-font-tablet, 0.75rem);
}

@media (max-width: 1024px) {
    .customers-page .ent-table thead th,
    .customers-page .ent-table tbody td {
        font-size: var(--ent-font-tablet, 0.75rem);
    }
}

.mobile-layout .customers-page .ent-table thead th,
.mobile-layout .customers-page .ent-table tbody td {
    font-size: var(--ent-font-mobile, 0.65rem);
}

@media (max-width: 768px) {
    .customers-page .ent-table thead th,
    .customers-page .ent-table tbody td {
        font-size: var(--ent-font-mobile, 0.65rem);
    }
}
