/* ============================================================================
   Global form-control styling — native <select> and Select2 widgets.

   Loaded by every base template (panel / admin / claims / credentials) so that
   dropdowns share one polished, theme-aware look. Colours come from Bootstrap
   CSS variables (--bs-*), so the styling follows light/dark mode automatically.

   Page-specific overrides that use higher specificity or !important (e.g. the
   compact filters in admin/logs.css) continue to win, so this file only sets a
   sensible global baseline.
   ========================================================================== */

:root {
    --fx-field-bg: var(--bs-gray-100, #f5f8fa);
    --fx-field-bg-hover: var(--bs-gray-200, #eef1f5);
    --fx-field-border: var(--bs-gray-300, #dbe0ea);
    --fx-field-text: var(--bs-gray-800, #3f4254);
    --fx-field-muted: var(--bs-gray-500, #99a1b7);
    --fx-field-radius: 0.725rem;
    --fx-field-height: calc(1.5em + 1.65rem + 2px);
    --fx-field-focus-ring: 0 0 0 0.2rem rgba(var(--bs-primary-rgb, 1, 107, 178), 0.18);
}

/* ── Native <select> ─────────────────────────────────────────────────────── */
.form-select {
    border-radius: var(--fx-field-radius);
    border: 1px solid var(--fx-field-border);
    color: var(--fx-field-text);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
    background-position: right 1rem center;
    cursor: pointer;
}

.form-select:hover {
    border-color: var(--bs-primary, #016bb2);
}

.form-select:focus {
    border-color: var(--bs-primary, #016bb2);
    box-shadow: var(--fx-field-focus-ring);
}

/* Solid variant: borderless until interacted with, soft fill. */
.form-select.form-select-solid {
    background-color: var(--fx-field-bg);
    border-color: transparent;
}

.form-select.form-select-solid:hover {
    background-color: var(--fx-field-bg-hover);
    border-color: transparent;
}

.form-select.form-select-solid:focus {
    background-color: var(--fx-field-bg);
    border-color: var(--bs-primary, #016bb2);
}

/* ── Select2 (Metronic bootstrap5 theme) ─────────────────────────────────── */
.select2-container--bootstrap5 .select2-selection {
    min-height: var(--fx-field-height);
    border-radius: var(--fx-field-radius) !important;
    border: 1px solid var(--fx-field-border);
    background-color: var(--fx-field-bg);
    color: var(--fx-field-text);
    display: flex;
    align-items: center;
    padding: 0.25rem 2.5rem 0.25rem 1rem;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.select2-container--bootstrap5 .select2-selection:hover {
    background-color: var(--fx-field-bg-hover);
    border-color: var(--bs-primary, #016bb2);
}

/* Open / focused */
.select2-container--bootstrap5.select2-container--focus .select2-selection,
.select2-container--bootstrap5.select2-container--open .select2-selection {
    background-color: var(--fx-field-bg);
    border-color: var(--bs-primary, #016bb2);
    box-shadow: var(--fx-field-focus-ring);
    outline: none;
}

.select2-container--bootstrap5 .select2-selection--single .select2-selection__rendered {
    padding: 0;
    color: var(--fx-field-text);
    font-weight: 500;
    line-height: 1.5;
}

.select2-container--bootstrap5 .select2-selection__placeholder {
    color: var(--fx-field-muted);
    font-weight: 400;
}

/* Custom chevron, vertically centred */
.select2-container--bootstrap5 .select2-selection--single .select2-selection__arrow {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
}

.select2-container--bootstrap5 .select2-selection--single .select2-selection__arrow b {
    border: none;
    width: 0.6rem;
    height: 0.6rem;
    margin: 0;
    transform: translateY(-2px) rotate(45deg);
    border-right: 2px solid var(--fx-field-muted);
    border-bottom: 2px solid var(--fx-field-muted);
    transition: transform .15s ease;
}

.select2-container--bootstrap5.select2-container--open .select2-selection__arrow b {
    transform: translateY(2px) rotate(-135deg);
}

/* Clear (×) button */
.select2-container--bootstrap5 .select2-selection__clear {
    color: var(--fx-field-muted);
    font-weight: 700;
    margin-right: 0.4rem;
    transition: color .15s ease;
}

.select2-container--bootstrap5 .select2-selection__clear:hover {
    color: var(--bs-danger, #d9214e);
}

/* Multi-select chips */
.select2-container--bootstrap5 .select2-selection--multiple {
    padding: 0.3rem 0.6rem;
}

.select2-container--bootstrap5 .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(var(--bs-primary-rgb, 1, 107, 178), 0.1);
    color: var(--bs-primary, #016bb2);
    border: none;
    border-radius: 0.5rem;
    padding: 0.15rem 0.55rem;
    font-weight: 500;
}

.select2-container--bootstrap5 .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--bs-primary, #016bb2);
    border: none;
}

/* ── Dropdown panel ──────────────────────────────────────────────────────── */
.select2-container--bootstrap5 .select2-dropdown {
    border: 1px solid var(--fx-field-border);
    border-radius: var(--fx-field-radius);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    padding: 0.35rem;
    background-color: var(--bs-body-bg, #ffffff);
}

.select2-container--bootstrap5 .select2-search--dropdown {
    padding: 0.25rem 0.25rem 0.45rem;
}

.select2-container--bootstrap5 .select2-search--dropdown .select2-search__field {
    border-radius: 0.55rem;
    border: 1px solid var(--fx-field-border);
    background-color: var(--fx-field-bg);
    color: var(--fx-field-text);
    padding: 0.5rem 0.75rem;
    outline: none;
}

.select2-container--bootstrap5 .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--bs-primary, #016bb2);
    box-shadow: var(--fx-field-focus-ring);
}

.select2-container--bootstrap5 .select2-results__option {
    border-radius: 0.55rem;
    padding: 0.55rem 0.75rem;
    color: var(--fx-field-text);
    font-weight: 500;
    transition: background-color .12s ease, color .12s ease;
}

.select2-container--bootstrap5 .select2-results__option--highlighted,
.select2-container--bootstrap5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--bs-primary, #016bb2);
    color: #ffffff;
}

.select2-container--bootstrap5 .select2-results__option--selected,
.select2-container--bootstrap5 .select2-results__option[aria-selected="true"] {
    background-color: rgba(var(--bs-primary-rgb, 1, 107, 178), 0.12);
    color: var(--bs-primary, #016bb2);
}

.select2-container--bootstrap5 .select2-results__option--selected.select2-results__option--highlighted {
    background-color: var(--bs-primary, #016bb2);
    color: #ffffff;
}
