/* Better Search - Native REDCap-Aligned Styling */

.bs-wrap {
    max-width: 960px;
    margin-bottom: 40px;
}

.bs-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.bs-top-row .projhdr {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bs-intro {
    font-size: 13px;
    color: #444;
    margin-bottom: 12px;
    line-height: 1.45;
}

/* Arm Tabs matching REDCap sub-nav */
.bs-arm-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 8px;
}

.bs-arm-label {
    font-size: 12.5px;
    font-weight: 700;
    color: #555;
    margin-right: 4px;
}

.bs-arm-tab {
    display: inline-block;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: #333 !important;
    background: #eaeaea;
    border: 1px solid #c5c5c5;
    border-radius: 4px;
    text-decoration: none !important;
}

.bs-arm-tab:hover {
    background: #dcdcdc;
}

.bs-arm-tab.active {
    background: #800000;
    color: #fff !important;
    border-color: #600000;
}

/* Main REDCap chklist panel */
.bs-panel {
    background-color: #f7f7f7;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.bs-counts-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    padding-bottom: 11px;
    margin-bottom: 13px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12.5px;
    color: #444;
}

.bs-counts-row strong {
    color: #111;
    font-size: 13px;
}

.bs-section-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 10px 0;
}

.bs-section-row + .bs-section-row {
    border-top: 1px solid #e0e0e0;
    margin-top: 6px;
    padding-top: 14px;
}

.bs-row-label {
    width: 195px;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 13px;
    color: #222;
    padding-top: 6px;
}

.bs-row-label-sub {
    font-weight: 400;
    font-size: 11px;
    color: #666;
    margin-top: 3px;
    line-height: 1.35;
}

.bs-row-content {
    flex: 1;
    min-width: 0;
}

@media (max-width: 700px) {
    .bs-section-row {
        flex-direction: column;
        gap: 6px;
    }
    .bs-row-label {
        width: 100%;
        padding-top: 0;
    }
}

/* Search Controls */
.bs-search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.bs-input-text {
    flex: 1;
    min-width: 220px;
    height: 34px;
    padding: 5px 10px;
    font-size: 13.5px;
    color: #222;
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 3px;
}

.bs-input-text:focus {
    border-color: #800000;
    outline: none;
    box-shadow: 0 0 0 2px rgba(128, 0, 0, 0.12);
}

.bs-select {
    height: 34px;
    padding: 4px 30px 4px 10px;
    font-size: 12.5px;
    color: #222;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23444' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 11px 11px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 1px solid #aaa;
    border-radius: 3px;
    max-width: 240px;
}

.bs-btn {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none !important;
    white-space: nowrap;
}

.bs-btn-search {
    background: #800000;
    color: #fff !important;
    border: 1px solid #600000;
}

.bs-btn-search:hover {
    background: #660000;
}

.bs-btn-quick-open {
    background: #0073e6;
    color: #fff !important;
    border: 1px solid #005bb5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.bs-btn-quick-open:hover {
    background: #005bb5;
    color: #fff !important;
}

/* Direct Match Quick Open Banner */
.bs-quick-open-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 7px 12px;
    background: #eef6fd;
    border: 1px solid #b8daff;
    border-radius: 4px;
    animation: bsFadeIn 0.15s ease-in;
}

.bs-quick-open-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: #1a3c61;
}

.bs-qo-icon {
    color: #0073e6;
    font-size: 14px;
}

.bs-qo-lead {
    font-weight: 600;
    color: #0056b3;
}

.bs-qo-id {
    font-size: 13.5px;
    font-weight: 700;
    color: #004085;
    background: #d4e8fd;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid #b6d8fb;
}

.bs-qo-label {
    color: #2b3e50;
    font-weight: 500;
}

.bs-qo-reason {
    font-size: 11px;
    color: #555;
    background: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid #cce5ff;
}

.bs-kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 10px;
    font-family: inherit;
    line-height: 1.2;
    color: #fff;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.bs-btn-add {
    background: #28a745;
    color: #fff !important;
    border: 1px solid #1e7e34;
}

.bs-btn-add:hover {
    background: #218838;
}

.bs-btn-add:disabled {
    opacity: 0.65;
    cursor: wait;
}

.bs-btn-outline {
    background: #fff;
    color: #333 !important;
    border: 1px solid #bbb;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.bs-btn-outline:hover {
    background: #eee;
}

/* Stacked Search Filter Chips */
.bs-chip-bar {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 3px;
    font-size: 12px;
}

.bs-chip-bar-label {
    font-weight: 700;
    color: #555;
    margin-right: 2px;
}

.bs-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: #800000;
    color: #fff;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.bs-filter-chip-remove {
    background: none;
    border: none;
    color: #ffcccc;
    font-size: 13px;
    line-height: 1;
    padding: 0 1px;
    cursor: pointer;
}

.bs-filter-chip-remove:hover {
    color: #fff;
}

.bs-search-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #555;
}

.bs-checkbox-label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.bs-link-btn {
    background: none;
    border: none;
    color: #0056b3;
    padding: 0;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
}

.bs-priority-drawer {
    display: none;
    margin-top: 8px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #d8d8d8;
    border-radius: 3px;
    font-size: 11.5px;
}

.bs-priority-chip {
    display: inline-block;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 1px 6px;
    margin: 2px 4px 2px 0;
    color: #333;
}

.bs-priority-chip em {
    font-style: normal;
    color: #800000;
    font-weight: 600;
}

/* Create Record Controls */
.bs-create-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.bs-error-msg {
    color: #c00000;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

/* Results Panel */
.bs-results-box {
    display: none;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.bs-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: #efefef;
    border-bottom: 1px solid #ccc;
    font-size: 12px;
}

.bs-badge-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.bs-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11.5px;
    font-weight: 600;
}

.bs-pill-fast {
    background: #dff0d8;
    color: #2b542c;
    border: 1px solid #c1e2b3;
}

.bs-pill-detected {
    background: #d9edf7;
    color: #245269;
    border: 1px solid #afd9ee;
}

.bs-pill-running {
    background: #fcf8e3;
    color: #66512c;
    border: 1px solid #f7ecb5;
}

.bs-pill-done {
    background: #e8e8e8;
    color: #444;
    border: 1px solid #d0d0d0;
}

.bs-pill-exact {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #ceead6;
}

.bs-exact-match-row {
    background-color: #f7fbf8 !important;
}

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

.bs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.bs-table th {
    background: #f5f5f5;
    color: #222;
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #ccc;
    white-space: nowrap;
}

.bs-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: top;
}

.bs-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.bs-table tbody tr:hover,
.bs-table tbody tr.bs-row-active {
    background: #fff8f8;
}

.bs-rec-id {
    font-weight: 700;
    font-size: 13.5px;
    color: #800000 !important;
    text-decoration: none;
}

.bs-rec-id:hover {
    text-decoration: underline;
}

.bs-meta-tag {
    display: inline-block;
    font-size: 10.5px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-top: 3px;
    margin-right: 4px;
    background: #e9ecef;
    color: #444;
    border: 1px solid #d6d8db;
}

.bs-tier-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 2px;
    margin-left: 5px;
}

.bs-tier-fast {
    background: #e6f4ea;
    color: #137333;
}

.bs-tier-deep {
    background: #fef7e0;
    color: #b06000;
}

.bs-hit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    margin-bottom: 4px;
    background: #f9f9f9;
    border: 1px solid #e2e2e2;
    border-radius: 3px;
    font-size: 12px;
}

.bs-hit-row:last-child {
    margin-bottom: 0;
}

.bs-hit-label {
    font-weight: 600;
    color: #333;
}

.bs-hit-val {
    color: #111;
    word-break: break-word;
}

.bs-hl {
    background: #ffe066;
    color: #000;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

.bs-hit-form-link {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: #0056b3 !important;
    text-decoration: none;
    white-space: nowrap;
}

.bs-hit-form-link:hover {
    text-decoration: underline;
}

.bs-lock-icon {
    color: #8a6d3b;
    font-size: 11px;
    margin-left: 4px;
}

/* Recently Viewed Records */
.bs-recent-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 3px;
    font-size: 12px;
}

.bs-recent-label {
    font-weight: 700;
    color: #555;
    margin-right: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bs-recent-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #800000 !important;
    font-weight: 600;
    text-decoration: none !important;
    font-size: 12px;
}

.bs-recent-chip:hover {
    background: #ececec;
    border-color: #999;
}

.bs-recent-chip-lbl {
    font-weight: 400;
    color: #555;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User Settings Drawer */
.bs-settings-badges {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: auto;
}

.bs-setting-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    background: #e9ecef;
    color: #444;
    border: 1px solid #d0d4d9;
}

.bs-settings-drawer {
    display: none;
    margin-top: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    font-size: 12px;
}

.bs-settings-title {
    font-weight: 700;
    color: #222;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.bs-settings-sub {
    font-weight: 400;
    color: #777;
    font-size: 11px;
    margin-left: 4px;
}

.bs-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bs-setting-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.bs-setting-label {
    margin: 0;
    font-weight: 400;
    color: #333;
}

.bs-select-sm {
    height: 28px;
    padding: 2px 26px 2px 8px;
    font-size: 12px;
}

.bs-fuzzy-slider {
    width: 160px;
    cursor: pointer;
    accent-color: #800000;
}

#bs-fuzzy-threshold-val {
    display: inline-block;
    min-width: 85px;
    font-size: 12px;
    color: #800000;
}

.bs-empty {
    padding: 22px 12px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

/* Table Footer & Pagination */
.bs-table tfoot td.bs-tfoot-cell {
    background: #efefef;
    border-top: 1px solid #ccc;
    border-bottom: none;
    padding: 8px 12px;
    vertical-align: middle;
}

.bs-tfoot-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: #333;
}

.bs-page-info {
    font-weight: 600;
    color: #444;
}

.bs-page-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.bs-page-btn {
    height: 26px;
    min-width: 28px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bs-page-btn:hover:not(:disabled) {
    background: #e2e2e2;
}

.bs-page-btn.active {
    background: #800000;
    color: #fff;
    border-color: #600000;
}

.bs-page-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.bs-page-ellipsis {
    padding: 0 4px;
    color: #666;
}

.bs-page-size-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #444;
}

.bs-page-size-wrap label {
    margin: 0;
    font-weight: 600;
}

.bs-page-size-input {
    width: 64px;
    height: 26px;
    padding: 2px 6px;
    font-size: 12px;
    color: #222;
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 3px;
    text-align: center;
}

.bs-page-size-input:focus {
    border-color: #800000;
    outline: none;
}


