/* =========================
   RESET & BASE
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'Urbanist', sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  min-height: 100vh;
}




/* =========================
   MAIN WRAPPER
========================= */
main {
  width: 100%;
  padding: 0.8rem;
  margin: 0 auto;
  max-width: 480px; /* mobile-first width */
}

/* =========================
   SEARCH + TRI
========================= */
.search-filter {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

#search-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-size: 1rem;
  border: 1.8px solid #ddd;
  border-radius: 8px;
  background: white;
}

#price-sort {
  width: 100%;
  padding: 0.7rem;
  border-radius: 999px;
  border: 2px solid #7f0000;
  color: #7f0000;
  font-weight: 700;
  background: white;
}

/* =========================
   CATEGORIES (SCROLLABLE)
========================= */
.categories-scroll {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  white-space: nowrap;
}

.categories-scroll::-webkit-scrollbar { display: none; }

.categories {
  display: inline-flex;
  gap: 0.6rem;
}

.categories button {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border: 1.8px solid #ddd;
  border-radius: 999px;
  background: white;
  white-space: nowrap;
  cursor: pointer;
}

.categories button.active {
  background: #7f0000;
  color: white;
  border-color: #7f0000;
}

/* =========================
   GRID PRODUITS MOBILE-FIRST
========================= */
.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
  margin-top: 0.8rem;
}

/* 2 colonnes dès 380px */
@media (min-width: 380px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =========================
   CARD PRODUIT
========================= */
.product-card {
  background: white;
  border-radius: 12px;
  padding: 0.55rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  transition: 0.25s ease;
}

.product-card:hover {
  transform: translateY(-4px);
}

/* Image carrée type Vinted */
.product-img {
  width: 100%;
  aspect-ratio: 1 / 1.2;
  object-fit: cover;
  border-radius: 10px;
}

.product-info {
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.product-price {
  font-size: 1.05rem;
  color: #7f0000;
  font-weight: 800;
}

/* =========================
   ACTIONS CARD
========================= */
.product-actions {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.5rem;
}

.add-cart-btn {
  flex: 1;
  padding: 0.6rem;
  font-size: 0.85rem;
  border-radius: 8px;
  background: #7f0000;
  color: white;
  font-weight: 700;
  border: none;
}

.favorite-icon {
  font-size: 22px;
  color: #7f0000;
  background: none;
  border: none;
  cursor: pointer;
}

/* =========================
   DESKTOP (simple, clean)
========================= */

@media (min-width: 900px) {

  main {
    max-width: 1200px;
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.6rem;
  }
}

@media (min-width: 1200px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}


/* ===========================
   DESKTOP : Search left + Tri right
=========================== */

@media (min-width: 900px) {

  /* Le container passe en ligne */
  .search-filter {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  /* Search devient large */
  #search-input {
    flex: 1;
    height: 48px;
    font-size: 1rem;
  }

  /* Tri compact à droite */
  #price-sort {
    width: 220px;
    height: 48px;
    padding: 0 1rem;
    font-size: 1rem;
    border-radius: 50px;
    margin-left: auto;  /* 🔥 met le tri à droite */
  }

  /* Catégories sous la ligne search/tri */
  .categories-scroll {
    order: 2;
    margin-top: 0.5rem;
  }
}

@media (min-width: 900px) {
  .search-filter {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  #search-input {
    flex: 1;
    height: 48px;
  }

  #price-sort {
    width: 220px;
    height: 48px;
    margin-left: auto;
  }
}

/* =========================
   SEARCH SUGGEST (dropdown)
========================= */
.search-wrap { position: relative; width: 100%; }

.search-suggest{
  position: absolute;
  top: calc(42px + 10px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.8px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.08);
  z-index: 50;
  overflow: hidden;
}

@media (min-width: 900px) {
  .search-suggest{ top: calc(48px + 10px); }
}

.search-suggest-tabs{
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.suggest-tab{
  flex: 1;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1.8px solid #ddd;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}

.suggest-tab.active{
  background: #7f0000;
  border-color: #7f0000;
  color: #fff;
}

.suggest-list{
  max-height: 320px;
  overflow: auto;
  padding: 6px;
}

.suggest-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s ease;
}

.suggest-item:hover{
  background: #f6f6f6;
}

.suggest-avatar{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  background: #eee;
}

.suggest-title{
  font-weight: 800;
  font-size: 0.95rem;
}

.suggest-sub{
  font-size: 0.85rem;
  color: #666;
}

.suggest-price{
  margin-left: auto;
  font-weight: 900;
  color: #7f0000;
}

/* mini vendeur sur carte produit */
.seller-mini{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.seller-avatar{
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #eee;
}

.seller-username{
  font-size: 0.85rem;
  font-weight: 800;
  color: #444;
}

/* MOBILE: search + tri sur une ligne (search plus grande) */
@media (max-width: 520px) {
  .search-filter {
    flex-direction: row;
    gap: 0.6rem;
    align-items: center;
  }

  /* La recherche prend vraiment la place */
  .search-wrap {
    flex: 1 1 auto;
    min-width: 0; /* IMPORTANT sinon l'input refuse de rétrécir correctement */
  }

  #search-input {
    width: 100%;
    height: 46px;
  }

  /* Le tri devient petit et ne vole pas la place */
  #price-sort {
    flex: 0 0 110px;  /* 🔥 largeur fixe + petite */
    width: 110px;
    height: 46px;
    padding: 0 0.6rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  /* dropdown aligné à la nouvelle hauteur */
  .search-suggest {
    top: calc(46px + 10px);
  }
}
