﻿/* 
PSEUDOCODE (detailed plan):
1. Detect the "value selected" state on the floating Select2 control:
   - The wrapper gains the class `.select2-has-value` when an option is selected.
   - The wrapper gains the class `.select2-focused` when focused.
2. When `.form-floating` has `.select2-has-value` OR `.select2-focused`:
   - Reduce the top padding of the `.select2-selection` so the content aligns visually with a floated label.
   - Reduce `min-height` slightly to reflect the compact floating-label appearance.
3. Apply separate adjustments for single-select and multi-select variants:
   - Single-select: smaller overall height and reduced top padding.
   - Multi-select: reduce `padding-top` to bring tags/values up while keeping room for multiple lines.
4. Keep the original default styles for the non-selected state unchanged.
5. Implement the changes as CSS overrides placed after the original rule so they take precedence.
*/

/* Original default style (kept as baseline) */
.form-floating .select2-container--bootstrap-5 .select2-selection {
    min-height: calc(3.5rem + 2px);
    padding: 1.5rem 0.75rem 0 0.75rem;
    /*border: 1px solid #dee2e6;*/
    border-radius: 0.375rem;
    /*background-color: #fff;*/
}

/* When a value is selected or the control is focused, reduce padding/height to match floated label */
.form-floating.select2-has-value .select2-container--bootstrap-5 .select2-selection,
.form-floating.select2-focused .select2-container--bootstrap-5 .select2-selection {
    /* Reduce top padding so selection text sits closer to the floated label */
   /* padding: 1.2rem 0.75rem 0 0.75rem;*/
    /* Slightly smaller min-height to reflect the compact state */
    /*min-height: calc(2.25rem + 2px);*/
}

/* Multi-select variant: adjust top padding for tags so they align under the floated label */
.form-floating.select2-has-value .select2-container--bootstrap-5 .select2-selection--multiple,
.form-floating.select2-focused .select2-container--bootstrap-5 .select2-selection--multiple {
    padding-top: 1.5rem;
    padding-bottom: 0.375rem;
}

/* Keep rendered area spacing consistent when value present */
.form-floating.select2-has-value .select2-container--bootstrap-5 .select2-selection__rendered,
.form-floating.select2-focused .select2-container--bootstrap-5 .select2-selection__rendered {
    padding: 0.10rem 1.5rem 0.1rem 0.10rem !important;
    margin-right: 1rem;
}

/* Optional: ensure the label float transition remains smooth (no changes required, kept for clarity) */
.form-floating.select2-has-value > label,
.form-floating.select2-focused > label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.85rem) translateX(0.15rem);
}

/* Ensure label is positioned correctly */
/*.select2-form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem 0.75rem;
    overflow: hidden;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
}*/

/* Adjust Select2 dropdown positioning */
.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #dee2e6;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/*.select2-selection__clear {
    top: 60% !important;
}*/

.select2-selection__rendered {
    margin-right: 1.25rem;
}

/* apply only when there is no value (placeholder is present) */
/*.select2-selection__rendered:has(.select2-selection__placeholder) {
    padding: 0.10rem 1.5rem 0.1rem 0.10rem;
}*/

/* Fallback for browsers that don't support :has()
Style the placeholder element itself so the visual matches when empty */
.select2-selection__rendered:not(:has(.select2-selection__placeholder)) {
    /*background-color: var(--bs-body-bg);*/
    /*border: solid 1px var(--md-sys-color-primary-fixed-dim);*/
    border-radius: 0.25rem;
    color: var(--md-sys-color-on-primary-container);
    display: inline-block; /* ensures the background is visible */
    padding: 0.10rem 1.5rem 0.1rem 0.10rem !important;
}
/*.select2-selection__rendered {
    background-color: var(--md-sys-color-primary-container);
    border: solid 1px var(--md-sys-color-primary-fixed-dim);
    border-radius: 0.25rem;
    margin-right: 1rem;
    padding: 0.10rem 1.5rem 0.1rem 0.10rem !important;
}*/

.select2-search__field {
    width: 100% !important;
    min-width: 100% !important; /* or your desired value */
    max-width: 100% !important;
}

.accessibility-skip-link {
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 2147483647;
    padding: .75rem 1rem;
    background: var(--md-sys-color-surface, white);
    color: var(--md-sys-color-on-surface, black);
    border: 2px solid currentColor;
    transform: translateY(-200%);
}

.accessibility-skip-link:focus {
    transform: translateY(0);
}

#page-content:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: -2px;
}
