/* ── Toolbar wrapper ── */
.ybsb-toolbar-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center; /* self-centers vertically when a parent row
                                 stretches this widget's column taller than
                                 its own content - e.g. next to a Search Bar
                                 widget of a different natural height */
    height: 100%;
}

/* Elementor gives every widget its own Advanced > Background/Border panel
   on .elementor-widget-container, completely separate from this plugin's
   own Style controls. If that panel has anything set, it renders as a
   second, sharp-cornered box sitting behind the dropdown trigger's own
   rounded background - the "two boxes" effect. This widget's look is
   fully owned by the Style tab controls above, so the native panel is
   neutralized here. */
.elementor-widget-ybsb_toolbar > .elementor-widget-container {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.ybsb-toolbar-main-row {
    display: flex;
    align-items: stretch; /* every element in the row (sort, layout switcher)
                              matches the height of the tallest sibling */
    flex-wrap: wrap;
}

/* ── Divider between Sort and Layout Switcher ── */
.ybsb-toolbar-divider {
    align-self: center;
    flex-shrink: 0;
    border-left-width: 1px;
    border-left-style: solid;
}

/* ── Sort container ── */
.ybsb-toolbar-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ybsb-toolbar-sort-label {
    white-space: nowrap;
}

/* ── Custom dropdown wrapper ── */
.ybsb-toolbar-select-wrap {
    position: relative;
    min-width: 0; /* the Dropdown Width control sets the real size now -
                     a hardcoded floor here would silently fight it */
    flex-shrink: 1;
    z-index: 1; /* Only needs to clear siblings inside the toolbar row */
}

/* Raised only while the dropdown is actually open, and only far enough to
   clear the rest of the toolbar - never fights page-level elements like a
   sticky navbar. */
.ybsb-toolbar-select-wrap.is-open {
    z-index: 20;
}

/* ── Trigger button (visible selected value) ── */
.ybsb-toolbar-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 30px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 12px; /* match your control default */
    background-color: #fff;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ybsb-toolbar-select-trigger-text {
    display: block;
    line-height: 1; /* matches the arrow icon's own line-height so both
                        sit on the same visual baseline */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Keep border radius on hover */
.ybsb-toolbar-select-trigger:hover {
    background-color: #f9f9f9;
    border-radius: 12px; /* keep the radius */
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease,
                transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ybsb-toolbar-select-trigger:focus-visible {
    outline: 2px solid #d9381e;
    outline-offset: 2px;
}

/* ── Arrow ── */
.ybsb-toolbar-select-arrow {
    display: flex;
    align-items: center;
    line-height: 1;
    transition: transform 0.25s ease, color 0.2s ease;
    pointer-events: none;
}

.ybsb-toolbar-select-arrow svg {
    display: block;
    width: 1em;
    height: 0.6em;
}

/* Arrow rotates ONLY when dropdown is OPEN */
.ybsb-toolbar-select-wrap.is-open .ybsb-toolbar-select-arrow {
    transform: rotate(180deg);
}

/* ── Dropdown options list ── */
.ybsb-toolbar-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 2; /* Stacks above the trigger within the wrap's own context */
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px; /* match your control */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-6px);
}

.ybsb-toolbar-select-wrap.is-open .ybsb-toolbar-select-options {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ── Individual options ── */
.ybsb-toolbar-select-option {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ybsb-toolbar-select-option:hover,
.ybsb-toolbar-select-option:focus {
    background-color: #f0f0f0;
}

.ybsb-toolbar-select-option.is-selected {
    font-weight: 600;
    background-color: #f0f0f0;
}

/* ── Hidden native select (keeps the original logic) ── */
.ybsb-toolbar-select-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    white-space: nowrap !important;
}

/* ── Layout switcher ── */
.ybsb-toolbar-layout-switcher {
    display: flex;
    align-items: stretch; /* buttons fill the full height of the row */
    gap: 6px;
}

.ybsb-toolbar-layout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    aspect-ratio: 1 / 1; /* keeps Grid and List the same square size,
                             regardless of how wide their own icon glyph
                             happens to render */
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.25s ease,
                color 0.25s ease,
                transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.ybsb-toolbar-layout-btn:not(.ybsb-active):hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ybsb-toolbar-layout-btn.ybsb-active {
    transform: none;
    box-shadow: none;
}

.ybsb-toolbar-layout-btn svg,
.ybsb-toolbar-layout-btn i {
    display: block;
}