/* =========================================================================
   Marketplace (pages/marketplace.php)
   Shared cards, rails, banner and toast come from home-page.css (.bh-*).
   ========================================================================= */

/* ---------- Head ---------- */
.bmk-head {
    padding: 26px 0 18px;
    background:
        radial-gradient(ellipse 60% 80% at 100% 0%, rgba(249, 115, 22, 0.22), transparent 60%),
        linear-gradient(135deg, #021A54 0%, #0b2f86 100%);
    color: #fff;
}

.bmk-head__row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.bmk-head h1 {
    margin: 0 0 4px;
    font-family: 'Plus Jakarta Sans', 'Poppins', sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

.bmk-head p {
    margin: 0;
    font-size: 14px;
    color: #cbd5e1;
}

.bh .bmk-location {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 280px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bh .bmk-location:hover {
    background: rgba(255, 255, 255, 0.18);
}

.bmk-location > i:first-child {
    color: #fdba74;
}

.bmk-location > i:last-child {
    font-size: 10px;
    color: #cbd5e1;
}

.bmk-location span {
    display: grid;
    min-width: 0;
    line-height: 1.2;
}

.bmk-location small {
    font-size: 11px;
    color: #cbd5e1;
}

.bmk-location strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.bmk-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 36px -20px rgba(0, 0, 0, 0.5);
}

.bmk-search > i {
    position: absolute;
    left: 20px;
    z-index: 1;
    color: var(--bh-muted);
    pointer-events: none;
}

.bmk-search .bmz-autocomplete-wrap {
    flex: 1;
    min-width: 0;
}

.bh .bmk-search input[type="search"] {
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 12px 0 42px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--bh-ink);
    font-family: inherit;
    font-size: 16px;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.bh .bmk-search button {
    height: 46px;
    padding: 0 22px;
    border: none;
    border-radius: 12px !important;
    background: var(--bh-orange);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.bh .bmk-search button:hover {
    background: var(--bh-orange-2);
}

/* ---------- Category chips ---------- */
.bmk-cats {
    position: sticky;
    top: var(--bnav-offset, 0px);
    z-index: 30;
    background: rgba(241, 245, 249, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--bh-line);
}

.bmk-cats__row {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.bmk-cats__row::-webkit-scrollbar {
    display: none;
}

.bmk-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 7px 14px;
    border: 1px solid var(--bh-line);
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.bmk-chip span {
    padding: 0 6px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--bh-muted);
    font-size: 11px;
}

.bmk-chip:hover {
    border-color: var(--bh-navy);
}

.bmk-chip.is-active {
    border-color: var(--bh-navy);
    background: var(--bh-navy);
    color: #fff;
}

.bmk-chip.is-active span {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.bmk-banner-wrap {
    padding-top: 18px;
}

/* ---------- Flash sale ---------- */
.bmk-flash {
    padding: 16px 16px 6px;
    border-radius: 18px;
    background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 45%, #ea580c 100%);
}

.bmk-flash__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 12px;
    color: #fff;
}

.bmk-flash__head > div:first-child {
    flex: 1;
    min-width: 0;
}

.bmk-flash__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fde68a;
}

.bmk-flash h2 {
    margin: 2px 0 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.bmk-countdown {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #fecaca;
}

.bmk-countdown span {
    margin-right: 4px;
}

.bmk-countdown b {
    min-width: 34px;
    padding: 5px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.bmk-countdown i {
    font-style: normal;
    font-weight: 800;
    color: #fff;
}

.bmk-flash__all {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.bmk-flash__all:hover {
    text-decoration: underline;
}

/* ---------- Browse layout ---------- */
.bmk-browse {
    scroll-margin-top: calc(var(--bnav-offset, 0px) + 60px);
}

.bmk-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

/* Filters */
.bmk-filters {
    position: sticky;
    top: calc(var(--bnav-offset, 0px) + 70px);
}

.bmk-filters__backdrop,
.bmk-filters__head .bmk-filters__close {
    display: none;
}

.bmk-filters__panel {
    display: grid;
    gap: 4px;
    max-height: calc(100vh - var(--bnav-offset, 0px) - 90px);
    overflow-y: auto;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--bh-line);
    scrollbar-width: thin;
}

.bmk-filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bmk-filters__head h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--bh-ink);
}

.bmk-fg {
    margin: 0;
    padding: 12px 0;
    border: none;
    border-bottom: 1px solid #eef2f6;
}

.bmk-fg legend {
    float: left;
    width: 100%;
    margin-bottom: 8px;
    padding: 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bh-muted);
}

.bmk-fg__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    clear: both;
}

.bh .bmk-fg input[type="text"],
.bh .bmk-fg input[type="number"] {
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: var(--bh-ink);
    font-family: inherit;
    font-size: 14px;
}

.bh .bmk-fg input:focus {
    outline: none;
    border-color: var(--bh-navy);
    box-shadow: 0 0 0 3px rgba(2, 26, 84, 0.12);
}

.bh .bmk-linkbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    color: var(--bh-navy);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.bmk-linkbtn.is-busy {
    opacity: 0.6;
    pointer-events: none;
}

.bmk-options {
    display: grid;
    gap: 2px;
    clear: both;
}

.bmk-options--scroll {
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.bmk-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
}

.bmk-option:hover {
    background: var(--bh-soft);
}

.bmk-option input {
    accent-color: var(--bh-navy);
}

.bmk-option span {
    flex: 1;
    min-width: 0;
}

.bmk-option em {
    font-size: 12px;
    font-style: normal;
    color: #94a3b8;
}

.bmk-option:has(input:checked) {
    background: var(--bh-hover, #eef2ff);
    color: var(--bh-navy);
    font-weight: 700;
}

.bmk-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.bh .bmk-preset {
    padding: 5px 10px;
    border: 1px solid var(--bh-line);
    border-radius: 999px !important;
    background: #fff;
    color: #334155;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.bh .bmk-preset:hover,
.bh .bmk-preset.is-active {
    border-color: var(--bh-navy);
    color: var(--bh-navy);
    background: #eef2ff;
}

.bmk-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    clear: both;
    padding: 6px 0;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
}

.bmk-switch input {
    width: 16px;
    height: 16px;
    accent-color: var(--bh-navy);
}

.bmk-filters__actions {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    padding-top: 12px;
}

.bmk-filters__actions .bmk-btn {
    white-space: nowrap;
}

/* Buttons */
.bh .bmk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px !important;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.bh .bmk-btn--primary {
    background: var(--bh-navy);
    color: #fff;
}

.bh .bmk-btn--primary:hover {
    background: var(--bh-navy-2);
}

.bh .bmk-btn--ghost {
    background: #fff;
    border-color: var(--bh-line);
    color: var(--bh-navy);
}

.bh .bmk-btn--ghost:hover {
    border-color: var(--bh-navy);
}

/* Results */
.bmk-results {
    min-width: 0;
}

.bmk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.bmk-toolbar__left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.bmk-toolbar__left h2 {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--bh-ink);
}

.bmk-toolbar__left span {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--bh-muted);
}

.bmk-toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.bmk-filter-btn {
    display: none !important;
}

.bmk-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--bh-orange);
    color: #fff;
    font-size: 11px;
}

.bmk-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--bh-line);
    border-radius: 12px;
    background: #fff;
}

.bmk-sort label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--bh-muted);
}

.bmk-sort select {
    height: 34px;
    padding: 0 6px;
    border: none;
    background: transparent;
    color: var(--bh-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.bmk-sort select:focus {
    outline: 2px solid var(--bh-navy);
    outline-offset: 2px;
    border-radius: 6px;
}

.bmk-active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.bmk-active__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--bh-navy);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.bmk-active__chip i {
    font-size: 11px;
}

.bmk-active__chip:hover {
    background: #e0e7ff;
}

.bmk-active__clear {
    color: var(--bh-muted);
    font-size: 13px;
    font-weight: 600;
}

/* Grid (cards come from home-page.css) */
.bmk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.bmk-grid .bh-card {
    min-width: 0;
}

.bmk-grid .bh-card.is-new {
    animation: bmk-in 0.3s ease both;
}

@keyframes bmk-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.bmk-more {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-top: 22px;
}

.bmk-more__btn {
    min-width: 240px;
}

.bmk-more__btn.is-busy {
    pointer-events: none;
    opacity: 0.7;
}

.bmk-more__note {
    font-size: 12px;
    color: var(--bh-muted);
}

/* With JavaScript the "Load more" button replaces the page numbers. */
.js-bmk .bmk-pager {
    display: none;
}

.bmk-pager {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.bmk-pager a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--bh-line);
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-weight: 700;
    text-decoration: none;
}

.bmk-pager a.is-active {
    border-color: var(--bh-navy);
    background: var(--bh-navy);
    color: #fff;
}

.bmk-empty {
    padding: 48px 20px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--bh-line);
    text-align: center;
    color: var(--bh-muted);
}

.bmk-empty > i {
    display: block;
    margin-bottom: 12px;
    font-size: 38px;
    color: #cbd5e1;
}

.bmk-empty h3 {
    margin: 0 0 6px;
    font-size: 1.15rem;
    color: var(--bh-ink);
}

.bmk-empty p {
    margin: 0 0 16px;
    font-size: 14px;
}

/* ---------- Tablet & phone: filters become a bottom sheet ---------- */
@media (max-width: 1024px) {
    .bmk-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .bmk-filter-btn {
        display: inline-flex !important;
    }

    .bmk-filters {
        position: fixed;
        inset: 0;
        z-index: 2600;
        visibility: hidden;
        pointer-events: none;
    }

    .bmk-filters.is-open {
        visibility: visible;
        pointer-events: auto;
    }

    .bmk-filters__backdrop {
        position: absolute;
        inset: 0;
        display: block;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .bmk-filters.is-open .bmk-filters__backdrop {
        opacity: 1;
    }

    .bmk-filters__panel {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 88vh;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom));
        border-radius: 20px 20px 0 0;
        border: none;
        transform: translateY(100%);
        transition: transform 0.25s ease;
    }

    .bmk-filters.is-open .bmk-filters__panel {
        transform: none;
    }

    .bmk-filters__head {
        position: sticky;
        top: 0;
        z-index: 2;
        margin: 0 -16px;
        padding: 16px 16px 12px;
        background: #fff;
        border-bottom: 1px solid var(--bh-line);
    }

    .bmk-filters__head::before {
        content: "";
        position: absolute;
        top: 6px;
        left: 50%;
        width: 40px;
        height: 4px;
        border-radius: 999px;
        background: #cbd5e1;
        transform: translateX(-50%);
    }

    .bh .bmk-filters__head .bmk-filters__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 50% !important;
        background: var(--bh-soft);
        color: var(--bh-ink);
        font-size: 16px;
        cursor: pointer;
    }

    .bmk-filters__actions {
        position: sticky;
        bottom: calc(-16px - env(safe-area-inset-bottom));
        margin: 0 -16px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--bh-line);
    }

    .bmk-options--scroll {
        max-height: none;
    }
}

body.bmk-filters-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .bmk-head {
        padding: 18px 0 14px;
    }

    .bmk-head__row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 12px;
    }

    .bmk-head p {
        font-size: 13px;
    }

    .bh .bmk-location {
        max-width: none;
        padding: 7px 12px;
    }

    .bmk-location > i:last-child {
        margin-left: auto;
    }

    .bmk-search {
        padding: 4px;
        border-radius: 14px;
    }

    .bmk-search > i {
        left: 16px;
    }

    .bh .bmk-search input[type="search"] {
        height: 42px;
        padding-left: 36px;
    }

    .bh .bmk-search button {
        height: 42px;
        padding: 0 14px;
        font-size: 14px;
    }

    .bmk-chip {
        padding: 6px 12px;
        font-size: 12px;
    }

    .bmk-flash {
        margin: 0 -12px;
        padding: 14px 12px 4px;
        border-radius: 0;
    }

    .bmk-flash .bh-rail {
        margin: 0 -12px;
    }

    .bmk-flash h2 {
        font-size: 1.05rem;
    }

    .bmk-countdown b {
        min-width: 28px;
        padding: 4px;
        font-size: 14px;
    }

    .bmk-flash__all {
        display: none;
    }

    .bmk-toolbar {
        flex-wrap: wrap;
    }

    .bmk-toolbar__left {
        width: 100%;
        justify-content: space-between;
    }

    .bmk-toolbar__left h2 {
        font-size: 1.1rem;
    }

    .bmk-toolbar__right {
        display: grid;
        grid-template-columns: 1fr 1.4fr;
        width: 100%;
    }

    .bh .bmk-btn {
        min-height: 40px;
        padding: 0 12px;
        font-size: 13px;
    }

    .bmk-sort {
        height: 40px;
        min-width: 0;
    }

    .bmk-sort label span {
        display: none;
    }

    .bmk-sort select {
        flex: 1;
        min-width: 0;
        font-size: 13px;
    }

    .bmk-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .bmk-more__btn {
        width: 100%;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bmk-filters__panel,
    .bmk-filters__backdrop,
    .bmk-grid .bh-card.is-new {
        transition: none;
        animation: none;
    }
}
