/* ---------------------------------------------------------------------------
   Searchable dropdown (gd-ss)

   Replaces the browser's native <select> panel, which on a 60 item brand list
   is a bare OS menu with no way to search. The native <select> stays in the
   DOM, hidden, so forms still submit it and existing change listeners keep
   firing - only the panel is ours.

   Markup: <div class="select-wrapper"><select class="modern-select">...</select></div>
   Behaviour: public/scripts/gd-select.js

   Lifted out of cars_modul/frontend/includes/top_banner_search_2.blade.php so
   every search card can use the same one.
   --------------------------------------------------------------------------- */

/* The pages that used to style .modern-select inline still do; this file only
   owns the dropdown itself. */

/* ===== Searchable Custom Dropdown ===== */
/* Native select stays in the DOM (so the form still submits it) but is hidden */
.gd-ss-native {
    position: absolute !important;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}

/* Hide the CSS chevron; the trigger draws its own */
.select-wrapper.gd-ss-ready::after {
    display: none;
}

.gd-ss-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}

.gd-ss-trigger .gd-ss-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gd-ss-trigger.is-placeholder .gd-ss-value {
    color: #94a3b8;
}

.gd-ss-trigger .gd-ss-caret {
    flex: none;
    color: #64748b;
    transition: transform 0.2s ease;
}

.gd-ss-trigger[aria-expanded="true"] {
    border-color: #6366f1;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.gd-ss-trigger[aria-expanded="true"] .gd-ss-caret {
    transform: rotate(180deg);
}

.gd-ss-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(320px, 88vw);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
    padding: 8px;
    z-index: 1200;
    display: none;
}

.gd-ss-panel.is-open {
    display: block;
}

.gd-ss-panel.align-right {
    left: auto;
    right: 0;
}

.gd-ss-panel.drop-up {
    top: auto;
    bottom: calc(100% + 6px);
}

.gd-ss-search-wrap {
    position: relative;
    margin-bottom: 6px;
}

/* !important: global resets in the shared stylesheets reset input box metrics */
.gd-ss-panel .gd-ss-search {
    width: 100% !important;
    height: 38px !important;
    padding: 0 12px 0 34px !important;
    margin: 0 !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-family: inherit;
    line-height: 36px !important;
    color: #334155 !important;
    outline: none !important;
    box-shadow: none;
}

.gd-ss-panel .gd-ss-search:focus {
    border-color: #6366f1 !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

.gd-ss-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.gd-ss-list {
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.gd-ss-panel .gd-ss-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px !important;
    border-radius: 9px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
    white-space: nowrap;
}

.gd-ss-option.is-active {
    background: #f1f5f9;
}

.gd-ss-option.is-selected {
    color: #4f46e5;
    font-weight: 600;
}

.gd-ss-option .gd-ss-check {
    flex: none;
    opacity: 0;
    color: #4f46e5;
}

.gd-ss-option.is-selected .gd-ss-check {
    opacity: 1;
}

.gd-ss-empty {
    padding: 14px 12px;
    font-size: 13px;
    color: #94a3b8;
    text-align: center;
}
