:root {
    /* Tabulator specific theme variables */
    --tabulator-background: #fff;
    --tabulator-text: #333;
    --tabulator-border: #ddd;
    --tabulator-header-background: #f3f3f3;
    --tabulator-header-text: #333;
    --tabulator-row-border: #ddd;
    --tabulator-row-background: #fff;
    --tabulator-row-background-hover: #f5f5f5;
}

/* ==========================================================================
   Tabulator Table Styles
   ========================================================================== */
   [data-page-type='references'] {
    max-width: 100%;
    overflow-x: hidden;
    margin-bottom: 0; /* Ensure no bottom margin */
    padding-bottom: 0; /* Ensure no bottom padding */
}

#references-table {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin-bottom: 0; /* Ensure no bottom margin */
}

.tabulator {
    background-color: var(--tabulator-background);
    border: 1px solid var(--tabulator-border);
    font-size: var(--base-font-size);
    width: 100% !important;
    margin: 0;
    border: none !important;
    line-height: 1.4 !important;
}

/* Header Styles */
.tabulator .tabulator-header {
    background-color: var(--tabulator-header-background);
    color: var(--tabulator-header-text);
    border-bottom: 2px solid var(--tabulator-border);
    font-weight: bold;
    font-size: var(--base-font-size) !important;
    padding-left: 0;
}

.tabulator .tabulator-header .tabulator-col {
    background-color: var(--tabulator-header-background);
    border-right: 1px solid var(--tabulator-border);
}

.tabulator .tabulator-header .tabulator-col:first-child {
    padding-left: 0;
}

.tabulator .tabulator-header .tabulator-col:last-child {
    border-right: none;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
    font-weight: bold !important; /* Force bold on column headers */
}

/* Table Body Styles */
.tabulator .tabulator-tableholder {
    overflow-y: auto !important;
    overflow-x: hidden;
    background: repeating-linear-gradient(to bottom, var(--tabulator-background) 0px, var(--tabulator-background) 50px, #f3f3f3 50px, #f3f3f3 100px);
}

.tabulator-row {
    border-bottom: 1px solid var(--tabulator-border);
    background-color: transparent !important; /* Use transparent to show gradient */
    margin-bottom: 0 !important;
}

.tabulator-row .tabulator-cell {
    border-right: 1px solid var(--tabulator-border);
    padding: 0px 2px !important;
    vertical-align: middle !important;
}

.tabulator-row .tabulator-cell:last-child {
    border-right: none;
}

.tabulator-row .tabulator-cell:first-child {
    border-left: none !important;
}

.tabulator-row:hover {
    background-color: var(--tabulator-row-background-hover) !important;
}

/* Column specific styles */
.cell-title {
    white-space: normal !important;
    min-width: 300px;
    font-weight: 500 !important;
}

/* Links in table cells */
.tabulator-cell a {
    color: var(--link-color);
    text-decoration: none;
}

.tabulator-cell a:hover {
    text-decoration: underline;
}

/* Sorting styles */
.tabulator-col.tabulator-sortable:hover {
    background-color: var(--tabulator-row-background-hover);
}

.tabulator-col.tabulator-sortable[aria-sort='none'] .tabulator-col-content:after {
    border-top: 4px solid #bbb;
}

.tabulator-col.tabulator-sortable[aria-sort='ascending'] .tabulator-col-content:after,
.tabulator-col.tabulator-sortable[aria-sort='descending'] .tabulator-col-content:after {
    border-top: 4px solid var(--accent-color);
}

/* table status */
.table-status {
    font-size: calc(var(--base-font-size) * 0.9);
    color: var(--text-muted);
    padding: 0 0.75rem; /* only horizontal padding*/
    border-top: none; /* Remove top border since it connects to table */
    background-color: var(--tabulator-background);
    text-align: right; /* Right-align the status text */
    min-height: 1.5rem; /* Ensure minimum height */
    line-height: 1.5rem; /* Add proper line height */
    box-sizing: border-box; /* Prevent padding from adding to total height */
    margin: 0; /* Remove margin */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading indicator */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid var(--accent-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Custom loader overlay */
#custom-loader {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    font-weight: bold;
    color: var(--text-color);
    padding: 10px 20px;
    text-align: center;
    border-radius: 5px;
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 1000;
    min-width: 200px;
    border: 2px solid var(--primary-color);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tabulator-col {
        min-width: unset !important;
    }

    .tabulator-cell {
        min-width: unset !important;
    }

    .cell-title {
        min-width: 200px;
    }
}

/* ==========================================================================
   Search Controls
   ========================================================================== */
   .search-controls {
    margin: 0;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.search-box input {
    flex: 1;
    padding: 0.5em;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.search-box button {
    padding: 0.5em 1em;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.search-box button:hover {
    background-color: #1976d2;
}

.search-box button.secondary {
    background-color: var(--text-muted);
}

.search-box button.secondary:hover {
    background-color: #4d4d4d;
}

.search-options-container {
    display: flex;
    justify-content: space-between;
    min-height: 24px;
}

.search-options {
    display: flex;
    column-gap: 10px;
}

.search-options label {
    display: inline-flex;
    align-items: center; /* Keep this to align checkbox with text */
    gap: 0.3em;
    cursor: pointer;
    height: 24px;
}

.search-options input[type='checkbox'] {
    cursor: pointer;
}

.search-status {
    color: var(--text-muted);
    font-style: italic;
    margin-left: 20px;
    line-height: 24px;
}

.button.secondary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.button.secondary:disabled:hover {
    background-color: #ccc;
}

@media (max-width: 768px) {
    .search-options-container {
        flex-direction: row;
    }

    .search-options {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .search-status {
        margin-left: 0;
        margin-top: 0.5rem;
    }
}
