/* GYS-style data table for VOB (Bootstrap 4/AdminLTE host).
   Tokens are copied from itk.gys.srms.fe_be (DESIGN.md / app.css).
   - .vob-pager       : emitted by server-table.js, safe to load globally.
   - .vob-table-card  : opt-in wrapper; nothing outside it is restyled. */

:root {
    --vob-primary: #01765a;
    --vob-primary-0: #f0f7f5;
    --vob-primary-10: #d4e8e3;
    --vob-primary-60: #00624b;
    --vob-grey-0: #ffffff;
    --vob-grey-5: #fcfcfd;
    --vob-grey-10: #f9fafb;
    --vob-grey-20: #f2f4f7;
    --vob-grey-30: #eaecf0;
    --vob-grey-40: #d0d5dd;
    --vob-grey-50: #98a2b3;
    --vob-grey-60: #667085;
    --vob-grey-70: #475467;
    --vob-grey-80: #344054;
    --vob-grey-90: #1d2939;
    --vob-radius-card: 12px;
    --vob-radius-control: 8px;
}

/* ---------- Inputs: search box + page-size select ---------- */
.vob-table-card .vob-input,
.vob-table-card .vob-select {
    height: 40px;
    border: 1px solid var(--vob-grey-40);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    padding: 0 12px;
    font-size: 0.875rem;
    color: var(--vob-grey-90);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.vob-table-card .vob-select { width: auto; padding-right: 28px; }
.vob-table-card .vob-input { width: 320px; max-width: 100%; }
.vob-table-card .vob-input::placeholder { color: var(--vob-grey-50); }
.vob-table-card .vob-input:focus,
.vob-table-card .vob-select:focus {
    outline: none;
    border-color: var(--vob-primary);
    box-shadow: 0 0 0 3px var(--vob-primary-10);
}
.vob-table-card .vob-search { position: relative; }
.vob-table-card .vob-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--vob-grey-50);
    pointer-events: none;
    font-size: 0.8rem;
}
.vob-table-card .vob-search .vob-input { padding-left: 34px; }

/* ---------- Table ---------- */
.vob-table-card .vob-table-wrap {
    position: relative;
    overflow-x: auto;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-card);
    background: var(--vob-grey-0);
}
.vob-table-card .vob-table-wrap.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    cursor: progress;
}

.vob-table-card table.vob-table {
    width: 100% !important;
    margin: 0 !important;
    border: 0;
    border-collapse: collapse !important;
    font-size: 0.875rem;
    color: var(--vob-grey-90);
}
.vob-table-card table.vob-table thead th {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--vob-grey-30);
    background: var(--vob-grey-5);
    color: var(--vob-grey-80);
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}
.vob-table-card table.vob-table tbody td {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--vob-grey-30);
    vertical-align: middle;
    color: var(--vob-grey-90);
}
.vob-table-card table.vob-table tbody tr:last-child td { border-bottom: 0; }
.vob-table-card table.vob-table tbody tr:nth-child(odd) { background: #fcfcfd; }
.vob-table-card table.vob-table tbody tr:nth-child(even) { background: var(--vob-grey-0); }
.vob-table-card table.vob-table tbody tr { transition: background-color 0.12s; }
.vob-table-card table.vob-table tbody tr:hover { background: var(--vob-grey-10); }
.vob-table-card table.vob-table td p { margin: 0; }
.vob-table-card table.vob-table .text-center { text-align: center; }
.vob-table-card table.vob-table .text-right { text-align: right; font-variant-numeric: tabular-nums; }

.vob-table-card table.vob-table thead th.text-center { text-align: center; }

/* Keep the Action column reachable when the table scrolls sideways. */
/* Header: first row only - a two-row header (Billing) has a second row whose last cell is not the Action column. */
.vob-table-card table.vob-table thead tr:first-child th:last-child,
.vob-table-card table.vob-table tbody td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: inherit;
    box-shadow: -1px 0 0 var(--vob-grey-30);
}
/* Above the cells scrolling underneath it, including a second header row (Billing's bank columns). */
.vob-table-card table.vob-table thead tr:first-child th:last-child { background: var(--vob-grey-5); z-index: 2; }

/* DataTables ships its own empty-row + sort chrome; keep it quiet and on-brand. */
.vob-table-card table.vob-table td.dataTables_empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--vob-grey-60);
}
.vob-table-card table.vob-table thead th::before,
.vob-table-card table.vob-table thead th::after { display: none !important; }

/* Sortable headers */
.vob-table-card table.vob-table thead th[data-sort] {
    cursor: pointer;
    user-select: none;
}
.vob-table-card table.vob-table thead th[data-sort]:hover { background: var(--vob-grey-10); color: var(--vob-grey-90); }
.vob-sort-icon {
    display: inline-block;
    margin-left: 6px;
    width: 10px;
    color: var(--vob-grey-40);
    font-size: 0.7rem;
}
.vob-table-card th[data-sort].is-sorted { color: var(--vob-primary); }
.vob-table-card th[data-sort].is-sorted .vob-sort-icon { color: var(--vob-primary); }

/* Row action buttons */
.vob-actions { display: flex; flex-wrap: nowrap; gap: 4px; }
.vob-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 4px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    color: var(--vob-grey-70);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.vob-icon-btn:last-child { margin-right: 0; }
.vob-icon-btn:hover { background: var(--vob-primary-0); border-color: var(--vob-primary-10); color: var(--vob-primary); }
.vob-icon-btn.is-danger:hover { background: #f5dbdb; border-color: #f5dbdb; color: #c62828; }
.vob-icon-btn:focus-visible { outline: 2px solid var(--vob-primary); outline-offset: 2px; }

/* Row action "more" menu (fixed so the scrolling table wrapper can't clip it) */
.vob-action-menu {
    position: fixed;
    z-index: 1060;
    min-width: 220px;
    padding: 4px 0;
    background: var(--vob-grey-0);
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.vob-action-menu[hidden] { display: none; }
.vob-action-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    border: 0;
    background: none;
    color: var(--vob-grey-70);
    text-align: left;
    cursor: pointer;
}
.vob-action-menu button i { width: 16px; text-align: center; }
.vob-action-menu button:hover { background: var(--vob-primary-0); color: var(--vob-primary); }
.vob-action-menu button.is-danger:hover { background: #f5dbdb; color: #c62828; }

/* Score / status pills */
.vob-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--vob-grey-20);
    color: var(--vob-grey-80);
    font-size: 0.75rem;
    font-weight: 500;
}
.vob-pill.is-good { background: #dce9dc; color: #1e5321; }
.vob-pill.is-warn { background: #fff4d5; color: #7f6003; }
.vob-pill.is-bad  { background: #f5dbdb; color: #841a1a; }
.vob-pill.is-info { background: #dbe8f7; color: #174e86; }

/* ---------- Pager (emitted by server-table.js) ---------- */
.vob-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--vob-grey-30);
    font-size: 0.875rem;
}
.vob-pager .vob-pager-info { margin: 0; color: var(--vob-grey-60); }
.vob-pager nav { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.vob-pager .vob-pages { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.vob-pager .vob-page,
.vob-pager .vob-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    height: 40px;
    min-width: 40px;
    padding: 0 8px;
    border-radius: var(--vob-radius-control);
    font-size: 0.875rem;
    font-weight: 500;
}
.vob-pager a.vob-page {
    border: 1px solid var(--vob-grey-30);
    background: var(--vob-grey-0);
    color: var(--vob-grey-80);
    text-decoration: none;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.vob-pager a.vob-page:hover { border-color: var(--vob-grey-40); background: var(--vob-grey-10); color: var(--vob-grey-90); }
.vob-pager a.vob-page:focus-visible { outline: 2px solid var(--vob-primary); outline-offset: 2px; }
.vob-pager .vob-page.is-current { background: var(--vob-primary); border: 1px solid var(--vob-primary); color: #fff; cursor: default; }
.vob-pager .vob-page.is-disabled { border: 1px solid var(--vob-grey-30); background: var(--vob-grey-10); color: var(--vob-grey-40); cursor: not-allowed; }
.vob-pager .vob-page-ellipsis { color: var(--vob-grey-50); }
.vob-pager .vob-jump { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--vob-grey-60); }
.vob-pager .vob-jump label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
.vob-pager .vob-jump input {
    width: 80px;
    height: 40px;
    border: 1px solid var(--vob-grey-40);
    border-radius: var(--vob-radius-control);
    text-align: center;
    color: var(--vob-grey-90);
}
.vob-pager .vob-jump input:focus { outline: none; border-color: var(--vob-primary); box-shadow: 0 0 0 3px var(--vob-primary-10); }
.vob-pager .vob-jump button {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    color: var(--vob-grey-80);
    font-weight: 500;
    cursor: pointer;
}
.vob-pager .vob-jump button:hover { background: var(--vob-grey-10); border-color: var(--vob-grey-40); }

@media (max-width: 576px) {
    .vob-table-card .vob-input { width: 100%; }
    .vob-pager { justify-content: center; }
}

/* ---------- Filter bar + panel (GYS style) ---------- */
.vob-table-card .vob-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.vob-table-card .vob-filterbar-left { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.vob-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    color: var(--vob-grey-80);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.vob-btn:hover { background: var(--vob-grey-10); border-color: var(--vob-grey-40); color: var(--vob-grey-90); text-decoration: none; }
.vob-btn:focus-visible { outline: 2px solid var(--vob-primary); outline-offset: 2px; }
.vob-btn i { color: var(--vob-grey-60); }
.vob-btn .vob-chevron { font-size: 0.7rem; transition: transform 0.2s; }
.vob-btn[aria-expanded="true"] .vob-chevron { transform: rotate(180deg); }
.vob-btn.is-primary { background: var(--vob-primary); border-color: var(--vob-primary); color: #fff; font-weight: 600; }
.vob-btn.is-primary i { color: #fff; }
.vob-btn.is-primary:hover { background: var(--vob-primary-60); border-color: var(--vob-primary-60); color: #fff; }

.vob-filter-panel {
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-5);
}
.vob-filter-panel[hidden] { display: none; }
.vob-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.vob-filter-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }

.vob-filter-field { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vob-filter-panel label.vob-filter-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--vob-grey-60);
}
.vob-filter-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    color: var(--vob-grey-50);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}
.vob-filter-trigger:focus, .vob-filter-trigger.is-open { outline: none; border-color: var(--vob-primary); box-shadow: 0 0 0 3px var(--vob-primary-10); }
.vob-filter-trigger i { color: var(--vob-grey-60); font-size: 0.7rem; transition: transform 0.15s; }
.vob-filter-trigger.is-open i { transform: rotate(180deg); }
.vob-filter-field[data-locked] .vob-filter-trigger { background: var(--vob-grey-10); cursor: not-allowed; }

.vob-filter-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    margin-top: 4px;
    padding: 8px;
    border: 1px solid var(--vob-grey-30);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}
.vob-filter-menu[hidden] { display: none; }
.vob-filter-search {
    width: 100%;
    height: 36px;
    margin-bottom: 8px;
    padding: 0 8px;
    border: 1px solid var(--vob-grey-30);
    border-radius: 6px;
    font-size: 0.875rem;
}
.vob-filter-search:focus { outline: none; border-color: var(--vob-primary); box-shadow: 0 0 0 2px var(--vob-primary-10); }
.vob-filter-options { max-height: 168px; overflow-y: auto; }
.vob-filter-panel label.vob-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--vob-grey-90);
    cursor: pointer;
}
.vob-filter-panel label.vob-filter-option[hidden] { display: none; }
.vob-filter-panel label.vob-filter-option:hover { background: var(--vob-grey-10); }
.vob-filter-panel label.vob-filter-option input { margin-top: 3px; accent-color: var(--vob-primary); }
.vob-filter-empty { margin: 0; padding: 6px 8px; font-size: 0.75rem; color: var(--vob-grey-50); }
.vob-filter-empty[hidden] { display: none; }

.vob-filter-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.vob-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 4px 2px 10px;
    border: 1px solid #aad1ff;
    border-radius: 999px;
    background: #d4e8ff;
    color: var(--vob-grey-80);
    font-size: 0.75rem;
}
.vob-chip:not(:has(.vob-chip-remove)) { padding-right: 10px; }
.vob-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--vob-grey-60);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.vob-chip-remove:hover { background: rgba(16, 24, 40, 0.08); color: var(--vob-grey-90); }

/* Footer left zone: page size + info */
.vob-pager .vob-pager-left { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.vob-pager .vob-page-size { display: flex; align-items: center; gap: 8px; }
.vob-pager .vob-page-size label { margin: 0; font-size: 0.875rem; color: var(--vob-grey-60); white-space: nowrap; font-weight: 400; }
.vob-page-size .vob-select {
    height: 40px;
    width: auto;
    padding: 0 28px 0 12px;
    border: 1px solid var(--vob-grey-40);
    border-radius: var(--vob-radius-control);
    background-color: var(--vob-grey-0);
    font-size: 0.875rem;
    color: var(--vob-grey-90);
}
.vob-page-size .vob-select:focus { outline: none; border-color: var(--vob-primary); box-shadow: 0 0 0 3px var(--vob-primary-10); }
#vendorMasterPager > .vob-page-size { margin-top: 16px; }

@media (max-width: 992px) { .vob-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 576px) {
    .vob-filter-grid { grid-template-columns: 1fr; }
    .vob-table-card .vob-filterbar-left, .vob-table-card .vob-filterbar-left > * { width: 100%; }
    .vob-filter-actions .vob-btn { flex: 1; }
}

/* Approve / reject confirmation popups: the popup never outgrows the screen, only the
   vendor table inside it scrolls (header stays pinned). */
.vob-review-dialog .modal-content { max-height: calc(100vh - 2rem); }
.vob-review-dialog .modal-body { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.vob-review-scroll { overflow: auto; min-height: 0; max-height: 55vh; }
.vob-review-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--vob-grey-0, #fff); box-shadow: inset 0 -1px 0 var(--vob-grey-30, #ddd); }
.vob-review-scroll select.is-invalid { border-color: #c62828; }

/* ---------- Invoice form (Billing Portal: add / view / edit) ---------- */
.vob-bill-dialog .modal-header { align-items: flex-start; }
.vob-bill-sub { margin-top: 2px; font-size: 0.8125rem; color: var(--vob-grey-60); }
.vob-bill-form { display: flex; flex-direction: column; gap: 20px; }
.vob-bill-section h5 {
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--vob-grey-30);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--vob-grey-90);
}
.vob-bill-section h5 .vob-optional { margin-left: 6px; font-weight: 400; font-size: 0.75rem; color: var(--vob-grey-60); }
.vob-bill-section[hidden] { display: none; }
.vob-bill-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
@media (max-width: 576px) { .vob-bill-grid { grid-template-columns: 1fr; } }

.vob-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vob-field > label { margin: 0; font-size: 0.8125rem; font-weight: 500; color: var(--vob-grey-80); }
.vob-field .req { color: #c62828; }
.vob-field input[type="text"], .vob-field input[type="date"], .vob-field select {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--vob-grey-40);
    border-radius: var(--vob-radius-control);
    background: var(--vob-grey-0);
    font-size: 0.875rem;
    color: var(--vob-grey-90);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.vob-field input:focus, .vob-field select:focus { outline: none; border-color: var(--vob-primary); box-shadow: 0 0 0 3px var(--vob-primary-10); }
.vob-field input:disabled, .vob-field select:disabled, .vob-field input[readonly] { background: var(--vob-grey-5); color: var(--vob-grey-70); cursor: not-allowed; }
.vob-field.has-error input, .vob-field.has-error select, .vob-field.has-error .vob-amount { border-color: #c62828; }
.vob-hint { font-size: 0.75rem; line-height: 1.4; color: var(--vob-grey-60); }
.vob-error { display: none; font-size: 0.75rem; color: #c62828; }
.vob-field.has-error > .vob-error { display: block; }

.vob-amount { display: flex; align-items: stretch; border: 1px solid var(--vob-grey-40); border-radius: var(--vob-radius-control); background: var(--vob-grey-0); overflow: hidden; }
.vob-amount:focus-within { border-color: var(--vob-primary); box-shadow: 0 0 0 3px var(--vob-primary-10); }
.vob-amount .vob-amount-ccy { display: inline-flex; align-items: center; padding: 0 12px; background: var(--vob-grey-10); border-right: 1px solid var(--vob-grey-30); font-size: 0.8125rem; font-weight: 600; color: var(--vob-grey-70); }
.vob-field .vob-amount input { border: 0; border-radius: 0; box-shadow: none; text-align: right; font-variant-numeric: tabular-nums; }

.vob-bill-alert { margin-bottom: 14px; padding: 10px 14px; border: 1px solid #f0c4c4; border-radius: var(--vob-radius-control); background: #fbeaea; font-size: 0.8125rem; color: #841a1a; }
.vob-bill-alert[hidden] { display: none; }

.vob-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.vob-file { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--vob-grey-30); border-radius: var(--vob-radius-control); background: var(--vob-grey-5); font-size: 0.875rem; }
.vob-file i { color: #c62828; }
.vob-file a, .vob-file .vob-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vob-file .vob-file-size { color: var(--vob-grey-60); font-size: 0.75rem; }
.vob-file-remove { border: 0; background: none; padding: 0 4px; font-size: 1.25rem; line-height: 1; color: var(--vob-grey-60); cursor: pointer; }
.vob-file-remove:hover { color: #c62828; }
.vob-files-empty { padding: 10px 12px; border: 1px dashed var(--vob-grey-40); border-radius: var(--vob-radius-control); font-size: 0.8125rem; color: var(--vob-grey-60); }
.vob-files-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }

/* The invoice form is long: on a short screen the header and footer stay put and the form itself scrolls. */
.vob-bill-dialog .modal-content { display: flex; flex-direction: column; }
.vob-bill-dialog .modal-body { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* A table without an Action column: its last column is ordinary data, so it must not be pinned. */
.vob-table-card table.vob-table.no-action-column thead tr:first-child th:last-child,
.vob-table-card table.vob-table.no-action-column tbody td:last-child {
    position: static;
    z-index: auto;
    box-shadow: none;
}
