/* Responsive adjustments for storefront/account/checkout */

@media (max-width: 1200px) {
    .header-main {
        padding-bottom: 1rem;
    }

    #header .header-gradient-bar .dummy-menu {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .header-main .header-search .form-control {
        max-width: 100%;
    }

    body.account_body .card-account .card-body {
        padding: 1.5rem 1.5rem;
    }

    #account-address .account-address-card {
        padding: 1rem 1.15rem 1rem 1.5rem;
    }
}

@media (max-width: 1400px) {
    #product-search .product-container.product-grid-5,
    #product-category .product-container.product-grid-5,
    #product-manufacturer .product-container.product-grid-5 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1200px) {
    #product-search .product-container.product-grid-5,
    #product-category .product-container.product-grid-5,
    #product-manufacturer .product-container.product-grid-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 992px) {
    #product-search .product-container.product-grid-5,
    #product-category .product-container.product-grid-5,
    #product-manufacturer .product-container.product-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    #product-search .product-container.product-grid-5,
    #product-category .product-container.product-grid-5,
    #product-manufacturer .product-container.product-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---- Category toolbar: stop horizontal overflow on mobile ---- */
@media (max-width: 767.98px) {
    #product-category .top-pagination {
        row-gap: 12px;
    }
    /* sort + pagination columns each take the full row and stack */
    #product-category .top-pagination > .col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* pagination + view-toggle column: allow wrapping, keep on screen */
    #product-category .top-pagination > .col-sm-6.text-end {
        flex-wrap: wrap;
        justify-content: space-between !important;
        gap: 10px;
    }
    #product-category .top-pagination .pagination-wrap {
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
    }
    #product-category .top-pagination .pagination {
        flex-wrap: wrap;
    }
    #product-category .btn-sorting {
        width: 100%;
    }
    /* shrink the grid/list toggle so it fits */
    #product-category .view-toggle {
        margin-left: 0;
        flex: 0 0 auto;
    }
    #product-category .view-toggle__btn {
        width: 38px;
        height: 38px;
    }
    #product-category .view-toggle__btn svg {
        width: 18px;
        height: 18px;
    }
    /* bottom pagination row: stack and center */
    #product-category .pagination-wrap.row > .col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
        text-align: center !important;
    }
}

@media (max-width: 992px) {
    #logo {
        padding-top: 0;
    }

    #header .m_header-logo img {
        max-height: 50px;
    }

    #header .m_header-main {
        position: sticky;
        top: 0;
        z-index: 1050;
        background: #fff;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
        padding: 0.5rem 0.75rem 0.65rem;
    }

    #header .m_header-main .header-main-wrapper {
        align-items: center;
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    #header .m_header-trigger {
        flex: 0 0 auto;
    }

    #header .m_header-logo {
        flex: 1 1 auto;
        display: flex;
        justify-content: center;
    }

    #header .m_header-logo img {
        max-height: 50px;
        width: auto;
    }

    #header .m_header-icons {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 0.35rem 0.55rem;
    }

    #header .m_header-icons a {
        width: 30px;
        height: 30px;
        background: #f3f4f6;
        border: 1px solid #e6e6e6;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    #header .m_header-icons .header-search-b2b,
    #header .m_header-icons .header-search-btn {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        margin-top: 0.35rem;
    }

    #header .m_header-icons .header-search-b2b #search-b2b,
    #header .m_header-icons .header-search-btn {
        width: 100%;
        justify-content: flex-start;
        background: #fff;
        border: 1px solid #e6e6e6;
        border-radius: 999px;
        padding: 0.4rem 0.75rem;
    }

    #header .m_header-icons .header-search-b2b #search-b2b input {
        height: 34px;
        font-size: 0.85rem;
        background: transparent;
        border: 0;
        padding: 0;
    }

    #header .m_header-icons .header-search-b2b .header-search-submit,
    #header .m_header-icons .header-search-btn i {
        font-size: 0.95rem;
    }

    nav[aria-label="breadcrumb"],
    .breadcrumb {
        display: none !important;
    }
    .header-main {
        padding-bottom: 0.85rem;
    }

    .header-main .header-main-wrapper {
        flex-wrap: wrap;
    }

    .header-main .header-logo,
    .header-main .header-main-block {
        flex: 1 1 100%;
        display: flex;
        justify-content: center;
    }

    .header-main .header-logo #logo img {
        max-width: 180px;
        height: auto;
    }

    .header-main .btn-new-order {
        width: 100%;
        justify-content: center;
    }

    .header-main .header-search {
        display: block !important;
        width: 100%;
        margin-top: 0.5rem;
        order: 3;
    }

    .header-main .header-search .header-top-bar-block {
        width: 100%;
    }

    .header-main .header-utilities {
        display: flex !important;
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
        margin-top: 0.5rem;
        order: 4;
    }

    #header .header-gradient-bar {
        max-height: none;
    }

    #header .header-gradient-bar .dummy-menu {
        gap: 0.5rem 1rem;
        padding: 0.5rem;
    }

    #account-account .row,
    #account-address .row {
        row-gap: 1rem;
    }

    #account-account .col-12.col-sm-4,
    #account-address .col-12.col-sm-4 {
        order: 0;
    }

    #account-account .col-12.col-sm-8,
    #account-address .col-12.col-sm-8 {
        order: 1;
    }

    body.account_body .card-account .card-body {
        padding: 1.25rem 1.25rem;
    }

    #checkout-checkout .checkout-wrap {
        grid-template-columns: 1fr;
    }

    #checkout-checkout #mini_cart.card-cart {
        position: static;
        top: auto;
    }
}

@media (max-width: 768px) {
    .header-main .header-main-wrapper {
        gap: 0.5rem;
    }

    .account-wrap.container-xxl {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .account-list-group .list-group-item {
        padding: 0.65rem 0.85rem;
        font-size: 0.92rem;
    }

    .account-list-group .list-group-item i {
        font-size: 0.95rem;
    }

    .header-main .header-search input,
    .header-main .header-search .form-control {
        height: 36px;
    }

    #header .header-gradient-bar .dummy-menu-item {
        font-size: 0.8rem;
    }

    #account-address .account-address-card {
        padding: 0.95rem 1rem 0.95rem 1.35rem;
    }

    #account-account .account-intro-link {
        margin-top: 0.4rem;
    }

    #checkout-checkout .card-checkout,
    #checkout-checkout .card-cart {
        border-radius: 0.5rem;
    }

    #checkout-checkout .form-check {
        flex-wrap: wrap;
    }
}

@media (max-width: 767px) {
    /* Product gallery: main image first, thumbnails in a horizontal row below */
    body.product-product .product-gallery-grid,
    body.product_product .product-gallery-grid {
        flex-direction: column;
    }

    body.product-product .product-gallery-main,
    body.product_product .product-gallery-main {
        order: 1;
        min-height: 280px;
    }

    body.product-product .product-gallery-thumbs,
    body.product_product .product-gallery-thumbs {
        order: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
}

@media (max-width: 576px) {
    .header-main {
        padding-bottom: 0.75rem;
    }

    #account-account .card-account,
    #account-address .card-account {
        border-radius: 0.75rem;
    }

    .card-account-header {
        gap: 0.75rem;
    }

    .card-account-title {
        font-size: 1.1rem;
    }

    #header .header-gradient-bar .dummy-menu {
        padding: 0.4rem 0.5rem;
        gap: 0.4rem 0.75rem;
    }

    #account-account .card-account,
    #account-address .card-account {
        border-radius: 0.75rem;
    }

    body.account_body .card-account .card-body {
        padding: 1rem;
    }

    #account-address .account-address-card {
        border-radius: 12px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    }

    #account-address .account-address-name {
        font-size: 0.9rem;
    }

    #checkout-checkout .btn-primary,
    #checkout-checkout .btn.btn-primary {
        width: 100%;
    }
}

@media (max-width: 992px) {
    #header .m_header-main {
        position: sticky;
        top: 0;
        z-index: 1050;
        background: #fff;
        border-bottom: 1px solid #f0f0f0;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
        padding: 0.5rem 0.75rem 3.1rem;
    }

    #header .m_header-main .header-main-wrapper {
        position: relative;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    #header .m_header-main .header-main-wrapper > .col-auto:first-child,
    #header .m_header-main .header-main-wrapper > .col.m_header-logo,
    #header .m_header-main .header-main-wrapper > .col-auto.m_header-icons {
        flex: 0 0 auto;
        width: auto;
    }

    #header .m_header-main .header-main-wrapper > .col.m_header-logo {
        flex: 1 1 auto;
    }

    #header .m_header-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #header .m_header-trigger .btn-m_trigger {
        width: 28px;
        height: 20px;
        padding: 0;
    }

    #header .m_header-logo {
        flex: 1 1 auto;
        display: flex;
        justify-content: center;
    }

    #header .m_header-logo img {
        max-height: 50px;
        width: auto;
    }

    #header .m_header-icons {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    #header .m_header-icons > a {
        width: 30px;
        height: 30px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        background: #f4f4f4;
        border: 1px solid #e6e6e6;
        color: #111;
    }

    #header .m_header-icons .m_header-block-garage {
        position: relative;
        display: inline-flex;
        flex: 0 0 auto;
    }

    #header .m_header-icons .garage-toggle {
        position: relative;
        width: 30px;
        height: 30px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        background: #f4f4f4;
        border: 1px solid #e6e6e6;
        color: #111;
        padding: 0;
    }

    #header .m_header-icons .garage-count {
        width: 1.15rem;
        height: 1.15rem;
        bottom: -.3rem;
        left: -.4rem;
        font-size: 0.62rem;
        line-height: 1;
        border-width: 1.5px;
        box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.6);
    }

    /* Mobile garage dropdown: keep each vehicle on one tidy line.
       Reset the generic ".m_header-icons a" pill styling for dropdown links. */
    #header .m_header-icons .garage-dropdown {
        width: min(280px, calc(100vw - 24px));
        padding: 10px;
    }

    #header .m_header-icons .garage-list {
        max-height: 60vh;
    }

    #header .m_header-icons .garage-item__link {
        width: auto;
        height: auto;
        background: transparent;
        border: 0;
        border-radius: 8px;
        justify-content: flex-start;
        gap: 8px;
        padding: 10px 8px;
        line-height: 1.25;
    }

    #header .m_header-icons .garage-item__link i {
        flex: 0 0 auto;
    }

    #header .m_header-icons .garage-item__link span {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #header .m_header-icons .header-search-b2b,
    #header .m_header-icons .header-search-btn {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        margin-top: 0.45rem;
    }

    #header .m_header-icons .header-search-b2b #search-b2b,
    #header .m_header-icons .header-search-btn {
        width: 100%;
        background: #f7f7f7;
        border: 1px solid #e6e6e6;
        border-radius: 999px;
        padding: 0.35rem 0.75rem;
        min-height: 36px;
        position: relative;
    }

    #header .m_header-icons .header-search-b2b #search-b2b {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: nowrap;
        flex-direction: row;
    }

    #header .m_header-icons .header-search-b2b #search-b2b input {
        height: 34px;
        font-size: 0.85rem;
        background: transparent;
        border: 0;
        padding: 0 2.25rem 0 0.6rem;
        flex: 1 1 auto;
        min-width: 0;
    }

    #header .m_header-icons .header-search-b2b .header-search-submit {
        flex: 0 0 auto;
        width: auto;
        white-space: nowrap;
        border: 0;
        background: #111;
        width: 30px;
        height: 30px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
    }

    #header .m_header-icons .header-search-b2b .header-search-submit .header-search-text {
        display: none;
    }

    #header .m_header-icons .header-search-b2b .header-search-submit i {
        color: #fff;
    }

    #header .m_header-icons .header-search-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: #666;
    }

    #header .m_header-icons .header-search-btn .header-search-text {
        font-size: 0.85rem;
    }

    #header .m_header-icons .header-search-b2b .header-search-submit {
        left: auto;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        margin-top: 0;
        min-height: 0;
        min-width: 0;
    }

    #header .m_header-main {
        padding-bottom: 4rem;
    }

    .product-gallery_wrap {
        padding: 0.5rem;
    }

    body.product-product .product-info_wrap,
    body.product_product .product-info_wrap {
        padding: 1rem !important;
    }

    #account-product-list {
        padding-top: 0 !important;
    }

    .brand-filter-sidebar {
        width: 100%;
        height: 300px !important;
    }

    .brand-filter-sidebar,
    .category-filter-sidebar {
        width: 100%;
    }

    table.product-table.table.table-hover.table-sm.mb-0 {
    }

    .table-wrapper {
        overflow-x: auto !important;
    }

    .pagination-wrapper {
        display: flex;
        flex-direction: column;
    }

    .product-table tbody {
        overflow: visible !important;
    }

    .footer-wrap .footer-content {
        padding: 0.5rem 0;
    }

    .mobile-categories {
        padding: 0.25rem 0 0.75rem;
    }

    .mobile-categories-root,
    .mobile-categories-root ul {
        list-style: none;
        padding-left: 0;
        margin: 0;
    }

    .mobile-categories-item {
        border-bottom: 1px solid #eee;
    }

    .mobile-categories-item > a,
    .mobile-categories details > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 1.25rem;
        line-height: 3.125rem;
        font-weight: 700;
        color: #111;
        font-size: 0.95rem;
        width: 100%;
    }

    .mobile-categories details > summary::marker,
    .mobile-categories details > summary::-webkit-details-marker {
        display: none;
    }

    .mobile-categories details > summary::after {
        content: '+';
        font-weight: 700;
        color: #666;
        margin-left: auto;
    }

    li.mobile-categories-item details {
        width: 100%;
        padding-right: 0;
    }

    .mobile-categories details[open] > summary::after {
        content: '−';
    }

    .mobile-categories details ul {
        padding: 0 0 0.5rem 0.75rem;
    }

    .mobile-categories details ul li a {
        display: block;
        padding: 0.5rem 0;
        color: #333;
        font-size: 0.9rem;
    }

    .mobile-categories-item.is-thursday > a,
    .mobile-categories-item.is-thursday > details > summary {
        color: #dc0000;
    }

    .hometopbanners > .container-xxl > .row {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .contenttophome.col-10 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }

    .content.column_right.col-2 {
    }

    .hometopbanners .content.column_right.col-2 {
        width: 199%;
        max-width: 100%;
    }

    .verticalbanners {
    }

    .verticalbanners .row.banner-row .banner-col {
        width: 100%;
        flex: 1;
        max-width: none;
        display: flex;
        gap: 0;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    .verticalbanners .row.banner-row .banner-col a.banner-item {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .americathomebanners .banner-col.col-12.col-md-0 {
        display: flex;
        flex-direction: column;
    }
}

/* Mobile header: burger + logo hug the left, icons fill the right with spacing.
   Applies to both guest and b2b headers. */
#header .m_header-trigger {
    flex: 0 0 auto !important;
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0.5rem !important;
    width: auto !important;
    justify-content: flex-start !important;
}

#header .m_header-main .header-main-wrapper > .col.m_header-logo {
    flex: 0 0 auto !important;
    justify-content: flex-start !important;
    padding-left: 0 !important;
}

#header .m_header-main .header-main-wrapper > .col-auto.m_header-icons {
    flex: 1 1 auto !important;
    max-width: none !important;
    padding-right: 0 !important;
    width: auto !important;
    justify-content: flex-end !important;
    flex-direction: unset;
    gap: 0.45rem 0.7rem !important;
}

/* Vehicle landing page */
@media (max-width: 992px) {
    .vehicle-cats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .vehicle-cats {
        grid-template-columns: repeat(2, 1fr);
    }

    .vehicle-hero {
        flex-wrap: wrap;
        gap: 16px;
        padding: 18px 20px;
    }

    .vehicle-hero__title {
        font-size: 1.35rem;
    }

    .vehicle-hero__change {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .vehicle-cats {
        grid-template-columns: 1fr;
    }
}
