/* ============================================================
   DataTable — shared table styles (ported from gridops-ft-kyaw)
   ============================================================ */

/* Extra tokens used by datatable */
:root {
    --color-border-light: #e5e7eb;
    --color-bg-tertiary: #f3f4f6;
    --color-primary-dark: #005a9e;
    --border-radius: 6px;
    --border-radius-lg: 8px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --font-size-sm: 0.8rem;
}

.datatable-wrapper {
    background: white;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* visible so dropdowns (column picker, filter menus) anchored inside
       the toolbar can extend below the wrapper without being clipped */
    overflow: visible;
}
.datatable-wrapper > .table-scroll-area { border-radius: 0 0 8px 8px; }
.datatable-wrapper > .dt-toolbar { border-radius: 8px 8px 0 0; }

.table-scroll-area {
    overflow-x: auto;
}

.datatable-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    min-width: 400px;
}

/* Header row */
.datatable-table thead tr:first-child th {
    background: #f7fafc;
    position: sticky;
    top: 0;
    z-index: 10;
    color: #4a5568;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 12px;
    border-bottom: 2px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    text-align: left;
}

.datatable-table thead tr:first-child th:hover {
    background: #edf2f7;
}

.datatable-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.datatable-table tbody tr {
    transition: background 0.1s;
}

.datatable-table tbody tr:hover {
    background: #ebf8ff;
}

/* Allow pointer when row click is used */
.datatable-table tbody tr.dt-row {
    cursor: pointer;
}

/* Row-selection checkbox column */
.dt-select-col {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    padding-left: 12px !important;
    padding-right: 0 !important;
    text-align: center !important;
    cursor: default !important;
}
.dt-select-col input[type="checkbox"] {
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* Bulk-edit bar — shown once one or more rows are selected. Fixed to the
   viewport bottom (KYAW/NJAW pattern) rather than inline in the table, so
   it stays reachable regardless of scroll position and doesn't push rows
   around when it appears/disappears. */
.dt-bulk-bar {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1000;
    background: #111827;
    color: #f9fafb;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    /* min() so the chip rows actually wrap on narrow screens instead of
       overflowing — a bare max-width doesn't constrain a max-content box
       until after intrinsic sizing has already assumed no wrapping. */
    width: min(max-content, calc(100vw - 2rem));
    box-sizing: border-box;
}
.dt-bulk-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}
.dt-bulk-head strong {
    font-weight: 700;
}
.dt-bulk-link {
    background: transparent;
    border: 1px solid #4b5563;
    color: #e5e7eb;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
}
.dt-bulk-link:hover {
    background: #1f2937;
}
.dt-bulk-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}
.dt-bulk-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.dt-bulk-group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    flex: 0 0 auto;
    min-width: 8.5em;
}
/* Below this width the fixed-width label crowds the chip row into a tall,
   awkward wrap — drop back to label-above-chips like the rest of the page. */
@media (max-width: 600px) {
    .dt-bulk-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }
    .dt-bulk-group-label {
        min-width: 0;
    }
}
.dt-bulk-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.dt-bulk-chip {
    background: transparent;
    border: 1px solid #4b5563;
    color: #d1d5db;
    border-radius: 9999px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}
.dt-bulk-chip:hover {
    border-color: #9ca3af;
}
.dt-bulk-chip.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.dt-bulk-chip.dt-bulk-chip-clear {
    color: #9ca3af;
    border-style: dashed;
}
.dt-bulk-set-btn {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    height: fit-content;
}
.dt-bulk-set-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.dt-bulk-feedback {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Column Resize Handle */
.datatable-table th {
    position: relative;
}

.col-resize {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 11;
}

.col-resize:hover,
.col-resize.active {
    background: var(--color-primary);
    opacity: 0.4;
}

/* Filter Row */
.filter-row th {
    background: #edf2f7;
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 37px;
    z-index: 9;
    cursor: default;
    height: 36px;
}

.filter-row th:hover {
    background: #edf2f7;
}

/* Per-Column Filter Inputs & Selects */
.col-filter-input,
.col-filter-select {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #2d3748;
    background: white;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.col-filter-input:focus,
.col-filter-select:focus {
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.15);
}

.col-filter-input::placeholder {
    color: #cbd5e0;
}

.col-filter-select {
    cursor: pointer;
}

/* DataTable Toolbar */
.dt-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-light);
    background: white;
    flex-wrap: wrap;
}

/* ── Mobile card view (DataTable options.cardView) ──
   The table markup always renders; below 768px the wrapper swaps it for
   stacked cards so list rows are readable without horizontal scrolling. */
.dt-card-list { display: none; }
@media (max-width: 767px) {
    .datatable-wrapper.dt-has-cards .table-scroll-area { display: none; }
    .datatable-wrapper.dt-has-cards .dt-card-list { display: block; }
}
.dt-card {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    background: var(--color-bg);
}
.dt-card:active { background: var(--color-bg-secondary); }
.dt-card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.dt-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 0;
    overflow-wrap: anywhere;
}
.dt-card-badges {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.dt-card-line {
    display: flex;
    gap: 0.5rem;
    padding: 1px 0;
    font-size: 0.8125rem;
    align-items: baseline;
}
.dt-card-line-label {
    color: var(--color-text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 92px;
    flex-shrink: 0;
}
.dt-card-line-value {
    min-width: 0;
    overflow-wrap: anywhere;
}
/* Money/count cells format as right-aligned blocks for table columns —
   inside a card line they should flow inline-left like everything else. */
.dt-card-line-value > span[style*="text-align:right"],
.dt-card-line-value > span[style*="text-align:center"] {
    display: inline !important;
    text-align: left !important;
}

/* Filter Pills */
.dt-filter-pill-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
/* Dedicated full-width pill row under the toolbar (data-table.js renders
   pills here; JS toggles display when filters come and go). */
.dt-pill-row {
    flex: none;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 500;
    background: #e8f4fd;
    color: #1a56db;
    border: 1px solid #b3d9f2;
    border-radius: 9999px;
    white-space: nowrap;
}

.filter-pill-label {
    color: #0078d4;
}

.filter-pill-x {
    background: none;
    border: none;
    cursor: pointer;
    color: #93c5fd;
    padding: 0;
    margin-left: 2px;
    line-height: 1;
    font-size: 14px;
}

.filter-pill-x:hover {
    color: #1a56db;
}

.filter-clear-all {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 2px 10px;
    cursor: pointer;
}

.filter-clear-all:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Column Picker (Gear Icon) */
.col-picker-wrap {
    position: relative;
}

.col-picker-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    color: #6b7280;
}

.col-picker-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.col-picker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 180px;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 200;
    padding: 6px 0;
}

.col-picker-dropdown.show {
    display: block;
}

.module-group-label {
    padding: 12px 14px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.module-group-label:first-child {
    padding-top: 4px;
}

.col-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #111827;
    user-select: none;
}

.col-picker-item:hover {
    background: #f3f4f6;
}

.col-picker-item.disabled {
    opacity: 0.45;
    cursor: default;
}

.col-picker-item input[type="checkbox"] {
    accent-color: var(--color-primary);
}

.col-picker-handle {
    cursor: grab;
    color: #6b7280;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
}

.col-picker-item.dragging {
    opacity: 0.4;
}

.col-picker-item.drag-over {
    border-top: 2px solid var(--color-primary);
}

/* Export CSV Button */
.export-csv-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.export-csv-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Views button — match toolbar button height */
.view-selector-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.8rem;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.2;
}
.view-selector-btn:hover {
    background: #f3f4f6;
    color: #111827;
}
.view-selector-wrap {
    position: relative;
}

/* Column picker button — match toolbar button height */
.col-picker-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.8rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
}
.col-picker-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Pagination */
.datatable-bottom {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #718096;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.datatable-bottom .datatable-info { order: 1; }
.datatable-bottom .datatable-pagination { order: 2; }
.datatable-bottom .datatable-dropdown { order: 3; margin-left: auto; }

.datatable-pagination .datatable-pagination-list {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.datatable-pagination .datatable-pagination-list li button {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.8rem;
}

.datatable-pagination .datatable-pagination-list li button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.datatable-pagination .datatable-pagination-list li.datatable-active button {
    background: #0078d4;
    color: white;
    border-color: #0078d4;
}

.datatable-bottom select {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
}

/* ============================================================
   End DataTable styles
   ============================================================ */
/* ============================================================
   End DataTable styles (ported verbatim from gridops-ft-aps
   styles.css — the claims.html table). Do not restyle; override
   in main.css if an inbox-specific tweak is ever needed.
   ============================================================ */

/* ── Engine extras appended from later in the donor stylesheet ── */
/* ── Mobile card view (DataTable options.cardView) ──
   The table markup always renders; below 768px the wrapper swaps it for
   stacked cards so list rows are readable without horizontal scrolling. */
.dt-card-list { display: none; }
@media (max-width: 767px) {
    .datatable-wrapper.dt-has-cards .table-scroll-area { display: none; }
    .datatable-wrapper.dt-has-cards .dt-card-list { display: block; }
}
.dt-card {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    background: var(--color-bg);
}
.dt-card:active { background: var(--color-bg-secondary); }
.dt-card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.dt-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 0;
    overflow-wrap: anywhere;
}
.dt-card-badges {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.dt-card-line {
    display: flex;
    gap: 0.5rem;
    padding: 1px 0;
    font-size: 0.8125rem;
    align-items: baseline;
}
.dt-card-line-label {
    color: var(--color-text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 92px;
    flex-shrink: 0;
}
.dt-card-line-value {
    min-width: 0;
    overflow-wrap: anywhere;
}
/* Money/count cells format as right-aligned blocks for table columns —
   inside a card line they should flow inline-left like everything else. */
.dt-card-line-value > span[style*="text-align:right"],
.dt-card-line-value > span[style*="text-align:center"] {
    display: inline !important;
    text-align: left !important;
}

/* Filter Pills */
.dt-filter-pill-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
/* Dedicated full-width pill row under the toolbar (data-table.js renders
   pills here; JS toggles display when filters come and go). */
.dt-pill-row {
    flex: none;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 500;
    background: #e8f4fd;
    color: #1a56db;
    border: 1px solid #b3d9f2;
    border-radius: 9999px;
    white-space: nowrap;
}

.filter-pill-label {
    color: #0078d4;
}

.filter-pill-x {
    background: none;
    border: none;
    cursor: pointer;
    color: #93c5fd;
    padding: 0;
    margin-left: 2px;
    line-height: 1;
    font-size: 14px;
}

.filter-pill-x:hover {
    color: #1a56db;
}

.filter-clear-all {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 2px 10px;
}
.form-edit-btn:hover { background: #f3f4f6; border-color: var(--color-primary); color: var(--color-primary); }

/* ── Multi-Select Filter ── */
.multi-filter-wrap { position: relative; }
.multi-filter-btn {
    width: 100%;
    background: var(--color-bg, #fff);
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.1s;
    text-align: left;
    font-family: inherit;
}
.multi-filter-btn:hover { border-color: #4299e1; }
.multi-filter-btn.active {
    border-color: #4299e1;
    color: #1a56db;
    font-weight: 600;
}
.multi-filter-panel {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    /* Size to the widest option (capped) instead of clamping to the button
       width — long values like emails were being clipped. min-width keeps it at
       least as wide as the button; max-width caps it and lets rows wrap. */
    width: max-content;
    min-width: 100%;
    max-width: min(340px, 90vw);
    background: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 500;
    padding: 4px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.multi-filter-panel.show { display: block; }
.multi-filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    font-size: 0.75rem;
    color: #2d3748;
    /* Wrap long values (emails/names) rather than clip them. */
    white-space: normal;
    overflow-wrap: anywhere;
    user-select: none;
    cursor: pointer;
}
.multi-filter-item:hover { background: #f7fafc; }
.multi-filter-item input[type="checkbox"] { accent-color: #4299e1; cursor: pointer; flex-shrink: 0; }

/* ── Date Range Filter ── */
.date-filter-wrap { position: relative; }
.date-filter-trigger {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    background: #fff;
    color: #718096;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
    transition: border-color 0.15s;
}
.date-filter-trigger:hover { border-color: #4299e1; }
.date-filter-trigger.has-filter {
    color: #1a56db;
    border-color: #4299e1;
    background: #e8f4fd;
    font-weight: 600;
}
.date-filter-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 9999;
    min-width: 260px;
    background: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 10px;
}
.date-filter-preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.date-filter-preset {
    padding: 4px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #f7fafc;
    font-size: 0.75rem;
    cursor: pointer;
    color: #4a5568;
    font-family: inherit;
    transition: all 0.15s;
}
.date-filter-preset:hover { background: #edf2f7; border-color: #4299e1; }
.date-filter-preset.active { background: #4299e1; color: #fff; border-color: #4299e1; }
.date-filter-divider {
    font-size: 0.7rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 8px 0 6px;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}
.date-filter-custom { display: flex; gap: 8px; margin-bottom: 10px; }
.date-filter-field { flex: 1; }
.date-filter-field label { display: block; font-size: 0.7rem; color: #718096; margin-bottom: 2px; }
.date-filter-field input[type="date"] {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #2d3748;
    background: #fff;
    font-family: inherit;
}
.date-filter-field input[type="date"]:focus { border-color: #4299e1; outline: none; }
.date-filter-btn-row { display: flex; gap: 6px; }
.date-filter-clear-btn, .date-filter-apply-btn {
    flex: 1;
    padding: 5px 0;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}
.date-filter-clear-btn { background: #e5e7eb; color: #6b7280; }
.date-filter-clear-btn:hover { background: #d1d5db; }
.date-filter-apply-btn { background: #4299e1; color: #fff; }
.date-filter-apply-btn:hover { opacity: 0.9; }

#btn-add-user-toggle {
    background: var(--color-primary) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 600;
