/* ==============================================
   Archive Product Mobile Fixes
   ============================================== */

/* ======================
   Fix Filter & Sorting Alignment on Mobile
   ====================== */
@media (max-width: 768px) {
  /* Make filter and sorting containers equal height */
  .hide-desktop.col-lg-12 {
    flex: 0 0 auto;
    width: auto;
  }

  /* Style filter button to match sorting dropdown */
  .btn-filter {
    height: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    color: #1d2327;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin: 0;
  }

  .btn-filter:hover {
    border-color: #2271b1;
    background: #f0f4ff;
    color: #2271b1;
  }

  /* Ensure sorting container is properly aligned */
  .col-sm-6.col-7.col-lg-12 {
    display: flex;
    align-items: stretch;
  }

  .col-sm-6.col-7.col-lg-12 .d-flex {
    width: 100%;
    height: 100%;
    align-items: center;
  }

  /* Match sorting dropdown height with filter button */
  .custom-select.sources {
    height: 100%;
  }

  .custom-select.sources .custom-select-trigger {
    min-height: 38px;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 8px 35px 8px 12px;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
  }

  .custom-select.sources .custom-select-trigger:hover {
    border-color: #2271b1;
    background: #f0f4ff;
  }

  /* Ensure both columns stretch to same height */
  .row.g-3 > .col-5,
  .row.g-3 > .col-7 {
    display: flex;
    align-items: stretch;
  }
}

/* Very small screens (below 576px) */
@media (max-width: 576px) {
  /* Adjust column widths for better proportion */
  .hide-desktop.col-5 {
    flex: 0 0 auto;
    width: 35%;
    max-width: 35%;
  }

  .col-sm-6.col-7 {
    flex: 0 0 auto;
    width: 65%;
    max-width: 65%;
  }

  .btn-filter {
    width: 100%;
    font-size: 13px;
    padding: 8px 12px;
  }

  /* Adjust text sizes for small screens */
  .col-sm-6.col-7 .text-xs {
    font-size: 11px;
    display: none; /* Hide "Sort by" text on very small screens */
  }

  .custom-select.sources .custom-select-trigger {
    font-size: 13px;
    padding: 8px 30px 8px 10px;
  }
}

/* ======================
   Product Grid Mobile Optimization
   ====================== */
@media (max-width: 768px) {
  /* Product grid container */
  .product-content .row.g-2.g-sm-3 {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  /* Product items - ensure consistent sizing */
  .product-content .col-6,
  .product-content .col-sm-6 {
    flex: 0 0 calc(50% - 4px);
    max-width: calc(50% - 4px);
    margin-bottom: 8px;
  }

  /* Handle odd number of products - last item centered */
  .product-content .row.g-2.g-sm-3.odd-last-item > .col-6:last-child {
    flex: 0 0 calc(50% - 4px);
    max-width: calc(50% - 4px);
    margin-left: 0;
    margin-right: auto;
  }

  /* Product item styling consistency */
  .product-items {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .product-items .img-prod {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .product-items .info-prod {
    padding: 10px 8px;
    min-height: 60px;
  }
}

/* Smaller mobile screens */
@media (max-width: 480px) {
  /* Adjust gaps for smaller screens */
  .product-content .col-6 {
    flex: 0 0 calc(50% - 3px);
    max-width: calc(50% - 3px);
    margin-bottom: 6px;
  }

  .product-items .info-prod {
    padding: 8px 6px;
    min-height: 50px;
  }

  .product-items .text-xs {
    font-size: 11px;
  }

  .product-items .text-hidden {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ======================
   Loading States for Mobile
   ====================== */
@media (max-width: 768px) {
  .LoadingOverlay {
    background: rgba(255, 255, 255, 0.95) !important;
  }

  .infinity-loading {
    padding: 15px 0;
    font-size: 13px;
  }

  .infinity-loading .spinner-border {
    width: 1rem;
    height: 1rem;
  }
}

/* ======================
   Pagination Mobile Optimization
   ====================== */
@media (max-width: 768px) {
  .pagination {
    padding-top: 30px !important;
  }

  .btn-show-more,
  .btn-show-all {
    width: 100%;
    max-width: 280px;
    padding: 10px 20px;
    font-size: 14px;
  }

  .btn-show-more span,
  .btn-show-all span {
    font-size: 14px;
  }
}

/* ======================
   Filter Sidebar Mobile
   ====================== */
@media (max-width: 768px) {
  .filter-side {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .filter-side.show {
    left: 0;
  }

  .btn-back-filter {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    width: 100%;
    text-align: left;
  }

  .inner-filter {
    padding: 15px;
  }

  .info-filter {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
  }
}

/* Dark overlay when filter is open */
@media (max-width: 768px) {
  body.filter-open::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
  }
}
