/* Wing-preselected readonly/disabled shift & medium fields */
.field-readonly-disabled,
select.field-readonly-disabled:disabled {
    background-color: #e9ecef !important;
    opacity: 0.85;
    cursor: not-allowed;
}

/* Override Bootstrap validation colors to use primary color */
.form-control.is-valid,
.form-select.is-valid,
.datepicker-input.is-valid {
    border-color: var(--bs-primary) !important;
    padding-right: calc(1.5em + 0.75rem) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23005b6f' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right calc(0.375em + 0.1875rem) center !important;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem) !important;
}

.form-control.is-valid:focus,
.form-select.is-valid:focus,
.datepicker-input.is-valid:focus {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25) !important;
}

/*
 * Global table density — every table on every page (list pages, DataTables, plain tables).
 * Body base is 0.812rem (--bs-body-font-size); table cells sit one step below it.
 * This file is loaded from templates/element/new/head-css.php on every layout, so it is
 * the single place to change table text size — do not re-declare it per page.
 */
.table > :not(caption) > * > *,
.table > thead > tr > th {
    font-size: 0.75rem;
}

/* DataTables chrome (length select, search box, info line, pager) matches the cells */
.datatable-top,
.datatable-bottom,
div.dt-container .dt-length,
div.dt-container .dt-search,
div.dt-container .dt-info,
div.dt-container .dt-paging .page-link {
    font-size: 0.75rem;
}

/*
 * Long, transient tables inside a modal (for example the blocked-payment list on the
 * fee template payment sync preview): keep the modal itself a sensible height and let
 * the table scroll inside its own box.
 */
.sync-scroll-area {
    max-height: 20rem;
    overflow-y: auto;
}
/*
 * Theme badges. Templates use .badge-primary / .badge-secondary (the project's badge convention),
 * but the compiled theme does not define them, so Bootstrap's .badge rendered white text on no
 * background — the count was there but invisible. Theme variables, so dark mode follows.
 */
.badge.badge-primary {
    background-color: var(--bs-primary);
    color: #fff;
}

.badge.badge-secondary {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-emphasis-color);
    border: 1px solid var(--bs-border-color);
}

/*
 * Boxed tabs: filled active tab on a primary underline, pane boxed underneath. Opt-in modifier on top
 * of the theme's .nav-tabs-custom, so other tab bars keep the theme look. Used by Administer > Global
 * Settings and the Result Config class modal. Theme variables, so dark mode follows.
 */
.nav-tabs-custom.nav-tabs-boxed {
    border-bottom: 2px solid var(--bs-primary);
    gap: 4px;
}

.nav-tabs-custom.nav-tabs-boxed .nav-link {
    color: var(--bs-body-color);
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-weight: 500;
    padding: 10px 18px;
    transition: all 0.2s ease-in-out;
    margin-bottom: -2px;
}

.nav-tabs-custom.nav-tabs-boxed .nav-link:hover {
    color: var(--bs-primary);
    background-color: var(--bs-secondary-bg);
    border-color: var(--bs-border-color);
}

.nav-tabs-custom.nav-tabs-boxed .nav-link.active {
    color: #fff !important;
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    font-weight: 600;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.08);
}

.tab-content-boxed {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    background-color: var(--bs-body-bg);
}

/*
 * Custom merit ordering builder (element/resultConfig/merit_criteria_builder.php): two drag and drop
 * lists of criteria. Scoped to the builder; theme variables only, so dark mode follows.
 */
.merit-criteria-builder .merit-criteria-switch .form-check-input {
    width: 2.75rem;
    height: 1.4rem;
    cursor: pointer;
}

.merit-criteria-builder .merit-criteria-list {
    min-height: 3.5rem;
}

.merit-criteria-builder .merit-criterion {
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.375rem;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    cursor: grab;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.merit-criteria-builder .merit-criterion:last-child {
    margin-bottom: 0;
}

.merit-criteria-builder .merit-criterion:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 1px 4px rgba(var(--bs-primary-rgb), 0.15);
}

.merit-criteria-builder .merit-criterion[data-tiebreak="1"] {
    border-style: dashed;
}

.merit-criteria-builder .merit-criterion .btn {
    --bs-btn-padding-y: 0.125rem;
    --bs-btn-padding-x: 0.4rem;
}

/* Rank circle only in "Used"; + only in "Available", × only in "Used". */
.merit-criteria-builder .merit-criterion-rank {
    display: none;
    flex: 0 0 1.6rem;
    width: 1.6rem;
    height: 1.6rem;
    line-height: 1.6rem;
    border-radius: 50%;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--bs-primary);
}

.merit-criteria-builder .merit-criteria-used .merit-criterion-rank {
    display: inline-block;
}

.merit-criteria-builder .merit-criteria-used .merit-criterion-add,
.merit-criteria-builder .merit-criteria-unused .merit-criterion-remove {
    display: none;
}

.merit-criteria-builder .merit-criteria-unused .merit-criterion {
    background-color: var(--bs-tertiary-bg);
}

.merit-criteria-builder .merit-criteria-empty {
    padding: 0.875rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    border: 1px dashed var(--bs-border-color);
    border-radius: 0.5rem;
}

.merit-criteria-builder .merit-criterion-ghost {
    opacity: 0.45;
    border-color: var(--bs-primary);
    border-style: dashed;
}

.merit-criteria-builder .merit-criteria-chips .badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35em 0.6em;
}

/* The theme's primary is too dark to read as an outline on a dark surface. */
[data-bs-theme="dark"] .merit-criteria-builder .merit-criterion-add {
    color: var(--bs-emphasis-color);
    border-color: var(--bs-secondary-color);
}

/* ---- Result Config field tooltips (element/resultConfig/field_tip.php) ---- */
.result-config-tip {
    cursor: help;
    font-size: 0.8em;
}

.result-config-tip:hover,
.result-config-tip:focus {
    color: var(--bs-primary) !important;
    outline: none;
}

/* Several lines of Bangla text: wider than the 200px default, left aligned, a little more leading. */
.result-config-tooltip .tooltip-inner {
    max-width: 360px;
    text-align: left;
    line-height: 1.55;
    padding: 0.5rem 0.75rem;
}

[data-bs-theme="dark"] .result-config-tip:hover,
[data-bs-theme="dark"] .result-config-tip:focus {
    color: var(--bs-emphasis-color) !important;
}
