/*
 * Copyright (c) 2026.  SimplyMetadata LLC
 *
 * The list / gallery page bar (macros/list_bar.html), shared by busterapp
 * and archiveapp: buttons on the left, the search row on the right; on
 * mobile the buttons stack above the search row. Colours come from the
 * app's variables: the archive names (--surface-card, --hairline, --brand,
 * --brand-tint, --brand-strong, --surface-canvas) fall back to the shared
 * colors.css ones. The fixed positioning of `.bstr-page-bar nav` stays
 * with each app. `.bstr-list-bar-inline` (busterapp) keeps one row on
 * mobile too.
 */

.bstr-list-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
}

.bstr-nav-controls {
    display: flex;
    align-items: center;
    flex-grow: 1;
    justify-content: space-between;
    gap: 12px;
}

/* ---- Buttons ---- */

.bstr-actions-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.bstr-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    margin: 0 !important;
    background: var(--surface-card, var(--button-bar-bg));
    border: 1px solid var(--hairline, var(--border));
    border-radius: 999px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 550;
    line-height: 1;
    text-decoration: none !important;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease,
                transform 100ms ease;
}

/* Icons match the submit / more buttons' 24px (the selector outranks the
   apps' generic icon sizing) */
.bstr-list-nav .bstr-action-btn i {
    font-size: 24px;
    margin: 0;
    color: var(--brand, var(--accent));
}

.bstr-action-btn:hover {
    background: var(--brand-tint, var(--accent-bg));
    border-color: color-mix(in srgb, var(--brand, var(--accent)) 40%,
                            var(--hairline, var(--border)));
    color: var(--brand-strong, var(--accent-hover));
    transform: translateY(-1px);
}

.bstr-action-btn:hover i {
    color: var(--brand-strong, var(--accent-hover));
}

/* Icon-only bars (busterapp): round buttons, no labels */
.bstr-list-nav-icons .btn-label {
    display: none;
}

.bstr-list-nav-icons .bstr-action-btn {
    width: 38px;
    padding: 0;
}

/* Single icon-only buttons in a labelled bar (the Refresh button) */
.bstr-action-btn-icon {
    width: 38px;
    padding: 0;
}

/* ---- Search row ---- */

.bstr-search-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    justify-content: flex-end;
}

/* The search box is a fixed size, except on narrow single-row bars (below) */
.bstr-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    width: 220px;
}

.bstr-search-input-wrapper .search-icon {
    position: absolute;
    left: 12px;
    color: var(--pico-muted-color, #777);
    font-size: 18px;
    pointer-events: none;
}

.bstr-search-input-wrapper input[type=search] {
    height: 38px;
    width: 100%;
    border: 1px solid var(--hairline, var(--border));
    border-radius: 999px;
    background: var(--surface-canvas, var(--input-bg));
    padding: 0 14px 0 34px !important;
    margin: 0 !important;
    font-size: 0.88rem;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.bstr-search-input-wrapper input[type=search]:focus {
    border-color: var(--brand, var(--accent));
    box-shadow: 0 0 0 3px var(--brand-tint, var(--accent-bg));
    background: var(--surface-card, var(--input-bg));
}

.bstr-search-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px !important;
    height: 38px !important;
    flex-shrink: 0;
    background: var(--surface-card, var(--button-bar-bg));
    border: 1px solid var(--hairline, var(--border));
    border-radius: 50%;
    color: var(--brand, var(--accent));
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.bstr-search-submit:hover {
    background: var(--brand-tint, var(--accent-bg));
    border-color: color-mix(in srgb, var(--brand, var(--accent)) 40%,
                            var(--hairline, var(--border)));
    color: var(--brand-strong, var(--accent-hover));
    transform: translateY(-1px);
}

.bstr-more-wrapper {
    flex-shrink: 0;
}

.bstr-more-wrapper details.dropdown.bstr-more {
    margin: 0 !important;
    padding: 0 !important;
    height: auto;
}

.bstr-more-wrapper details.dropdown.bstr-more summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px !important;
    height: 38px !important;
    flex-shrink: 0;
    background: var(--surface-card, var(--button-bar-bg));
    border: 1px solid var(--hairline, var(--border));
    border-radius: 50%;
    color: var(--brand, var(--accent));
    outline: none;
    padding: 0 !important;
    margin: 0 !important;
    transition: background 150ms ease, border-color 150ms ease;
}

.bstr-more-wrapper details.dropdown.bstr-more summary:hover {
    background: var(--brand-tint, var(--accent-bg));
    border-color: color-mix(in srgb, var(--brand, var(--accent)) 40%,
                            var(--hairline, var(--border)));
}

.bstr-more-wrapper details.dropdown.bstr-more summary::after {
    display: none !important;
}

/* ---- Mobile: the buttons above the search row ---- */

@media (max-width: 768px) {
    /* Both rows left-justified */
    .bstr-list-nav {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
    }

    .bstr-nav-controls {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
    }

    /* One row of buttons at their natural width; the row scrolls
       sideways when they don't fit. Sized so four labelled pills (the
       photos list: Gallery, Filter, Columns, Sort) fit a 375px phone. */
    .bstr-actions-group {
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
        gap: 4px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .bstr-actions-group::-webkit-scrollbar {
        display: none;
    }

    .bstr-action-btn {
        flex: 0 0 auto;
        padding: 0 8px;
        font-size: 0.8rem;
        gap: 3px;
        white-space: nowrap;
    }

    .bstr-list-nav-icons .bstr-action-btn,
    .bstr-action-btn-icon {
        flex: 0 0 38px;
        padding: 0;
    }

    /* Stacked bars (archiveapp): both rows right-justified. The button
       row uses an auto margin rather than flex-end so an overflowing row
       still scrolls from its start instead of clipping it. */
    .bstr-list-page-bar:not(.bstr-list-bar-inline) .bstr-actions-group > :first-child {
        margin-left: auto !important;  /* the pill rule zeroes margins */
    }

    .bstr-list-page-bar:not(.bstr-list-bar-inline) .bstr-search-group {
        justify-content: flex-end;
    }

    .bstr-list-bar-inline .bstr-search-group {
        justify-content: flex-start;
    }

    /* Two rows: the page's spacer must clear the taller fixed bar */
    .bstr-list-page-bar:not(.bstr-list-bar-inline) ~ .bstr-spacer {
        height: 108px;
    }

    /* Single-row bars: buttons and the search row stay side by side */
    .bstr-list-bar-inline .bstr-list-nav,
    .bstr-list-bar-inline .bstr-nav-controls {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
    }

    .bstr-list-bar-inline .bstr-actions-group {
        width: auto;
        flex: 0 0 auto;
        overflow: visible;
    }

    /* The search box gives way so the submit and more buttons stay on
       screen on narrow phones */
    .bstr-list-bar-inline .bstr-nav-controls {
        min-width: 0;
    }

    .bstr-list-bar-inline .bstr-search-group {
        flex: 1 1 auto;
        min-width: 0;
    }

    .bstr-list-bar-inline .bstr-search-input-wrapper {
        flex: 1 1 auto;
        width: auto;
        min-width: 80px;
    }
}
