/*
 * Django 5.2 rewrote the filter_horizontal / filter_vertical widget markup:
 * the panel headings are now <div class="selector-*-title"> containing a
 * <label> and a <p class="helptext">, and every control (the arrows, "Choose
 * all", "Remove all") is a <button> instead of an <a>. djangocms-admin-style
 * 3.3.1 still targets the old <h2>/<a> markup, so Django's default blue
 * "Chosen" header shows through and the theme's generic `button` rule
 * (padding: 6px 20px !important, border, white background) mangles the
 * arrow and choose/remove-all buttons.
 *
 * This restyles the new markup to match the rest of the admin theme. It is
 * loaded after djangocms-admin.css (see templates/admin/base_site.html), and
 * uses !important where the theme does.
 */

.selector .selector-available,
.selector .selector-chosen {
    padding: 0 !important;
    overflow: hidden;
}

/* Panel headings */
.selector .selector-available-title,
.selector .selector-chosen-title {
    background: var(--dca-gray-super-lightest) !important;
    color: var(--dca-gray) !important;
    border: none !important;
    border-bottom: 1px solid var(--dca-gray-lighter) !important;
    border-radius: 0 !important;
    padding: 10px !important;
}

.selector .selector-available-title label,
.selector .selector-chosen-title label {
    display: block;
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
    color: var(--dca-gray) !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 20px;
    text-transform: uppercase !important;
}

.selector .selector-available-title .helptext,
.selector .selector-chosen-title .helptext {
    display: block;
    margin: 4px 0 0;
    color: var(--dca-gray-light) !important;
    font-size: 12px !important;
    line-height: 16px;
    text-align: left;
}

/* Filter inputs */
.selector .selector-filter {
    display: block;
    width: auto !important;
    margin: 0;
    padding: 8px 10px !important;
    border: none !important;
    border-bottom: 1px solid var(--dca-gray-lighter) !important;
}

.selector .selector-filter label {
    display: none !important;
}

.selector .selector-filter input {
    width: 100% !important;
    margin: 0 !important;
}

/* Lists */
.selector select[multiple] {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
}

/* The "x of y selected" footer Django shows while the chosen list is filtered */
.selector .selector-chosen .list-footer-display {
    margin: 0;
    border: none;
    border-top: 1px solid var(--dca-gray-lighter);
    border-radius: 0;
    background: var(--dca-gray-super-lightest);
    color: var(--dca-gray);
    font-size: 12px;
}

.selector .selector-chosen .list-footer-display__clear {
    color: var(--dca-primary);
}

/* Arrow buttons between the panels */
.selector ul.selector-chooser {
    align-self: center;
    width: 30px !important;
    height: auto;
    margin: 0 5px !important;
    padding: 0;
    transform: none;
    background: none !important;
    border-radius: 0;
}

.selector .selector-chooser li {
    float: none;
    padding: 3px 0;
}

.selector button.selector-add,
.selector button.selector-remove {
    display: block;
    width: 24px !important;
    height: 24px !important;
    margin: 0 auto;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: none !important;
    color: var(--dca-gray-light) !important;
    font-size: 0 !important;
    line-height: 24px;
    text-indent: 0;
    overflow: visible;
    opacity: 1;
}

.selector button.selector-add:before,
.selector button.selector-remove:before {
    font-size: 22px;
    line-height: 24px;
    margin: 0;
}

.selector button.selector-add:enabled,
.selector button.selector-remove:enabled {
    color: var(--dca-primary) !important;
}

/* "Choose all" / "Remove all" */
.selector button.selector-chooseall,
.selector button.selector-clearall {
    display: block;
    align-self: stretch;
    width: 100% !important;
    height: auto !important;
    margin: 0;
    padding: 8px 10px !important;
    border: none !important;
    border-top: 1px solid var(--dca-gray-lighter) !important;
    border-radius: 0 !important;
    background: var(--dca-white) !important;
    color: var(--dca-gray-light) !important;
    font-size: 12px !important;
    line-height: 14px;
    text-align: center;
    opacity: 1;
}

.selector button.selector-chooseall:enabled,
.selector button.selector-clearall:enabled {
    color: var(--dca-primary) !important;
}

.selector button.selector-chooseall:enabled:hover,
.selector button.selector-clearall:enabled:hover {
    background: var(--dca-gray-super-lightest) !important;
}

.selector button.selector-chooseall:before,
.selector button.selector-clearall:before {
    color: inherit;
    font-size: 14px;
    vertical-align: -2px;
}

/* Narrow screens: Django stacks the two panels vertically and puts the two
   arrows side by side between them (admin-style swaps the glyphs to up/down). */
@media (max-width: 767px) {
    .selector ul.selector-chooser {
        display: flex;
        justify-content: center;
        width: 60px !important;
        margin: 0 auto !important;
    }

    .selector .selector-chooser li {
        padding: 0 3px;
    }
}
