/*
 * Product listings (categories, manufacturers, search, new products, specials): the ♥ wishlist
 * button on cards, and on phones a two-column grid with the first products on the first
 * screen. Linked from app/includes/styles.php. Category-page rules are scoped to
 * .kt-category-page, set in app/includes/home/nested.php and home/products.php.
 */

.kt-card-media {
    position: relative;
}

.kt-wishlist-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    color: #e0475b;
    font-size: 22px;
    line-height: 40px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.kt-wishlist-btn:hover,
.kt-wishlist-btn:focus-visible {
    transform: scale(1.1);
}

.kt-wishlist-btn:focus-visible {
    outline: 2px solid #2a7bd4;
    outline-offset: 2px;
}

.kt-wishlist-btn[aria-busy="true"] {
    opacity: 0.6;
}

.kt-wishlist-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10000;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: 8px;
    background: #2f3640;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transform: translateX(-50%);
}

.kt-wishlist-toast a {
    margin-left: 8px;
    color: #ffd54f;
    text-decoration: underline;
}

.kt-wishlist-toast.is-error {
    background: #c0392b;
}

/*
 * The "Разгледайте също" box (seo_internal_links.php) sits in a floated column. Without clearing
 * it, the next row (with the "Раздели" toggle) starts underneath it and, being drawn on top,
 * catches taps meant for the box's links.
 */
.kt-category-page > .row {
    clear: both;
}

@media (max-width: 767px) {
    /* Heading area: products, not headings, on the first screen. */
    .kt-category-page h1 {
        margin: 6px 0 8px;
        font-size: 22px;
        line-height: 1.25;
    }

    /* The breadcrumb stays one line and scrolls sideways (its row already allows it). */
    body:has(.kt-category-page) h4.header-navigation,
    body:has(.kt-category-page) h4.header-navigation span {
        white-space: nowrap !important;
    }

    body:has(.kt-category-page) h4.header-navigation {
        font-size: 13px;
    }

    /* Only the "Списък на продуктите" heading table: the page links are a table too. */
    .kt-category-page .kt-category-image,
    .kt-category-page .kt-listing-heading {
        display: none;
    }

    .kt-category-page h2[onclick] {
        margin: 2px 0 8px;
        font-size: 18px;
    }

    /* Page links under the products: the count above them, both centred. */
    #product-list-results ~ table td {
        display: block;
        text-align: center !important;
    }

    #product-list-results ~ table .pagination {
        margin: 6px 0 12px;
    }

    /* Two products per row. */
    #product-list-results .infoBox {
        display: flex;
        flex-wrap: wrap;
        padding: 0;
    }

    #product-list-results .infoBox .row {
        display: contents;
    }

    #product-list-results .infoBoxContents {
        width: 50%;
        padding: 6px 4px 14px;
    }

    #product-list-results .infoBoxContents > .col-md-12 {
        padding: 0;
    }

    #product-list-results .productListing-data {
        font-size: 13px;
        line-height: 1.35;
    }

    #product-list-results .kt-wishlist-btn {
        top: 2px;
        right: 2px;
        width: 36px;
        height: 36px;
        font-size: 20px;
        line-height: 36px;
    }
}

/*
 * Filter and sort box (src/templates/storefront/ListingFilters.html, behaviour in
 * src/js/category-listing.js). Wide screens: the filters sit open above the products in three
 * columns. Phones: a bar with "Филтри" and the sort menu, "Филтри" floating over the products
 * once the bar scrolls away; the filters open as a full-screen sheet with the
 * "Покажи продуктите" button always in reach.
 */
.kt-lf {
    --kt-lf-green: #429f59;
    --kt-lf-green-dark: #2f7d43;
    --kt-lf-line: #dfe5da;
    --kt-lf-ink: #2f3a28;
    margin-bottom: 12px;
    text-align: left;
}

.kt-lf-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.kt-lf-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 2px solid var(--kt-lf-green);
    border-radius: 999px;
    background: #fff;
    color: var(--kt-lf-green-dark);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.kt-lf-open[aria-expanded="true"],
.kt-lf-open:hover {
    background: var(--kt-lf-green);
    color: #fff;
}

.kt-lf-open:focus-visible,
.kt-lf-range:focus-visible,
.kt-lf-more:focus-visible,
.kt-lf-close:focus-visible,
.kt-lf-chip:focus-visible {
    outline: 3px solid #2a7bd4;
    outline-offset: 2px;
}

.kt-lf-badge {
    display: inline-block;
    min-width: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #e0475b;
    color: #fff;
    font-size: 13px;
    line-height: 22px;
    text-align: center;
}

.kt-lf-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.kt-lf-sort-label {
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
}

.kt-lf-sort select {
    min-height: 44px;
    border-radius: 8px;
}

.kt-lf-panel {
    margin-bottom: 10px;
    border: 1px solid var(--kt-lf-line);
    border-radius: 12px;
    background: #fff;
    color: var(--kt-lf-ink);
}

.kt-lf-panel.is-collapsed,
.kt-lf-head,
.kt-lf-apply-phone {
    display: none;
}

.kt-lf-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 4px 24px;
    padding: 16px 18px 4px;
}

.kt-lf-section {
    min-width: 0;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.kt-lf-legend {
    width: auto;
    margin: 0 0 8px;
    border: 0;
    color: var(--kt-lf-ink);
    font-size: 16px;
    font-weight: 700;
}

.kt-lf-legend-count {
    color: var(--kt-lf-green-dark);
}

.kt-lf-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.kt-lf-range {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--kt-lf-line);
    border-radius: 999px;
    background: #f6f8f4;
    color: var(--kt-lf-ink);
    font-size: 14px;
    cursor: pointer;
}

.kt-lf-range[aria-pressed="true"] {
    border-color: var(--kt-lf-green);
    background: var(--kt-lf-green);
    color: #fff;
}

.kt-lf-price-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.kt-lf-price-inputs label {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-weight: 400;
}

.kt-lf-price-caption {
    display: block;
    font-size: 13px;
    color: #66705f;
}

.kt-lf-price-inputs input {
    min-height: 44px;
    border-radius: 8px;
    font-size: 16px;
}

.kt-lf-price-dash,
.kt-lf-price-unit {
    padding-bottom: 11px;
}

.kt-lf-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
    font-weight: 600;
    cursor: pointer;
}

.kt-lf-switch input {
    position: absolute;
    opacity: 0;
}

.kt-lf-switch-track {
    position: relative;
    flex: none;
    width: 46px;
    height: 26px;
    border-radius: 13px;
    background: #c9d1c3;
    transition: background 0.15s ease;
}

.kt-lf-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

.kt-lf-switch input:checked + .kt-lf-switch-track {
    background: var(--kt-lf-green);
}

.kt-lf-switch input:checked + .kt-lf-switch-track::after {
    transform: translateX(20px);
}

.kt-lf-switch input:focus-visible + .kt-lf-switch-track {
    outline: 3px solid #2a7bd4;
    outline-offset: 2px;
}

.kt-lf-search {
    min-height: 40px;
    margin-bottom: 6px;
    border-radius: 8px;
    font-size: 16px;
}

.kt-lf-options {
    margin: 0;
    padding: 0;
    list-style: none;
}

.kt-lf-option {
    padding-left: calc(var(--kt-lf-depth, 0) * 16px);
}

.kt-lf-option label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

.kt-lf-option input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--kt-lf-green);
}

.kt-lf-options:not(.is-expanded) .kt-lf-option.is-extra,
.kt-lf-option.is-hidden {
    display: none;
}

.kt-lf-options.is-searching .kt-lf-option.is-extra:not(.is-hidden) {
    display: block;
}

.kt-lf-more {
    margin-top: 4px;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--kt-lf-green-dark);
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.kt-lf-no-match {
    margin: 4px 0;
    color: #66705f;
}

.kt-lf-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--kt-lf-line);
}

.kt-lf-foot .btn {
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 700;
}

.kt-lf-apply {
    border-color: var(--kt-lf-green);
    background: var(--kt-lf-green);
}

.kt-lf-apply:hover,
.kt-lf-apply:focus {
    border-color: var(--kt-lf-green-dark);
    background: var(--kt-lf-green-dark);
}

.kt-lf-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
}

.kt-lf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: #e6f2e8;
    color: var(--kt-lf-green-dark);
    font-weight: 600;
    text-decoration: none;
}

.kt-lf-chip:hover,
.kt-lf-chip:focus {
    background: #d2e8d6;
    color: var(--kt-lf-green-dark);
    text-decoration: none;
}

.kt-lf-chip span {
    font-size: 18px;
    line-height: 1;
}

.kt-lf-chip-clear {
    padding: 0 6px;
    color: #66705f;
    text-decoration: underline;
}

@media (max-width: 767px) {
    .kt-lf {
        margin-bottom: 4px;
    }

    .kt-lf-bar {
        margin-bottom: 8px;
    }

    .kt-lf-open {
        flex: 1;
        justify-content: center;
    }

    .kt-lf-open[aria-expanded="true"] {
        background: #fff;
        color: var(--kt-lf-green-dark);
    }

    /* Once the bar has scrolled away, "Филтри" floats at the bottom over the products. */
    .kt-lf.is-floating .kt-lf-open {
        position: fixed;
        left: 50%;
        bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 1000;
        flex: none;
        background: var(--kt-lf-green);
        color: #fff;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
        transform: translateX(-50%);
    }

    .kt-lf.is-floating .kt-lf-sort {
        margin-left: 0;
    }

    .kt-lf-sort {
        flex: 1;
        min-width: 0;
    }

    .kt-lf-sort-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .kt-lf-sort select {
        width: 100%;
        font-size: 16px;
    }

    /* The sheet. */
    .kt-lf-panel,
    .kt-lf-panel.is-collapsed {
        display: none;
    }

    .kt-lf.is-open .kt-lf-panel {
        position: fixed;
        inset: 0;
        /* Above the header and the cookie notice. */
        z-index: 10001;
        display: flex;
        flex-direction: column;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .kt-lf-head {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: space-between;
        padding: 6px 6px 6px 18px;
        border-bottom: 1px solid var(--kt-lf-line);
    }

    .kt-lf-title {
        margin: 0;
        font-size: 20px;
        font-weight: 700;
    }

    .kt-lf-close {
        width: 48px;
        height: 48px;
        border: 0;
        background: none;
        color: var(--kt-lf-ink);
        font-size: 32px;
        line-height: 1;
    }

    .kt-lf-body {
        display: block;
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 16px 18px;
    }

    .kt-lf-section {
        margin-bottom: 22px;
    }

    .kt-lf-option label {
        min-height: 44px;
        font-size: 16px;
    }

    .kt-lf-foot {
        flex: none;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .kt-lf-foot .btn {
        min-height: 48px;
        font-size: 16px;
    }

    .kt-lf-clear {
        flex: 1;
    }

    .kt-lf-apply {
        flex: 2;
    }

    .kt-lf-apply-phone {
        display: inline;
    }

    .kt-lf-apply-wide {
        display: none;
    }

    /* Chips scroll sideways in one row instead of pushing the products down. */
    .kt-lf-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -15px 6px;
        padding: 0 15px 4px;
        scrollbar-width: none;
    }

    .kt-lf-chips li {
        flex: none;
    }

    html.kt-lf-locked,
    html.kt-lf-locked body {
        overflow: hidden;
    }
}
