/* ============================================================
   bs5-compat.css - Bootstrap 5 class compatibility layer
   ------------------------------------------------------------
   The app renders Bootstrap 5 markup (form-select, gutters,
   logical spacing, text-start / text-end, fs, fw, rounded...)
   on top of the Bootstrap 4.6 CSS bundled with SB Admin 2.
   This file adds the missing BS5 classes so every page lays
   out identically, and normalises control heights (42px
   default / 34px small) so inputs, selects and buttons line
   up in filter rows.
   Load order: sb-admin-2.css, modern-theme.css, bs5-compat.css, index.css
   ============================================================ */

/* ---------- Form controls: uniform height ---------- */
.form-control {
    height: 42px;
    padding: 0.4375rem 0.85rem;
}

textarea.form-control,
select.form-control[multiple],
select.form-control[size]:not([size="1"]),
input.form-control[type="file"] {
    height: auto;
}

.form-control-sm {
    height: 34px;
    padding: 0.3rem 0.65rem;
    font-size: 0.875rem;
}

.form-control-lg {
    height: 50px;
    padding: 0.5rem 1rem;
    font-size: 1.125rem;
}

.input-group-text {
    height: 42px;
    display: inline-flex;
    align-items: center;
}

.input-group-sm .input-group-text {
    height: 34px;
}

/* ---------- .form-select (BS5 select) ---------- */
.form-select {
    display: block;
    width: 100%;
    height: 42px;
    padding: 0.4375rem 2.25rem 0.4375rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.5;
    color: #1e293b;
    vertical-align: middle;
    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='%23343a40' 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 0.75rem center;
    background-size: 16px 12px;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-select:focus {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
    outline: none;
}

.form-select:disabled {
    background-color: #e9ecef;
}

.form-select-sm {
    height: 34px;
    padding: 0.3rem 1.75rem 0.3rem 0.65rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

.form-select-lg {
    height: 50px;
    padding: 0.5rem 2.25rem 0.5rem 1rem;
    font-size: 1.125rem;
    border-radius: 12px;
}

.form-select[multiple],
.form-select[size]:not([size="1"]) {
    height: auto;
    padding-right: 0.85rem;
    background-image: none;
}

/* ---------- Select2 (bootstrap-5 theme) sized to match ---------- */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 42px;
    padding: 0.4375rem 0.85rem;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
}

.select2-container--bootstrap-5 .select2-selection--single {
    height: 42px;
    padding: 0.4375rem 2.25rem 0.4375rem 0.85rem;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 34px;
    padding: 0;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 38px;
    right: 0.6rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    min-height: 42px;
    padding: 0.25rem 0.85rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    flex: 1 1 auto;
    padding: 0;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice {
    margin: 0.25rem 0.25rem 0 0;
    border-radius: 8px;
    padding: 0.1rem 0.45rem;
    font-size: 0.875rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search--inline,
.select2-container--bootstrap-5 .select2-selection--multiple .select2-search {
    display: inline-block;
    width: auto;
    flex: 0 0 auto;
    margin-top: 0.25rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search .select2-search__field,
.select2-container--bootstrap-5 .select2-selection--multiple .select2-search--inline .select2-search__field {
    width: auto;
    min-width: 3em;
    height: 24px;
    margin: 0;
    padding: 0 0.25rem;
    resize: none;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

/* select2 inside flex rows (toolbars) should size to content, not stretch
   full width — an inline width:100% would push sibling buttons/controls */
.d-flex .select2-container--bootstrap-5 {
    width: auto !important;
    max-width: 100%;
}

.d-flex .select2-container--bootstrap-5 .select2-selection {
    min-width: 9rem;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--border-color, #e2e8f0);
    border-radius: 10px;
}

/* ---------- Form switch (BS5) ---------- */
.form-switch {
    padding-left: 2.5em;
}

.form-switch .form-check-input {
    width: 2em;
    height: 1em;
    margin-left: -2.5em;
    border-radius: 2em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: rgba(0, 0, 0, 0.25);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: left center;
    background-repeat: no-repeat;
    background-size: contain;
    transition: background-position 0.15s ease-in-out;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary-color, #3b82f6);
    background-position: right center;
}

/* ---------- Grid gutters: g-*, gx-*, gy-* (0–5 + md) ---------- */
.row.g-0 { margin-right: 0; margin-left: 0; margin-top: 0; }
.row.g-0 > * { padding-right: 0; padding-left: 0; margin-top: 0; }
.row.g-1 { margin-right: -0.25rem; margin-left: -0.25rem; margin-top: -0.25rem; }
.row.g-1 > * { padding-right: 0.25rem; padding-left: 0.25rem; margin-top: 0.25rem; }
.row.g-2 { margin-right: -0.5rem; margin-left: -0.5rem; margin-top: -0.5rem; }
.row.g-2 > * { padding-right: 0.5rem; padding-left: 0.5rem; margin-top: 0.5rem; }
.row.g-3 { margin-right: -1rem; margin-left: -1rem; margin-top: -1rem; }
.row.g-3 > * { padding-right: 1rem; padding-left: 1rem; margin-top: 1rem; }
.row.g-4 { margin-right: -1.5rem; margin-left: -1.5rem; margin-top: -1.5rem; }
.row.g-4 > * { padding-right: 1.5rem; padding-left: 1.5rem; margin-top: 1.5rem; }
.row.g-5 { margin-right: -3rem; margin-left: -3rem; margin-top: -3rem; }
.row.g-5 > * { padding-right: 3rem; padding-left: 3rem; margin-top: 3rem; }

.row.gx-0 { margin-right: 0; margin-left: 0; }
.row.gx-0 > * { padding-right: 0; padding-left: 0; }
.row.gx-1 { margin-right: -0.25rem; margin-left: -0.25rem; }
.row.gx-1 > * { padding-right: 0.25rem; padding-left: 0.25rem; }
.row.gx-2 { margin-right: -0.5rem; margin-left: -0.5rem; }
.row.gx-2 > * { padding-right: 0.5rem; padding-left: 0.5rem; }
.row.gx-3 { margin-right: -1rem; margin-left: -1rem; }
.row.gx-3 > * { padding-right: 1rem; padding-left: 1rem; }
.row.gx-4 { margin-right: -1.5rem; margin-left: -1.5rem; }
.row.gx-4 > * { padding-right: 1.5rem; padding-left: 1.5rem; }
.row.gx-5 { margin-right: -3rem; margin-left: -3rem; }
.row.gx-5 > * { padding-right: 3rem; padding-left: 3rem; }

.row.gy-0 { margin-top: 0; }
.row.gy-0 > * { margin-top: 0; }
.row.gy-1 { margin-top: -0.25rem; }
.row.gy-1 > * { margin-top: 0.25rem; }
.row.gy-2 { margin-top: -0.5rem; }
.row.gy-2 > * { margin-top: 0.5rem; }
.row.gy-3 { margin-top: -1rem; }
.row.gy-3 > * { margin-top: 1rem; }
.row.gy-4 { margin-top: -1.5rem; }
.row.gy-4 > * { margin-top: 1.5rem; }
.row.gy-5 { margin-top: -3rem; }
.row.gy-5 > * { margin-top: 3rem; }

@media (min-width: 768px) {
    .row.g-md-0 { margin-right: 0; margin-left: 0; margin-top: 0; }
    .row.g-md-0 > * { padding-right: 0; padding-left: 0; margin-top: 0; }
    .row.g-md-1 { margin-right: -0.25rem; margin-left: -0.25rem; margin-top: -0.25rem; }
    .row.g-md-1 > * { padding-right: 0.25rem; padding-left: 0.25rem; margin-top: 0.25rem; }
    .row.g-md-2 { margin-right: -0.5rem; margin-left: -0.5rem; margin-top: -0.5rem; }
    .row.g-md-2 > * { padding-right: 0.5rem; padding-left: 0.5rem; margin-top: 0.5rem; }
    .row.g-md-3 { margin-right: -1rem; margin-left: -1rem; margin-top: -1rem; }
    .row.g-md-3 > * { padding-right: 1rem; padding-left: 1rem; margin-top: 1rem; }
    .row.g-md-4 { margin-right: -1.5rem; margin-left: -1.5rem; margin-top: -1.5rem; }
    .row.g-md-4 > * { padding-right: 1.5rem; padding-left: 1.5rem; margin-top: 1.5rem; }
    .row.g-md-5 { margin-right: -3rem; margin-left: -3rem; margin-top: -3rem; }
    .row.g-md-5 > * { padding-right: 3rem; padding-left: 3rem; margin-top: 3rem; }
}

/* ---------- Flex gap utilities ---------- */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }

/* ---------- Logical margin/padding (ms-*, me-*, ps-*, pe-*) ---------- */
.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-5 { margin-left: 3rem !important; }
.ms-auto { margin-left: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-5 { margin-right: 3rem !important; }
.me-auto { margin-right: auto !important; }

.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }
.ps-4 { padding-left: 1.5rem !important; }
.ps-5 { padding-left: 3rem !important; }

.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.pe-4 { padding-right: 1.5rem !important; }
.pe-5 { padding-right: 3rem !important; }

/* ---------- Text alignment (BS5 names) ---------- */
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }

/* ---------- Font size / weight utilities ---------- */
.fs-1 { font-size: calc(1.375rem + 1.5vw) !important; }
.fs-2 { font-size: calc(1.325rem + 0.9vw) !important; }
.fs-3 { font-size: calc(1.3rem + 0.6vw) !important; }
.fs-4 { font-size: calc(1.275rem + 0.3vw) !important; }
.fs-5 { font-size: 1.25rem !important; }
.fs-6 { font-size: 1rem !important; }

.fw-light { font-weight: 300 !important; }
.fw-lighter { font-weight: lighter !important; }
.fw-normal { font-weight: 400 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bolder { font-weight: bolder !important; }

.fst-italic { font-style: italic !important; }
.fst-normal { font-style: normal !important; }

/* ---------- Border radius scale (BS5) ---------- */
.rounded-0 { border-radius: 0 !important; }
.rounded-1 { border-radius: 0.125rem !important; }
.rounded-2 { border-radius: 0.25rem !important; }
.rounded-3 { border-radius: 0.5rem !important; }
.rounded-4 { border-radius: 1rem !important; }
.rounded-5 { border-radius: 2rem !important; }

/* ---------- Display / misc utilities ---------- */
.d-grid { display: grid !important; }
.d-inline-grid { display: inline-grid !important; }

/* The BS5 pattern "d-grid d-md-flex" (stacked buttons on mobile, a row on
   desktop) needs the responsive flex utilities to out-rank .d-grid — they
   come later in this file than sb-admin-2's copies, so re-declare them. */
@media (min-width: 576px) {
    .d-sm-flex { display: flex !important; }
    .d-sm-inline-flex { display: inline-flex !important; }
}

@media (min-width: 768px) {
    .d-md-flex { display: flex !important; }
    .d-md-inline-flex { display: inline-flex !important; }
}

@media (min-width: 992px) {
    .d-lg-flex { display: flex !important; }
    .d-lg-inline-flex { display: inline-flex !important; }
}

@media (min-width: 1200px) {
    .d-xl-flex { display: flex !important; }
    .d-xl-inline-flex { display: inline-flex !important; }
}

.overflow-auto { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-scroll { overflow: scroll !important; }
.overflow-visible { overflow: visible !important; }

.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }
.text-decoration-line-through { text-decoration: line-through !important; }

/* ---------- Screen-reader only (BS5 name) ---------- */
.visually-hidden,
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap !important;
    border: 0 !important;
}

/* ---------- Close button (BS5) ---------- */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    color: #000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.375rem;
    opacity: 0.5;
}

.btn-close:hover { opacity: 0.75; }
.btn-close:focus { outline: 0; box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25); opacity: 1; }

/* ---------- DataTables controls sized like the app ---------- */
.dataTables_wrapper .dataTables_filter input {
    height: 34px;
    padding: 0.3rem 0.7rem;
    margin-left: 0.5rem;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-color, #3b82f6);
}

.dataTables_wrapper .dataTables_length select {
    height: 34px;
    padding: 0.3rem 1.75rem 0.3rem 0.65rem;
    margin: 0 0.5rem;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat right 0.6rem center/14px 10px;
}
