
/* =========================================
   KRISHICARE CATEGORY PAGE
   Compatible with AJAX navigation
========================================= */

/* Page height */
html,
body {
    height: 100%;
    min-height: 0;
}

    /* Category page detection */
    body:has(.mobile-app #pageContent > .catalog) {
        overflow: hidden;
    }

/* =========================================
   MOBILE APP SHELL
========================================= */

.mobile-app:has(#pageContent > .catalog) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
}

    /* AJAX container fills available space */
    .mobile-app:has(#pageContent > .catalog) #mobilePageContainer {
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        height: 0;
        min-height: 0;
        min-width: 0;
        overflow: hidden;
    }

    /* Page content */
    .mobile-app:has(#pageContent > .catalog) #pageContent {
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        min-width: 0;
        overflow: hidden;
    }

        /* Header, if present inside page content */
        .mobile-app:has(#pageContent > .catalog) #pageContent > .app-header {
            flex: 0 0 auto;
            position: relative;
            z-index: 10;
        }

/* =========================================
   MAIN CATEGORY LAYOUT
========================================= */

.mobile-app #pageContent > .catalog {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px;
    flex: 1 1 0;
    width: 100%;
    height: 0;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 12px 10px 12px 0;
}

/* =========================================
   CATEGORY SIDEBAR
========================================= */

.mobile-app .subcategory-panel {
    min-height: 0;
    height: 100%;
    border-radius: 0 10px 0 0;
    overflow: hidden;
}

.mobile-app .subcategory-list {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 0 12px;
}

    .mobile-app .subcategory-list::-webkit-scrollbar {
        display: none;
    }

.mobile-app .subcategory {
    position: relative;
    width: 100%;
    min-height: 114px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
    font-size: 12px;
    line-height: 1.25;
    font-weight: 700;
    color: #191919;
    cursor: pointer;
}

    .mobile-app .subcategory.active:before {
        content: "";
        position: absolute;
        left: 0;
        top: 14px;
        bottom: 14px;
        width: 7px;
        background: var(--green);
    }

.mobile-app .sub-image {
    width: 70px;
    height: 62px;
    display: grid;
    place-items: center;
}

    .mobile-app .sub-image img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

/* =========================================
   PRODUCTS AREA
========================================= */

.mobile-app .products-area {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.mobile-app .results-row {
    flex: 0 0 auto;
    font-size: 10px;
    margin-bottom: 5px;
}

/* =========================================
   PRODUCT GRID
========================================= */

.mobile-app #productGrid.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-rows: max-content;
    align-content: start;
    align-items: stretch;
    gap: 12px;
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 1px 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-y;
}

    .mobile-app #productGrid.product-grid::-webkit-scrollbar {
        display: none;
    }

/* =========================================
   PRODUCT CARDS
========================================= */

.mobile-app #productGrid > .kc-product-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    max-width: 100%;
    flex: none;
    align-self: stretch;
    overflow: hidden;
}

    /* Product image */
    .mobile-app #productGrid > .kc-product-card > .kc-product-image {
        display: block;
        position: relative;
        flex: 0 0 auto;
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
        overflow: hidden;
    }

        .mobile-app #productGrid > .kc-product-card > .kc-product-image > img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

/* Product information */
.mobile-app #productGrid .kc-product-info {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    min-width: 0;
    padding: 4px 4px 6px;
}

.mobile-app #productGrid .kc-product-origin,
.mobile-app #productGrid .kc-product-name,
.mobile-app #productGrid .kc-product-price,
.mobile-app #productGrid .kc-product-unit {
    position: static;
    visibility: visible;
    opacity: 1;
}

.mobile-app #productGrid .kc-product-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    min-height: 30px;
    margin: 0 0 5px;
}

.mobile-app #productGrid .kc-product-action {
    display: block;
    flex: 0 0 auto;
    margin-top: auto;
}

/* =========================================
   FIXED BOTTOM NAVIGATION
========================================= */

.mobile-app:has(#pageContent > .catalog) > .bottom-navigation {
    position: fixed;
    z-index: 100;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
}

/* =========================================
   RESPONSIVE
========================================= */

@media (max-width: 420px) {

    .mobile-app #pageContent > .catalog {
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 8px;
    }
}

@media (max-width: 350px) {

    .mobile-app #pageContent > .catalog {
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 7px;
    }
}

@media (min-width: 600px) {

    .mobile-app:has(#pageContent > .catalog) {
        margin: 0 auto;
    }

        .mobile-app:has(#pageContent > .catalog) > .bottom-navigation {
            position: absolute;
        }
}

/* Hide filtered products */
#productGrid > .kc-product-card[hidden] {
    display: none !important;
}


/* Category sidebar */
.mobile-app #pageContent > .catalog > .subcategory-panel {
    display: flex;
    flex-direction: column;
    width: 112px;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

/* Independently scrollable category list */
.mobile-app .subcategory-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    scrollbar-width: none;
}

    .mobile-app .subcategory-list::-webkit-scrollbar {
        display: none;
    }

/* Category buttons */
.mobile-app .subcategory {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    width: 100%;
    min-height: 114px;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
    pointer-events: auto;
    cursor: pointer;
}
