/**
 * Gletra sticky sidebar / rail layout (cart, customer, checkout, shop)
 * Same behavior as admin dashboard side columns.
 */
:root {
    --gc-sticky-top: 88px;
    --gc-sticky-max-height: calc(100vh - 104px);
}

body.admin-shell {
    --gc-sticky-top: 72px;
    --gc-sticky-max-height: calc(100vh - 88px);
}

@media (min-width: 992px) {
    .gletra-cart-grid,
    .gletra-layout-with-rail,
    .dashboard-three-col-row,
    .row.g-3:has(.gc-sticky-col),
    .row.g-4:has(.gc-sticky-col),
    .row.g-4:has(.customer-sidebar),
    .row.g-4:has(#customerSidebar) {
        align-items: flex-start;
    }

    .gc-sticky-rail,
    .gc-sticky-col,
    .gletra-cart-grid > aside,
    .dashboard-three-col-row > .col-left,
    .dashboard-three-col-row > .col-right,
    .row > .col-lg-3:has(.customer-sidebar),
    .row > .col-lg-3:has(#customerSidebar),
    .row > .col-lg-4.gc-sticky-col,
    .row > .col-md-4.gc-sticky-col {
        position: -webkit-sticky;
        position: sticky;
        top: var(--gc-sticky-top);
        align-self: flex-start;
        z-index: 5;
        max-height: var(--gc-sticky-max-height);
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    .gc-sticky-rail::-webkit-scrollbar,
    .gc-sticky-col::-webkit-scrollbar,
    .gletra-cart-grid > aside::-webkit-scrollbar,
    .dashboard-three-col-row > .col-left::-webkit-scrollbar,
    .dashboard-three-col-row > .col-right::-webkit-scrollbar,
    .row > .col-lg-3:has(.customer-sidebar)::-webkit-scrollbar,
    .row > .col-lg-3:has(#customerSidebar)::-webkit-scrollbar {
        width: 5px;
    }

    .gc-sticky-rail::-webkit-scrollbar-thumb,
    .gc-sticky-col::-webkit-scrollbar-thumb,
    .gletra-cart-grid > aside::-webkit-scrollbar-thumb,
    .dashboard-three-col-row > .col-left::-webkit-scrollbar-thumb,
    .dashboard-three-col-row > .col-right::-webkit-scrollbar-thumb,
    .row > .col-lg-3:has(.customer-sidebar)::-webkit-scrollbar-thumb,
    .row > .col-lg-3:has(#customerSidebar)::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 999px;
    }

    /* Cart / checkout summary rail — fill viewport, no empty gap below */
    .gc-sticky-rail,
    .gletra-cart-grid > aside.gc-sticky-rail,
    .gletra-cart-grid > aside,
    .row > .col-lg-3:has(.customer-sidebar),
    .row > .col-lg-3:has(#customerSidebar),
    .row > .col-lg-4.gc-sticky-col,
    .row > .col-md-4.gc-sticky-col {
        min-height: var(--gc-sticky-max-height);
        box-sizing: border-box;
    }

    /* Inner cards stick with the rail, not independently */
    .gc-sticky-rail .gc-price-card--sticky,
    .gc-sticky-col .gc-price-card--sticky,
    .gc-sticky-rail .gc-card--sticky,
    .gc-sticky-col .gc-card--sticky {
        position: static;
        top: auto;
        max-height: none;
    }

    /* Standalone sticky gc cards (when not inside a sticky rail) */
    .gc-card.gc-card--sticky,
    .gc-price-card.gc-price-card--sticky {
        position: -webkit-sticky;
        position: sticky;
        top: var(--gc-sticky-top);
        z-index: 5;
        align-self: flex-start;
    }

    /* Product page gallery column */
    .dp-page-layout {
        align-items: flex-start;
    }

    .dp-gallery-sticky {
        position: -webkit-sticky;
        position: sticky;
        top: var(--gc-sticky-top);
        z-index: 5;
        align-self: flex-start;
    }

    .checkout-summary-card.gc-sticky-col,
    .row > .col-md-4.gc-sticky-col > .checkout-summary-card.sticky-top {
        position: static !important;
        top: auto !important;
    }
}

@media (max-width: 991.98px) {
    .gc-sticky-rail,
    .gc-sticky-col,
    .gletra-cart-grid > aside,
    .dashboard-three-col-row > .col-left,
    .dashboard-three-col-row > .col-right,
    .gc-card.gc-card--sticky,
    .gc-price-card.gc-price-card--sticky,
    .dp-gallery-sticky {
        position: static !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
}
