/* -----------------------------------------------------------------------
   admin-tables.css
   Shared styles for admin data-table pages (toolbar, table, pagination).
   Page-specific layout and domain styles (e.g. .admit-hca) stay inline.
   ----------------------------------------------------------------------- */

/* --- toolbar ---------------------------------------------------------- */
.fm-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.fm-cache-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
}
.fm-toolbar label,
.fm-cache-controls label,
.fm-filter-row label,
.fm-label {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}
.fm-toolbar input[type=date] {
    border: 1px solid #9e9e9e;
    border-radius: 2px;
    padding: 5px 8px;
    font-size: 0.875rem;
    width: 140px !important;
    box-sizing: border-box;
}
.fm-toolbar select,
.fm-cache-controls select,
.fm-native-select {
    display: inline-block !important;
    width: auto !important;
    min-width: 60px;
    max-width: 120px;
    border: 1px solid #9e9e9e;
    border-radius: 2px;
    padding: 4px 6px;
    font-size: 0.875rem;
    background: var(--hca-card-bg) !important;
    color: var(--hca-text) !important;
    height: auto !important;
    opacity: 1 !important;
    position: static !important;
    pointer-events: auto !important;
    box-sizing: border-box;
}
.fm-hidden { display: none !important; }
.fm-toolbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: auto;
}
.fm-toolbar-right-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.fm-badge {
    font-size: 0.75rem;
    color: var(--hca-report-header-text);
}
.fm-cache-badge {
    font-size: 0.75rem;
    color: var(--hca-report-header-text);
    padding: 2px 8px;
    border: 1px solid var(--hca-divider);
    border-radius: 12px;
    background: var(--hca-card-bg);
    white-space: nowrap;
}
.fm-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--hca-card-bg);
    border: 1px solid var(--hca-report-header-border);
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--hca-text);
    cursor: pointer;
    transition: background 0.15s;
}
.fm-export-btn:hover { background: var(--hca-report-header-bg); }

/* --- apply spinner ---------------------------------------------------- */
.fm-spinner {
    display: none;
    font-size: 1.1rem;
    vertical-align: middle;
    animation: fm-spin 0.7s linear infinite;
    color: var(--hca-report-header-text);
}
@keyframes fm-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* --- filter row ------------------------------------------------------- */
.fm-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    position: relative;
}
.fm-search {
    border: 1px solid #9e9e9e;
    border-radius: 2px;
    padding: 5px 10px;
    font-size: 0.875rem;
    width: 300px !important;
    max-width: 300px !important;
    height: auto !important;
    box-sizing: border-box;
    background: var(--hca-card-bg);
    color: var(--hca-text);
}
.fm-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    margin-left: -4px;
    color: var(--hca-text);
    opacity: 0.5;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.fm-search-clear:hover { opacity: 1; }
.fm-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--hca-report-header-text);
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.fm-info-btn:hover { color: #1565c0; }
.fm-info-popup {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 300;
    background: var(--hca-card-bg);
    border: 1px solid var(--hca-divider);
    border-radius: 6px;
    padding: 14px 18px 10px;
    font-size: 0.8rem;
    width: 460px;
    max-width: 90vw;
    box-shadow: 0 4px 18px rgba(0,0,0,0.18);
    color: var(--hca-text);
    line-height: 1.55;
}
.fm-info-popup h6 { margin: 0 0 8px; font-size: 0.85rem; font-weight: 700; }
.fm-info-popup table { width: 100%; border-collapse: collapse; }
.fm-info-popup tr + tr td { border-top: 1px solid var(--hca-divider); }
.fm-info-popup td { padding: 4px 8px 4px 0; vertical-align: top; }
.fm-info-popup td:first-child {
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.82rem;
    color: #1565c0;
    padding-right: 14px;
    width: 1%;
}
.fm-info-note { margin: 8px 0 0; font-size: 0.75rem; color: var(--hca-report-header-text); }

/* --- table ------------------------------------------------------------ */
.fm-table-wrap {
    background: var(--hca-card-bg);
    border: 1px solid var(--hca-divider);
    border-radius: 4px;
    overflow-x: auto;
}
.fm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.fm-table thead tr {
    background: var(--hca-report-header-bg);
    border-bottom: 2px solid var(--hca-report-header-border);
}
.fm-table th {
    padding: 6px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--hca-report-header-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.fm-table th:hover { opacity: 0.8; }
.fm-table th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.4;
    font-size: 0.75rem;
}
.fm-table th.sort-asc .sort-icon,
.fm-table th.sort-desc .sort-icon { opacity: 1; }
.fm-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--hca-divider);
    white-space: nowrap;
}
.fm-table th.fm-col-dest,
.fm-table td.fm-col-dest {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fm-table th.fm-col-matchid,
.fm-table td.fm-col-matchid {
    width: 100px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fm-table tbody tr:hover { background: var(--hca-report-header-bg); }

/* --- pagination ------------------------------------------------------- */
.fm-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}
.fm-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 0.82rem;
    flex-wrap: wrap;
}
.fm-page-btn {
    border: 1px solid var(--hca-divider);
    background: var(--hca-card-bg);
    color: var(--hca-text);
    border-radius: 3px;
    padding: 3px 9px;
    cursor: pointer;
    font-size: 0.82rem;
}
.fm-page-btn:disabled { opacity: 0.4; cursor: default; }
.fm-page-btn.active { background: #1565c0; color: #fff; border-color: #1565c0; }
.fm-page-info { color: var(--hca-report-header-text); margin: 0 4px; }

/* --- row selection ---------------------------------------------------- */
.fm-table tbody tr { cursor: pointer; }
.fm-table tbody tr.fm-row-mixed-dob { background: rgba(255, 179, 0, 0.14); }
.fm-table tbody tr.fm-row-potential-match { background: rgba(0, 150, 136, 0.13); }
.fm-table tbody tr.fm-row-potential-match-alt { background: rgba(0, 150, 136, 0.06); }
.fm-table tbody tr.fm-row-selected { background: rgba(21, 101, 192, 0.2) !important; }

/* --- right-click context menu ----------------------------------------- */
.fm-ctx-menu {
    display: none;
    position: fixed;
    z-index: 600;
    background: var(--hca-card-bg);
    border: 1px solid var(--hca-divider);
    border-radius: 6px;
    padding: 12px 16px 14px;
    min-width: 260px;
    max-width: 420px;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22);
    color: var(--hca-text);
}
.fm-ctx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.fm-ctx-title { font-size: 0.85rem; font-weight: 700; }
.fm-ctx-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--hca-text);
    padding: 2px;
    display: inline-flex;
    align-items: center;
}
.fm-ctx-close:hover { color: #c62828; }
.fm-ctx-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    font-size: 0.8rem;
    font-family: monospace;
    line-height: 1.6;
}
.fm-ctx-list li {
    padding: 2px 0;
    border-bottom: 1px solid var(--hca-divider);
}
.fm-ctx-list li:last-child { border-bottom: none; }
.fm-ctx-empty { font-size: 0.82rem; color: var(--hca-report-header-text); }
.fm-ctx-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
}
.fm-ctx-copy:hover { background: #0d47a1; }
.fm-ctx-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    margin-top: 6px;
}
.fm-ctx-clear:hover { background: #b71c1c; }

/* --- copy toast -------------------------------------------------------- */
.fm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 700;
    background: #2e7d32;
    color: #fff;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.28);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}
.fm-toast.fm-toast-show {
    opacity: 1;
    transform: translateY(0);
}

/* Checkbox label used in toolbar and top bar */
.fm-chk-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.fm-chk-label input[type=checkbox] {
    position: static !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    flex-shrink: 0;
}
/* Suppress Materialize's animated pseudo-element overlay */
.fm-chk-label span::before,
.fm-chk-label span::after {
    display: none !important;
}
.fm-chk-label span {
    padding-left: 0 !important;
    height: auto !important;
    line-height: 1 !important;
    font-size: 0.82rem !important;
}








.fm-table th[data-col="matchLabel"],
.fm-table td.fm-col-match-label {
    width: 62px;
    max-width: 62px;
}
.fm-match-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 18px;
    padding: 0 5px;
    border: 1px solid var(--hca-divider);
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--hca-report-header-text);
    background: transparent;
}
.fm-match-pill.has-value {
    border-color: #1565c0;
    color: #1565c0;
    background: rgba(21, 101, 192, 0.06);
}
.fm-table tbody tr.fm-row-match-hover {
    outline: 1px dashed #1565c0;
    outline-offset: -1px;
}
.fm-table tbody tr.fm-row-match-hover .fm-match-pill {
    border-color: #1565c0;
    background: rgba(21, 101, 192, 0.1);
}

/* --- column visibility: hide both <th> and <td> at the same nth-child ---- */
.fm-hide-col-admitType           #matchTable th:nth-child(1),  .fm-hide-col-admitType           #matchTable td:nth-child(1)  { display:none; }
.fm-hide-col-incidentIDorMatchingID #matchTable th:nth-child(2), .fm-hide-col-incidentIDorMatchingID #matchTable td:nth-child(2) { display:none; }
.fm-hide-col-admitArrival        #matchTable th:nth-child(3),  .fm-hide-col-admitArrival        #matchTable td:nth-child(3)  { display:none; }
.fm-hide-col-destinationCode     #matchTable th:nth-child(4),  .fm-hide-col-destinationCode     #matchTable td:nth-child(4)  { display:none; }
.fm-hide-col-destinationName     #matchTable th:nth-child(5),  .fm-hide-col-destinationName     #matchTable td:nth-child(5)  { display:none; }
.fm-hide-col-division            #matchTable th:nth-child(6),  .fm-hide-col-division            #matchTable td:nth-child(6)  { display:none; }
.fm-hide-col-state               #matchTable th:nth-child(7),  .fm-hide-col-state               #matchTable td:nth-child(7)  { display:none; }
.fm-hide-col-matchLabel          #matchTable th:nth-child(8),  .fm-hide-col-matchLabel          #matchTable td:nth-child(8)  { display:none; }
.fm-hide-col-dateOfBirth         #matchTable th:nth-child(9),  .fm-hide-col-dateOfBirth         #matchTable td:nth-child(9)  { display:none; }
.fm-hide-col-lastName            #matchTable th:nth-child(10), .fm-hide-col-lastName            #matchTable td:nth-child(10) { display:none; }
.fm-hide-col-middleName          #matchTable th:nth-child(11), .fm-hide-col-middleName          #matchTable td:nth-child(11) { display:none; }
.fm-hide-col-firstName           #matchTable th:nth-child(12), .fm-hide-col-firstName           #matchTable td:nth-child(12) { display:none; }
.fm-hide-col-gender              #matchTable th:nth-child(13), .fm-hide-col-gender              #matchTable td:nth-child(13) { display:none; }
.fm-hide-col-sex                 #matchTable th:nth-child(14), .fm-hide-col-sex                 #matchTable td:nth-child(14) { display:none; }
.fm-hide-col-encounterNumber     #matchTable th:nth-child(15), .fm-hide-col-encounterNumber     #matchTable td:nth-child(15) { display:none; }
.fm-hide-col-medicalReportNumber #matchTable th:nth-child(16), .fm-hide-col-medicalReportNumber #matchTable td:nth-child(16) { display:none; }
.fm-hide-col-messageType         #matchTable th:nth-child(17), .fm-hide-col-messageType         #matchTable td:nth-child(17) { display:none; }
.fm-hide-col-created             #matchTable th:nth-child(18), .fm-hide-col-created             #matchTable td:nth-child(18) { display:none; }

/* --- cog button --------------------------------------------------------- */
.fm-col-cog-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    padding: 0 8px;
    height: 30px;
    cursor: pointer;
    color: #555;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.fm-col-cog-btn:hover { background: #f5f5f5; border-color: #9e9e9e; }
.fm-col-cog-btn .material-icons { font-size: 1.1rem; }

/* --- compact table toggle ----------------------------------------------- */
.fm-table-compact-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    padding: 0 7px;
    height: 30px;
    cursor: pointer;
    color: #555;
    transition: background 0.15s, border-color 0.15s;
}
.fm-table-compact-btn:hover { background: #f5f5f5; border-color: #9e9e9e; }
.fm-table-compact-btn .material-icons { font-size: 1.1rem; }
.fm-table-compact-btn.active { background: #e3f2fd; border-color: #90caf9; color: #1565c0; }
.fm-table-wrap.fm-compact #matchTable { width: auto; }

/* --- column visibility modal -------------------------------------------- */
.fm-colvis-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9000;
    align-items: center;
    justify-content: center;
}
.fm-colvis-overlay.open { display: flex; }
.fm-colvis-modal {
    background: var(--hca-bg, #fff);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    width: 360px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.fm-colvis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e0e0e0;
}
.fm-colvis-header h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fm-colvis-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #757575;
    padding: 2px;
    display: inline-flex;
}
.fm-colvis-close:hover { color: #212121; }
.fm-colvis-body {
    overflow-y: auto;
    padding: 8px 0;
    flex: 1;
}
.fm-colvis-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 16px;
    border-bottom: 1px solid #f5f5f5;
    gap: 8px;
}
.fm-colvis-row:last-child { border-bottom: none; }
.fm-colvis-label {
    font-size: 0.88rem;
    color: #333;
    flex: 1;
}
.fm-colvis-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}
.fm-colvis-toggle button {
    border: none;
    background: #f5f5f5;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    color: #757575;
}
.fm-colvis-toggle button.active-visible { background: #1565c0; color: #fff; }
.fm-colvis-toggle button.active-hidden  { background: #e53935; color: #fff; }
.fm-colvis-footer {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
    border-top: 1px solid #e0e0e0;
    justify-content: flex-end;
}
.fm-colvis-footer button {
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    background: #f5f5f5;
    padding: 4px 12px;
    cursor: pointer;
}
.fm-colvis-footer button:hover { background: #e0e0e0; }
