/* Nabdi v1.6.1 — global table rendering + visit chronology polish */

/*
 * Global table fix:
 * Earlier base CSS made every <th> sticky at top:72px. Inside cards and horizontally
 * scrollable settings tables this caused headers to float over the first data row and
 * made rows look clipped/hidden. Sticky headers are now opt-in only.
 */
.content table thead th,
.content table th {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
}

/* Stable table surface used by settings, attachments, patient lists and admin screens. */
.table-card,
.attachment-table-wrap,
.encounter-table-wrap,
.data-table-wrap {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    background: #fff;
    isolation: isolate;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
}

.table-card table,
.attachment-table,
.encounter-table,
.master-table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-card thead th,
.attachment-table thead th,
.encounter-table thead th,
.master-table thead th {
    background: #f8fafc !important;
    box-shadow: inset 0 -1px 0 var(--border);
    white-space: nowrap;
}

.table-card tbody td,
.attachment-table tbody td,
.encounter-table tbody td,
.master-table tbody td {
    background-clip: padding-box;
}

.master-table { min-width: 760px; }
.attachment-table { min-width: 1180px; }
.encounter-table { min-width: 1320px; }

/* Never let a row render underneath a header or outside its table shell. */
.table-card tbody tr,
.attachment-table tbody tr,
.encounter-table tbody tr,
.master-table tbody tr {
    position: relative;
    z-index: 0;
}

/* Settings/addition cards remain visually separate from their tables. */
.master-create-card + .table-card { margin-top: 16px; }
.table-card { padding: 0; border-radius: 12px; }
.table-card > table th:first-child,
.table-card > table td:first-child { padding-right: 16px; }
.table-card > table th:last-child,
.table-card > table td:last-child { padding-left: 16px; }

/* Attachments table: remove inherited sticky positioning that produced the screenshot defect. */
.attachment-table-wrap { overflow-y: hidden; }
.attachment-table th { position: static !important; top: auto !important; }

/* Visit table: current visit remains visually dominant. */
.visit-row-latest {
    background: #effbf8 !important;
    box-shadow: inset -4px 0 0 var(--brand-primary) !important;
}
.visit-row-latest td { background: transparent !important; }
.recency-latest {
    background: #dcf8f2 !important;
    color: #08766c !important;
    border: 1px solid #a9e6dc;
}
.recency-old {
    background: #f2f4f7 !important;
    color: #667085 !important;
}

/* Keep horizontal scrolling usable on narrower clinic screens without clipping controls. */
@media (max-width: 900px) {
    .table-card,
    .attachment-table-wrap,
    .encounter-table-wrap { -webkit-overflow-scrolling: touch; }
}
