/* Global responsive helpers for small screens */
@media (max-width: 768px) {
  /* Stack grid columns on small screens */
  [class*="col-md-"],
  [class*="col-lg-"],
  [class*="col-sm-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Ensure rows wrap */
  .row,
  .d-flex {
    flex-wrap: wrap !important;
  }

  /* Common cards/boxes full width */
  .summary-card,
  .order-summary-card,
  .purchase-card,
  .vendor-section {
    width: 100% !important;
  }

  /* Buttons and form controls span full width when nested in blocks */
  .btn,
  .button,
  button,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    max-width: 100%;
  }

  /* Images scale down gracefully */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Reduce padding for dense mobile layouts */
  .container,
  .container-fluid,
  .main-cart-layout,
  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ===== NAVBAR RESPONSIVE ===== */
@media (max-width: 991px) {
  #primary-navigation {
    overflow-x: hidden;
  }
  #primary-navigation .container {
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ===== HOMEPAGE RESPONSIVE ===== */
@media (max-width: 991px) {
  /* Slider - mobile height */
  #content-wrapper .ei-slider {
    max-height: 280px;
    overflow: hidden;
  }

  #content-wrapper .ei-slider-large li img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }

  /* Banner block - full width on tablet/mobile */
  .banner-block .container {
    padding-left: 12px;
    padding-right: 12px;
    max-width: 100%;
  }

  .banner-block .col-lg-11,
  .banner-block .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
    margin-bottom: 12px;
  }

  .banner-block .image-banner img,
  .banner-block .banner-box img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }

  /* Product section headers */
  .best-under .best-under-header .sell-header-title h2 {
    font-size: 26px !important;
  }

  /* Product cards in sliders - allow flexible width on small screens */
  .best-under .slick-list {
    margin: 0 -8px;
  }

  .best-under .slick-slide {
    padding: 0 8px;
  }

  .homepage-sections-wrap .best-under .items-slider .box-inner {
    max-width: 100% !important;
    width: 100% !important;
  }

  .homepage-sections-wrap .best-under .items-slider .box-img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 2 / 3;
  }

  .homepage-sections-wrap .best-under .items-slider .box-img > a:first-child,
  .homepage-sections-wrap .best-under .items-slider .box-img img[data-name="product_image"] {
    width: 100% !important;
    height: 100% !important;
  }

  /* Homepage bottom text */
  .homepage-bottom-text {
    padding: 20px 0;
  }

  .homepage-bottom-text__inner {
    font-size: 16px;
  }

  .homepage-bottom-text__title {
    font-size: 22px;
  }

  .homepage-bottom-text__content h3 {
    font-size: 16px;
  }
}

@media (max-width: 576px) {
  /* Slider - smaller height on phones */
  #content-wrapper .ei-slider {
    max-height: 200px;
  }

  /* Banner block padding */
  .banner-block .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Product section headers */
  .best-under .best-under-header .sell-header-title h2 {
    font-size: 22px !important;
  }

  .best-under .best-under-header {
    padding-right: 45px;
  }

  .homepage-sections-wrap .best-under .items-slider .box-inner {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Product cards - compact on phone */
  .best-under .items-slider .box-title a {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  .best-under .items-slider .box-author,
  .best-under .items-slider .box-condition,
  .best-under .items-slider .box-price {
    font-size: 12px !important;
  }

  /* Slider arrows - smaller on mobile */
  .best-under .slider-arrow,
  .best-under .best-under-left,
  .best-under .best-under-right {
    width: 36px !important;
    height: 36px !important;
    padding: 6px !important;
  }

  .best-under .slider-arrow svg {
    width: 14px;
    height: 14px;
  }

  /* Homepage bottom text - stack on mobile */
  .homepage-bottom-text {
    margin: 14px 0 18px;
    padding: 16px 0;
  }

  .homepage-bottom-text__inner {
    font-size: 15px;
  }

  .homepage-bottom-text__title {
    font-size: 20px;
    margin-bottom: 14px;
  }

  .homepage-bottom-text__content h3 {
    font-size: 15px;
  }
}

@media (max-width: 400px) {
  /* Very small screens - slider */
  #content-wrapper .ei-slider {
    max-height: 180px;
  }

  /* Product cards - smaller padding */
  .best-under .slick-list {
    margin: 0 -6px;
  }

  .best-under .slick-slide {
    padding: 0 6px;
  }
}

/* Prevent horizontal overflow on homepage */
body:not(.rtl) #content-wrapper {
  overflow-x: hidden;
}

body.rtl #content-wrapper {
  overflow-x: hidden;
}

/* ===== CATEGORY PAGE RESPONSIVE ===== */

/* Category cover banner */
@media (max-width: 991px) {
  .category-banner-img-wrapper .banner,
  .cover-img-wrapper {
    min-height: 140px;
    background-size: cover;
    background-position: center;
  }
  .page-cover-title {
    font-size: 22px !important;
  }
  .page-cover-desc {
    font-size: 14px !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

@media (max-width: 576px) {
  .category-banner-img-wrapper .banner,
  .cover-img-wrapper {
    min-height: 120px;
  }
  .page-cover-title {
    font-size: 18px !important;
  }
  .page-cover-desc {
    font-size: 13px !important;
    -webkit-line-clamp: 1;
  }
}

/* Category page - breadcrumb */
@media (max-width: 991px) {
  .category-single-page .page-header,
  .category-single-page .nav-breadcrumb {
    padding-left: 0;
    padding-right: 0;
  }
  .nav-breadcrumb {
    font-size: 13px;
  }
  .nav-breadcrumb li {
    max-width: 100%;
  }
}

@media (max-width: 576px) {
  .nav-breadcrumb {
    font-size: 12px;
  }
}

/* Category page - product list layout */
@media (max-width: 991px) {
  .product-list-wrapper {
    flex-direction: column;
  }
  .product-list-wrapper > .col-xl-2,
  .product-list-wrapper > .col-lg-3 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }
  .product-list-wrapper > .col-xl-10,
  .product-list-wrapper > .col-lg-9 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }
  .product-list-wrapper .border.radius {
    border: none !important;
    padding: 0;
  }
  #filterBtn {
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    margin-bottom: 12px;
    padding: 10px 20px;
    background: #0B6776;
    color: #fff;
    border-radius: 6px;
    border: none;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 8px;
  }
  #filterBtn i {
    font-size: 16px;
  }
  .category-filters {
    margin-top: 12px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 70vh;
    overflow-y: auto;
  }
  .category-single-page .container {
    padding-left: 12px;
    padding-right: 12px;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .product-list-wrapper .product-2nd-parent .col-12:first-child {
    overflow-x: hidden;
  }
  .product-list-top-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  .product-list-top-filter .results-count {
    width: 100%;
    margin-bottom: 0;
    order: 2;
  }
  .product-list-top-filter .results-count span {
    font-size: 13px;
  }
  .product-list-top-filter .sort-and-view-controls {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    order: 1;
    visibility: visible !important;
    margin-top: 0 !important;
  }
  .product-list-top-filter .sort-control {
    min-width: 0 !important;
    width: 100% !important;
    overflow: visible;
    margin: 0 !important;
  }
  .product-list-top-filter .sort-control .selectboxit-container {
    width: 100% !important;
    max-width: 100% !important;
  }
  .product-list-top-filter .sort-control .selectboxit-container .selectboxit {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .product-list-top-filter .sort-control .selectboxit-container .selectboxit-options {
    max-width: 100%;
    box-sizing: border-box;
  }
  .product-list-top-filter .view-switcher {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .product-list-wrapper .product-2nd-parent .categoryCard:not(.list-view-card) {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
}

@media (max-width: 576px) {
  .category-single-page .container {
    padding-left: 10px;
    padding-right: 10px;
  }
  .product-list-wrapper .product-2nd-parent .categoryCard {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  .product-list-wrapper .product-info-title {
    font-size: 13px !important;
  }
  .product-list-wrapper .product-img-wrap {
    padding-top: 120%;
  }
}

/* Categories listing page (kategoriler) */
@media (max-width: 991px) {
  .category-widget {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  .category-widget .banner {
    min-height: 120px;
    background-size: cover;
  }
  .nav-category-inner-title {
    font-size: 15px;
  }
  .nav-category-inner-list {
    font-size: 14px;
  }
}

@media (max-width: 576px) {
  .category-widget {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .category-widget .banner {
    min-height: 100px;
  }
  .section-title h4 {
    font-size: 18px;
  }
}

/* Product cards - mobile improvements */
@media (max-width: 768px) {
  .product-list-wrapper .product.product-grid-view {
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 8px;
  }
  .product-list-wrapper .product.product-grid-view .product-info-title {
    font-size: 13px;
    line-height: 1.35;
  }
  .product-list-wrapper .product.product-grid-view .list-condition-price-head,
  .product-list-wrapper .product.product-grid-view .list-condition-price-body {
    font-size: 12px;
  }
}

/* List view on mobile - compact & clean */
@media (max-width: 767px) {
  .product-list-wrapper .product-2nd-parent .list-view-card,
  .product-list-wrapper .product-2nd-parent .categoryCard.list-view-card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    margin-bottom: 16px !important;
  }
  .product-list-wrapper .product.product-list-view {
    display: grid !important;
    grid-template-columns: 88px minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    column-gap: 14px;
    row-gap: 12px;
    padding: 14px 12px !important;
    align-items: start !important;
    overflow: hidden !important;
    border: 1px solid #e8e8e8 !important;
    border-radius: 10px !important;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
    margin: 0 0 12px 0 !important;
  }
  .product-list-wrapper .product.product-list-view .product-img-wrap {
    width: 88px !important;
    max-width: 88px !important;
    height: 130px !important;
    border-radius: 6px !important;
    grid-column: 1;
    grid-row: 1;
  }
  .product-list-wrapper .product.product-list-view .product-info {
    display: flex !important;
    flex-direction: column !important;
    grid-column: 2;
    grid-row: 1;
    min-width: 0 !important;
    overflow: hidden !important;
    height: auto !important;
    gap: 6px;
  }
  .product-list-wrapper .product.product-list-view .product-info-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    color: #1a1a1a !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    word-break: break-word !important;
    margin: 0 !important;
  }
  .product-list-wrapper .product.product-list-view .list-book-meta {
    font-size: 12px !important;
    margin: 0 !important;
    line-height: 1.4;
  }
  .product-list-wrapper .product.product-list-view .list-book-meta-row {
    margin-bottom: 2px !important;
    overflow: hidden !important;
  }
  .product-list-wrapper .product.product-list-view .list-book-meta .meta-label {
    color: #888 !important;
  }
  .product-list-wrapper .product.product-list-view .list-book-meta .meta-value {
    color: #0B6776 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .product-list-wrapper .product.product-list-view .list-book-meta .meta-row-empty {
    display: none !important;
  }
  .product-list-wrapper .product.product-list-view .product-info-rating {
    margin: 2px 0 !important;
    font-size: 12px;
  }
  .product-list-wrapper .product.product-list-view .product-info-availability {
    display: none !important;
  }
  .product-list-wrapper .product.product-list-view .list-condition-price {
    margin-top: 4px !important;
    padding-top: 8px !important;
    border-top: 1px solid #f0f0f0 !important;
  }
  .product-list-wrapper .product.product-list-view .list-condition-price-head {
    font-size: 11px !important;
    color: #888 !important;
    margin-bottom: 4px !important;
  }
  .product-list-wrapper .product.product-list-view .list-condition-price-body {
    font-size: 14px !important;
  }
  .product-list-wrapper .product.product-list-view .list-price-value strong {
    color: #0B6776 !important;
    font-size: 15px !important;
  }
  .product-list-wrapper .product.product-list-view .product-actions {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  .product-list-wrapper .product.product-list-view .product-actions .sc-add-to-cart {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    border-radius: 8px !important;
    font-size: 15px !important;
  }
}

@media (max-width: 575px) {
  .product-list-wrapper .product-2nd-parent .list-view-card,
  .product-list-wrapper .product-2nd-parent .categoryCard.list-view-card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .product-list-wrapper .product.product-list-view .product-info {
    height: auto !important;
  }
}

/* Force 2-column product grid on mobile category/list pages */
@media (max-width: 768px) {
  .product-list-wrapper .product-2nd-parent.row {
    display: flex !important;
    flex-wrap: wrap !important;
    margin: 15px -4px 0 !important;
  }

  .product-list-wrapper .product-2nd-parent .categoryCard,
  .product-list-wrapper .product-2nd-parent .list-view-card,
  .product-list-wrapper .product-2nd-parent .categoryCard.list-view-card {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
}

/* Pagination on mobile */
@media (max-width: 576px) {
  .product-list-wrapper .pagination.pagination-minimal a {
    font-size: 18px;
  }
}

/* Mobile: add breathing room between section headers and first cards */
@media (max-width: 1199px) {
  .sell-header,
  .best-under .best-under-header,
  .feature .sell-header,
  .trending-items-area .sell-header {
    margin-bottom: 18px !important;
  }

  .best-under .best-under-header .header-line {
    margin-bottom: 14px !important;
  }

  .section-title {
    margin-bottom: 14px !important;
  }
}

@media (max-width: 576px) {
  .sell-header,
  .best-under .best-under-header,
  .feature .sell-header,
  .trending-items-area .sell-header {
    margin-bottom: 20px !important;
  }

  .best-under .best-under-header .header-line {
    margin-bottom: 16px !important;
  }

  .section-title {
    margin-bottom: 16px !important;
  }
}

/* Mobile: hide non-functional arrows on the top hero/banner slider */
@media (max-width: 991px) {
  #ei-slider .slick-prev,
  #ei-slider .slick-next,
  #ei-slider .slick-arrow,
  #ei-slider .slider-arrow,
  #ei-slider .left-arrow,
  #ei-slider .right-arrow,
  #ei-slider .owl-prev,
  #ei-slider .owl-next,
  #content-wrapper > section:first-of-type .slick-prev,
  #content-wrapper > section:first-of-type .slick-next,
  #content-wrapper > section:first-of-type .slick-arrow,
  #content-wrapper > section:first-of-type .slider-arrow,
  #content-wrapper > section:first-of-type .left-arrow,
  #content-wrapper > section:first-of-type .right-arrow,
  #content-wrapper > section:first-of-type .owl-prev,
  #content-wrapper > section:first-of-type .owl-next {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Mobile: hide arrows on the first section right after the hero slider */
@media (max-width: 1199px) {
  #content-wrapper > section:first-of-type + section .slider-arrow,
  #content-wrapper > section:first-of-type + section .slick-prev,
  #content-wrapper > section:first-of-type + section .slick-next,
  #content-wrapper > section:first-of-type + section .slick-arrow,
  #content-wrapper > section:first-of-type + section .left-arrow,
  #content-wrapper > section:first-of-type + section .right-arrow {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Mobile/Tablet hard override: hide homepage product section arrows */
@media (max-width: 1199px) {
  #content-wrapper .best-under .slider-arrow,
  #content-wrapper .best-under .slick-arrow,
  #content-wrapper .best-under .left-arrow,
  #content-wrapper .best-under .right-arrow,
  #content-wrapper .best-under .best-under-left,
  #content-wrapper .best-under .best-under-right,
  #content-wrapper .best-under .slick-prev,
  #content-wrapper .best-under .slick-next,
  #content-wrapper .best-under .best-deal-left,
  #content-wrapper .best-under .best-deal-right {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* Mobile Hamburger Menu: simpler and easier category navigation */
@media (max-width: 991px) {
  .main-menu-nav li:first-child {
    z-index: 9 !important;
    display: list-item !important;
    margin-top: 0 !important;
  }

  .main-menu-nav .close-button {
    display: none !important;
  }

  .main-menu-nav > li.mobile-menu-group-item {
    border-bottom: 1px solid #edf2f3;
    overflow: visible !important;
  }

  .main-menu.mobile-mega-menu {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .main-menu.mobile-mega-menu > nav {
    height: 100%;
  }

  .mobile-mega-menu .main-menu-nav {
    padding-bottom: 96px;
  }

  .mobile-menu-group-link {
    display: block;
    width: calc(100% - 46px) !important;
    padding: 13px 14px 11px !important;
    line-height: 1.25;
    color: #1f2b2f !important;
    font-weight: 600 !important;
  }

  .mobile-menu-group-link span {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-group-link small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #6b7c82;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    font-weight: 600;
  }

  .mobile-mega-menu .next-button {
    left: auto !important;
    right: 0;
    width: 44px !important;
    height: 100%;
    min-height: 46px;
    border-left: 1px solid #edf2f3;
    display: flex !important;
    align-items: center;
    justify-content: center !important;
    background: transparent !important;
    text-align: center !important;
    padding: 0 !important;
  }

  .mobile-mega-menu .next-button .arrow {
    color: #607277;
  }

  .mobile-mega-menu .back-button {
    background: #f7fafb !important;
    border-bottom: 1px solid #edf2f3;
    color: #1f2b2f !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 12px 14px !important;
    width: 100% !important;
  }

  .mobile-mega-menu ul li a {
    width: 100% !important;
    padding: 11px 14px !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
  }

  .mobile-mega-menu ul li a:hover {
    transform: none !important;
    background: #f7fafb;
  }

  .mobile-menu-subgroups > li > a {
    color: #2e474e !important;
    font-size: 13px !important;
    padding-left: 18px !important;
    padding-right: 14px !important;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-subgroups > li.mobile-subgroup-viewall > a {
    color: #0d5b63 !important;
    font-weight: 700 !important;
    border-bottom: 1px dashed #dfe8ea;
    margin-bottom: 4px;
  }

  .mobile-mega-menu .mobile-menu-subgroups {
    max-height: calc(100dvh - 250px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 90px;
  }

  @supports not (height: 100dvh) {
    .mobile-mega-menu .mobile-menu-subgroups {
      max-height: calc(100vh - 250px);
    }
  }

  .mobile-menu-subgroups > li.mobile-subgroup-item {
    border-top: 1px solid #eef3f4;
  }

  .mobile-menu-subgroups > li.mobile-subgroup-item > a {
    color: #1f2b2f !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    padding-top: 12px !important;
    padding-bottom: 8px !important;
  }

  .mobile-menu-subgroups > li.mobile-leaf-category-item > a {
    color: #5f7278 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    padding-left: 30px !important;
    position: relative;
  }

  .mobile-menu-subgroups > li.mobile-leaf-category-item > a::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 50%;
    width: 6px;
    height: 1px;
    transform: translateY(-50%);
    background: #90a4aa;
  }
}
