/* Product listing pages — tablet grid + laptop sidebar filters */

/* ---------- tablet / medium (500–1399): 3 cards per row ---------- */
/* Phone <500 stays list; 800–1200 / 1400+ laptop rules override where they overlap */
@media (min-width: 500px) and (max-width: 1399px) {
  .page:has(#filterDrawer) {
    max-width: none !important;
    width: 100% !important;
    margin: 0 auto;
    padding: 0 0 48px;
    box-shadow: none !important;
    background: rgb(249, 249, 249);
  }

  .page:has(#filterDrawer) > .breadcrumb {
    padding: 20px var(--page-pad, 32px) 0;
    justify-content: flex-start;
  }

  .page:has(#filterDrawer) > .hero-banner {
    width: calc(100% - 2 * var(--page-pad, 32px));
    max-width: none;
    height: clamp(180px, 22vw, 220px);
    margin: 16px auto 20px;
  }

  .page:has(#filterDrawer) > .toolbar {
    padding: 4px var(--page-pad, 32px) 18px;
  }

  .page:has(#filterDrawer) .product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 0 var(--page-pad, 24px) 28px;
    background: transparent;
  }

  .page:has(#filterDrawer) .product-grid .product-card {
    display: flex;
    flex-direction: column;
    border-top: none;
    border: 1px solid #d9dce1;
    border-radius: 18px;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    gap: 0;
    background: #fff;
    box-sizing: border-box;
  }

  .page:has(#filterDrawer) .product-grid .product-image,
  .page:has(#filterDrawer) .product-grid .product-cover,
  .page:has(#filterDrawer) .product-grid .cover {
    flex: none !important;
    width: 100% !important;
    max-width: none !important;
    height: 202.5px !important;
    border-radius: 0;
    margin: 0 !important;
    overflow: hidden;
    background: #e7ebfb;
  }

  .page:has(#filterDrawer) .product-grid .product-image img,
  .page:has(#filterDrawer) .product-grid .product-cover img,
  .page:has(#filterDrawer) .product-grid .cover img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 0 !important;
    display: block;
  }

  .page:has(#filterDrawer) .product-grid .product-info {
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .page:has(#filterDrawer) .product-grid .rating-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .page:has(#filterDrawer) .product-grid .rating-row .wishlist-btn {
    position: static;
    margin: 0 0 0 auto;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    color: #004ebc;
  }

  .page:has(#filterDrawer) .product-grid .product-price,
  .page:has(#filterDrawer) .product-grid .price {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1a1a1a;
    white-space: nowrap;
  }

  .page:has(#filterDrawer) .product-grid .product-title {
    flex: none;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .page:has(#filterDrawer) .product-grid .add-cart-btn {
    width: 100%;
    margin-top: auto;
    background: #004ebc;
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 12px 16px;
    min-height: 44px;
    border: none;
    border-radius: 999px;
    box-shadow: 0 3px 0 #003894;
    cursor: pointer;
  }

  .page:has(#filterDrawer) .toolbar-sort {
    display: none;
  }
}

/* ---------- laptop (1400+): sidebar + card grid ---------- */
@media (min-width: 800px) and (max-width: 1200px), (min-width: 1400px) {
  .page:has(#filterDrawer) {
    max-width: min(100%, 1400px);
    margin: 0 auto;
    padding: 0 var(--page-pad, 40px) 48px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    column-gap: 24px;
    align-items: start;
    box-shadow: none !important;
  }

  .page:has(#filterDrawer) > .breadcrumb,
  .page:has(#filterDrawer) > .hero-banner,
  .page:has(#filterDrawer) > .toolbar {
    grid-column: 1 / -1;
  }

  .page:has(#filterDrawer) > .breadcrumb {
    width: 100%;
    margin: 0;
    padding: 24px 0 0;
    justify-content: flex-start;
    text-align: left;
  }

  .page:has(#filterDrawer) > .empty-state {
    grid-column: 2;
    grid-row: 5;
  }

  .page:has(#filterDrawer) > .toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0 20px;
    overflow: visible;
    position: relative;
    z-index: 5;
  }

  .page:has(#filterDrawer) .toolbar .filter-btn {
    display: none;
  }

  .page:has(#filterDrawer) .product-count {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1a1a1a;
  }

  .page:has(#filterDrawer) .toolbar-sort {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .page:has(#filterDrawer) .toolbar-sort-label {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
  }

  .page:has(#filterDrawer) .toolbar-sort-dropdown {
    position: relative;
  }

  .page:has(#filterDrawer) .toolbar-sort-trigger {
    min-width: 160px;
    height: 44px;
    padding: 0 36px 0 14px;
    border: 1.5px solid #c7ccd4;
    border-radius: 10px;
    background: #fff;
    font-family: 'Buenos Aires', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
    position: relative;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231a1a1a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
  }

  .page:has(#filterDrawer) .toolbar-sort-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    min-width: 100%;
    width: max-content;
    max-width: min(300px, calc(100vw - 32px));
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: #fff;
    border: 1.5px solid #c7ccd4;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(17, 33, 74, 0.14);
    z-index: 30;
    box-sizing: border-box;
  }

  .page:has(#filterDrawer) .toolbar-sort-option {
    padding: 10px 14px;
    font-family: 'Buenos Aires', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    white-space: nowrap;
  }

  .page:has(#filterDrawer) .toolbar-sort-option:hover,
  .page:has(#filterDrawer) .toolbar-sort-option.is-selected {
    background: #004ebc;
    color: #fff;
  }

  .page:has(#filterDrawer) .overlay {
    display: none !important;
  }

  .page:has(#filterDrawer) .filter-drawer {
    position: static;
    grid-column: 1;
    grid-row: 4;
    width: 100%;
    max-width: 260px;
    transform: none;
    box-shadow: none;
    border: 1px solid #e6e9ee;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: none;
    align-self: start;
  }

  .page:has(#filterDrawer) .filter-drawer .drawer-header {
    display: none;
  }

  .page:has(#filterDrawer) .filter-drawer::before {
    content: 'Filter:';
    display: block;
    padding: 18px 20px 10px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1a1a1a;
    border-bottom: 1px solid #e6e9ee;
    background: #fff;
  }

  .page:has(#filterDrawer) .filter-drawer .drawer-body {
    padding-bottom: 0;
    flex: 1;
    overflow: visible;
  }

  .page:has(#filterDrawer) .filter-drawer .drawer-footer {
    position: static;
    padding: 14px 16px 16px;
  }

  .page:has(#filterDrawer) .filter-drawer .accordion-header {
    padding: 16px 20px;
    font-size: 1rem;
  }

  .page:has(#filterDrawer) .product-grid {
    grid-column: 2;
    grid-row: 4;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    justify-content: start;
    padding: 0 0 24px;
    background: transparent;
    box-sizing: border-box;
  }

  .page:has(#filterDrawer) .product-grid .product-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border: 1px solid #d9dce1;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-sizing: border-box;
  }

  .page:has(#filterDrawer) .product-grid .product-card.hidden {
    display: none;
  }

  .page:has(#filterDrawer) .product-grid .product-image,
  .page:has(#filterDrawer) .product-grid .product-cover,
  .page:has(#filterDrawer) .product-grid .cover {
    position: relative;
    flex: none;
    width: 100%;
    height: 202.5px;
    border-radius: 0;
    font-size: 4rem;
    overflow: hidden;
    background: #e7ebfb;
  }

  .page:has(#filterDrawer) .product-grid .product-image img,
  .page:has(#filterDrawer) .product-grid .product-cover img,
  .page:has(#filterDrawer) .product-grid .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
  }

  .page:has(#filterDrawer) .product-grid .rating-row .wishlist-btn {
    position: static;
    margin: 0 0 0 auto;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    color: #004ebc;
  }

  .page:has(#filterDrawer) .product-grid .rating-row .wishlist-btn svg {
    width: 20px;
    height: 20px;
  }

  .page:has(#filterDrawer) .product-grid .wishlist-btn.active,
  .page:has(#filterDrawer) .product-grid .wishlist-btn.is-active {
    background: #004ebc !important;
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 78, 188, 0.35);
  }

  .page:has(#filterDrawer) .product-grid .wishlist-btn.active svg path,
  .page:has(#filterDrawer) .product-grid .wishlist-btn.is-active svg path {
    fill: #fff;
    stroke: #fff;
  }

  .page:has(#filterDrawer) .product-grid .product-info {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px 14px;
  }

  .page:has(#filterDrawer) .product-grid .rating-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
    flex: none;
  }

  .page:has(#filterDrawer) .product-grid .rating-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
  }

  .page:has(#filterDrawer) .product-grid .rating-row .rating-text {
    font-size: 0.88rem;
    color: #5b6878;
    white-space: nowrap;
  }

  .page:has(#filterDrawer) .product-grid .product-price,
  .page:has(#filterDrawer) .product-grid .price {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #1a1a1a;
    flex: none;
    white-space: nowrap;
  }

  .page:has(#filterDrawer) .product-grid .product-title {
    flex: none;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0;
  }

  .page:has(#filterDrawer) .product-grid .add-cart-btn {
    width: 100%;
    margin-top: auto;
    background: #004ebc;
    color: #fff;
    font-family: 'Buenos Aires', sans-serif;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 12px 16px;
    min-height: 44px;
    border: none;
    border-radius: 999px;
    box-shadow: 0 3px 0 #003894;
    cursor: pointer;
    transition: transform 0.08s;
  }

  .page:has(#filterDrawer) .product-grid .add-cart-btn:active {
    transform: translateY(2px);
    box-shadow: none;
  }

  .page:has(#filterDrawer) > .hero-banner {
    width: 100%;
    max-width: none;
    height: 223px;
    margin: 20px 0 24px;
  }
}

@media (max-width: 1399px) {
  .page:has(#filterDrawer) .toolbar-sort {
    display: none;
  }
}

/* Filter drawer — price inputs in DZD */
.page:has(#filterDrawer) .price-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page:has(#filterDrawer) .price-currency {
  flex: none;
  font-size: 0.92rem;
  font-weight: 700;
  color: #5b6878;
  white-space: nowrap;
}

/* Character / listing heroes — fixed mid band (800–1150): 944×223 */
@media (min-width: 800px) and (max-width: 1150px) {
  .page:has(#filterDrawer) > .hero-banner {
    width: 944px;
    max-width: 100%;
    height: 223px;
    margin: 16px auto 24px;
    border-radius: 16px;
    justify-self: center;
  }

  .page:has(#filterDrawer) > .hero-banner img,
  .page:has(#filterDrawer) > .hero-banner picture,
  .page:has(#filterDrawer) > .hero-banner picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
}

/* 800–1150 + laptop: full-bleed image area 202.5 tall, title tight above price */
@media (min-width: 800px) and (max-width: 1150px), (min-width: 1400px) {
  .page:has(#filterDrawer) .product-grid .product-image,
  .page:has(#filterDrawer) .product-grid .product-cover,
  .page:has(#filterDrawer) .product-grid .cover {
    width: 100% !important;
    max-width: none !important;
    height: 202.5px !important;
    flex: 0 0 202.5px !important;
    margin: 0 !important;
    overflow: hidden;
    background: #e7ebfb;
  }

  .page:has(#filterDrawer) .product-grid .product-image img,
  .page:has(#filterDrawer) .product-grid .product-cover img,
  .page:has(#filterDrawer) .product-grid .cover img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 0 !important;
    display: block;
  }

  .page:has(#filterDrawer) .product-grid .product-card {
    min-height: 0 !important;
  }

  .page:has(#filterDrawer) .product-grid .product-info {
    gap: 4px;
  }

  .page:has(#filterDrawer) .product-grid .product-title {
    flex: none !important;
    margin: 0;
  }

  .page:has(#filterDrawer) .product-grid .product-title + .product-price,
  .page:has(#filterDrawer) .product-grid .product-title + .price {
    margin-top: 0;
  }
}
