/* ===========================================================================
 * Marketplace (show_all_adverts) responsive masonry grid.
 * Plain CSS (not compiled from LESS) so it applies in dev without lessc.
 * Grid mechanics mirror bump-adaptive-web puzzle.less (15px spacer gutter).
 * ======================================================================== */

/* --- grid container ------------------------------------------------------ */
.marketplaceGrid {
    position: relative;
    margin-left: -15px;
}

/* Container must have NO padding: Masonry makes items position:absolute, whose
 * % width resolves against the padding-box, while the static sizer resolves
 * against the content-box. Any container padding desyncs them (sizer < item),
 * making each item span 2 columns -> everything collapses into one column.
 * (.allAdvertsListBlock ships with padding:10px 20px 10px 30px — override it.) */
.showAllAdvertsWrapper .marketplaceGrid,
.userAdvertsWrapper .marketplaceGrid {
    padding: 0;
}

/* Masonry column sizer — drives the number of columns (3 by default). */
.marketplaceGrid .marketplaceGridSizer,
.marketplaceGrid .puzzle-item {
    width: 33.333%;
    box-sizing: border-box;
}

.marketplaceGrid .marketplaceGridSizer {
    /* sizer is measurement-only, never shown */
    height: 0;
    padding: 0;
    margin: 0;
}

.marketplaceEmpty {
    padding: 20px 0;
    color: #929292;
}

/* --- card ---------------------------------------------------------------- */
.marketplaceCard {
    margin: 0 0 15px 15px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 3px;
    overflow: hidden;
}

.marketplaceCardImage {
    position: relative;
    display: block;
    height: 170px;            /* fixed height -> stable masonry, no reflow on resize */
    background: #f0f0f0;
    overflow: hidden;
    line-height: 0;
}

.marketplaceCardImage a {
    display: block;
    width: 100%;
    height: 100%;
}

.marketplaceCardImage img {
    width: 100%;
    height: 100%;
    object-fit: cover;       /* fill the box, crop overflow; broken images stay boxed */
    vertical-align: top;
}

.marketplaceCardImage .adminContextMenu {
    position: absolute;
    top: 6px;
    right: 6px;
    line-height: 1;
}

.marketplaceCardBody {
    padding: 12px 14px 14px;
    line-height: 1.35;
}

/* price: flat blue text per design (override sprite-based .advertPrice) */
.marketplaceCard .marketplaceCardPrice {
    display: block;
    background: none;
    height: auto;
    padding: 0;
    margin: 0 0 6px;
    color: #2f8fd0;
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: bold;
    line-height: 1.1;
}

.marketplaceCard .marketplaceCardPrice:before,
.marketplaceCard .marketplaceCardPrice:after {
    display: none;
    content: none;
}

.marketplaceCard .marketplaceCardPrice .rur {
    font-size: 15px;
    font-weight: normal;
}

.marketplaceCard .marketplaceCardPrice.freePrice {
    color: #59b001;
}

.marketplaceCardTitle {
    display: block;
    margin: 0 0 10px;
    color: #333;
    font-size: 15px;
    line-height: 1.3;
    text-decoration: none;
}

.marketplaceCardTitle:hover {
    text-decoration: underline;
}

/* author + "Подробнее" on a single bottom line */
.marketplaceCardFooter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.marketplaceCardMeta {
    color: #929292;
    font-size: 11px;
    min-width: 0; /* allow author text to truncate instead of pushing the button */
}

.marketplaceCardMeta .marketplaceCardAuthor {
    color: #929292;
    text-decoration: none;
}

.marketplaceCardMeta .marketplaceCardAuthor:hover {
    text-decoration: underline;
}

.marketplaceCardMeta .marketplaceCardDate {
    margin-top: 2px;
}

.marketplaceCardMore {
    flex: none;
    display: inline-block;
    padding: 5px 14px;
    background: #ededed;
    border-radius: 3px;
    color: #444;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.marketplaceCardMore:hover {
    background: #e2e2e2;
    color: #222;
}

/* --- responsive column count -------------------------------------------- */
/* 3 columns everywhere for now. The page container is still fixed-width and
/* ===========================================================================
 * Fluid layout for the marketplace page ONLY.
 * The desktop shell is fixed at 1000px (helpers.less .base-layout-size()).
 * We override the widths to fluid, but strictly scoped under
 * body.js_marketplacePage (added by show-all-adverts.js), so NO other page is
 * affected. Combined with the viewport meta + the ResizeObserver watcher, the
 * grid then reflows with the window and the filters stack on top on mobile.
 * ======================================================================== */
/* mainWrapper keeps a centered max-width (1000px), set INLINE from JS
 * (_enableFluidPage) because a desktop cascade rule glues max-width on it.
 * On wide screens -> 1000px centered (original desktop look); on narrow
 * screens width:auto collapses it to 100% (fluid). Everything inside is
 * fluid (100% of that max-width). */
body.js_marketplacePage .bump-contentWrapper,
body.js_marketplacePage .bump-pageWrapper,
body.js_marketplacePage .bump-headerWrapper,
body.js_marketplacePage .bump-topPanel,
body.js_marketplacePage .bump-topPanelContent,
body.js_marketplacePage .showAllAdvertsWrapper,
body.js_marketplacePage .shopPageHeader {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

/* main content column takes the remaining width next to the category sidebar */
body.js_marketplacePage .shopContentWrapper {
    float: none !important;
    width: auto !important;
    overflow: hidden !important; /* new BFC: fill space beside the floated sidebar */
    margin: 0 !important;
}

/* keep our own controls from overflowing */
body.js_marketplacePage .js_searByNameInput,
body.js_marketplacePage .shopContentWrapper input[type="text"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* mobile: filters stack on top, full width */
@media (max-width: 768px) {
    body.js_marketplacePage .shopCategoryMenuWrapper {
        float: none !important;
        width: auto !important;
        margin: 0 0 15px 0 !important;
    }
}

/* ===========================================================================
 * Left menu — Price block restyle to match the mockup (marketplace only).
 * Flat grey header, no grey plates, light bordered min/max fields, and a
 * radio list of price ranges instead of the old "free" checkbox.
 * ======================================================================== */

/* no collapse arrows on the marketplace menu */
.showAllAdvertsWrapper .accordionMenuOpener { display: none !important; }

/* "Цена" header like the category header */
.showAllAdvertsWrapper .accordionMenuHeader.js_menuBlockPrice {
    background: none !important;
    border-bottom: none !important;
    height: auto !important;
    padding: 14px 0 6px !important;
}
.showAllAdvertsWrapper .accordionMenuHeader.js_menuBlockPrice span {
    color: #8a8a8a !important;
    font-size: 13px !important;
    font-weight: normal !important;
    padding: 0 !important;
    float: none !important;
}

/* price min/max row: no grey plate, light bordered inputs */
.showAllAdvertsWrapper .pricesSelectorWrapper {
    background: none !important;
    padding: 0 !important;
    overflow: visible !important;
}
.showAllAdvertsWrapper .pricesSelectorWrapper > div {
    background: #fff !important;
    border: 1px solid #ccc !important;
    border-radius: 3px !important;
    float: left !important;
    margin: 0 8px 0 0 !important;
    padding: 6px 8px !important;
}
.showAllAdvertsWrapper .pricesSelectorWrapper > span {
    float: left;
    line-height: 32px;
    margin-right: 8px;
    color: #999;
}
.showAllAdvertsWrapper .pricesSelectorWrapper input {
    border: none !important;
    width: 55px !important;
    background: none !important;
    padding: 0 !important;
}

/* hide the old "free" checkbox — the mockup uses range radios instead */
.showAllAdvertsWrapper .forFreePriceFilter { display: none !important; }

/* price range radio list */
.showAllAdvertsWrapper .priceRanges {
    clear: both;
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
}
.showAllAdvertsWrapper .priceRanges li { margin: 0 0 9px; }
.showAllAdvertsWrapper .priceRanges label {
    display: block;
    color: #777;
    font-size: 13px;
    cursor: pointer;
}
.showAllAdvertsWrapper .priceRanges input[type="radio"] {
    margin: 0 8px 0 0;
    vertical-align: middle;
    width: 15px !important;
}

/* ===========================================================================
 * Spacing & alignment polish (marketplace page only).
 *   - the search box and the sort row align flush with the card grid: the old
 *     markup bakes a 29px indent into .productSearchPanel (padding-left) and
 *     .shopShowControlBlock (margin-left), so the search looked shifted;
 *   - a gap between the category panel and the content column;
 *   - inner padding for the category/price panel (the wrapper supplies the
 *     side gutter, so the per-item left indent is dropped).
 * All scoped under .showAllAdvertsWrapper — no other page is affected.
 * ======================================================================== */

/* search row: flat (no grey bar) and aligned to the grid */
.showAllAdvertsWrapper .productSearchPanel {
    padding-left: 0 !important;
    padding-right: 0 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* sort/order row: drop the legacy 29px indent, add a little breathing room */
.showAllAdvertsWrapper .shopShowControlBlock {
    margin-left: 0 !important;
    margin-top: 16px !important;
}

/* gap between the left panel and the content column + inner panel padding */
.showAllAdvertsWrapper .shopCategoryMenuWrapper {
    margin-right: 24px !important;
    box-sizing: border-box !important;
    padding: 6px 16px 18px !important;
}

/* the wrapper now supplies the side gutter -> drop the per-item left indent */
.showAllAdvertsWrapper .js_advertCategories span,
.showAllAdvertsWrapper .js_shopCategories span {
    padding-left: 0 !important;
}
.showAllAdvertsWrapper .js_advertCategories ul ul span,
.showAllAdvertsWrapper .js_shopCategories ul ul span {
    padding-left: 14px !important;
}
.showAllAdvertsWrapper .pricesSelectorWrapper {
    padding-left: 0 !important;
}

/* ===========================================================================
 * Fluid layout for the profile adverts tab ONLY (show_user_adverts).
 * The desktop shell is fixed at 1000px; we relax it to a centered max-width
 * and let the two columns reflow. Everything is gated behind
 * body.js_userAdvertsPage (added by show-user-adverts.js _enableFluidPage),
 * so no other profile tab or page is touched. Combined with the viewport meta
 * and the grid's ResizeObserver, the cards reflow with the window and the
 * columns stack on mobile.
 * ======================================================================== */
body.js_userAdvertsPage #topPanel,
body.js_userAdvertsPage .bump-topPanel,
body.js_userAdvertsPage .bump-topPanelContent,
body.js_userAdvertsPage .bump-profileImageWrapper,
body.js_userAdvertsPage .bump-userInfoWrapper,
body.js_userAdvertsPage .bump-profileCover,
body.js_userAdvertsPage .bump-contentWrapper,
body.js_userAdvertsPage .bump-headerWrapper,
body.js_userAdvertsPage .bump-contentPage,
body.js_userAdvertsPage .bump-columnsWrapper {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

/* the cover's decorative shadow is a fixed 1000px :after — keep it inside */
body.js_userAdvertsPage .bump-profileCover:after {
    width: 100% !important;
}

/* two fluid columns: list fills the rest, controls stay a fixed 250px */
body.js_userAdvertsPage .bump-leftColumn {
    box-sizing: border-box !important;
    width: calc(100% - 270px) !important;
}
body.js_userAdvertsPage .bump-rightColumn {
    box-sizing: border-box !important;
    width: 250px !important;
}

/* mobile: stack the columns full width, controls (right column) on top so the
 * "Все объявления" / create buttons don't end up below the whole list */
@media (max-width: 768px) {
    body.js_userAdvertsPage .bump-columnsWrapper {
        display: flex !important;
        flex-direction: column !important;
    }
    body.js_userAdvertsPage .bump-rightColumn {
        order: -1 !important;
        float: none !important;
        width: 100% !important;
    }
    body.js_userAdvertsPage .bump-leftColumn {
        order: 0 !important;
        float: none !important;
        width: 100% !important;
    }
}
