/* ===============================
   GLOBAL
================================ */

*{
  box-sizing:border-box;
}
:root{
  --primary-color:#ff5722;
}
body{
  font-family:-apple-system,BlinkMacSystemFont,sans-serif;
  margin:0;
  background:#f5f6fa;
  padding-bottom:0px;
  -webkit-font-smoothing:antialiased;
}

/* ===============================
   HOME SPACING FIX
================================ */

#app{
  margin-top:1px;   /* 🔥 tạo khoảng hở dưới header */
}
/* ===============================
   HEADER
================================ */
.header{
  background:#fff;
  padding:10px 16px;
  }
.main-header{
  background:#fff;
  padding:12px 16px 8px 16px;
}

.logo{
  font-size:22px;
  font-weight:700;
  text-decoration:none;
  color:#111;
  display:block;
  text-align:center;
  margin-bottom:0px;
}
/* ===============================
   TOP MENU (Below Search)
================================ */

.top-menu{
  display:flex;
  gap:16px;
  justify-content:center;
  flex-wrap:wrap;
  padding:12px 16px;
  background:#fff;
  border-bottom:1px solid #eee;
}

.top-menu a{
  text-decoration:none;
  font-size:14px;
  color:#444;
  font-weight:700;
  padding:6px 8px;
  border-radius:8px;
  transition:all .2s ease;
}

.top-menu a:hover{
  background:#f5f5f5;
  color:#ff5722;
}

/* Mobile scroll ngang nếu dài */
@media (max-width:600px){
  .top-menu{
    overflow-x:auto;
    flex-wrap:nowrap;
    justify-content:flex-start;
    white-space:nowrap;
  }

  .top-menu a{
    flex:0 0 auto;
  }
}
/* ===============================
   SEARCH
================================ */


.search-wrapper{
  position:sticky;
  top:0;
  z-index:999;
  background:#fff;
  padding:8px 16px;
  display:flex;
  align-items:center;

  border-bottom:1px solid transparent; /* 🔥 luôn tồn tại */
  transition:background .2s ease, border-color .2s ease;
}
.search-wrapper.is-sticky{
  border-bottom:1px solid #eee;
  padding:0px 6px;
}


/* Khi sticky bỏ border input */
.search-wrapper.is-sticky .search-box{
  border-color:transparent;
  box-shadow:none;
  background:#fff;
}

/* ===============================
   FORM
================================ */

.search-form{
  position:relative;
  width:100%;
  max-width:900px;
  margin:0 auto;
}

/* ===============================
   INPUT
================================ */

.search-box{
  width:100%;
  height:40px;
  padding:0 48px 0 48px;   /* 🔥 cân trái phải */
  border-radius:16px;
  border:1px solid #ddd;
  font-size:16px;
  outline:none;
  background:#fff;
  transition:.2s ease;
}

.search-box:focus{
  background:#fff;
  border-color:#ff5722; /* màu nút mua */
}

/* ===============================
   BACK BUTTON
================================ */

.back-btn{
  position:absolute;
  left:12px;
  top:50%;
  transform:translateY(-50%);
  border:none;
  background:none;
  cursor:pointer;
  display:none;
  padding:4px;
  color:#555;
}

/* ===============================
   SEARCH BUTTON
================================ */

.search-btn{
  position:absolute;
  right:12px;
  top:50%;
  transform:translateY(-50%);
  border:none;
  background:none;
  cursor:pointer;
  padding:6px;
  color:#666;
  display:flex;
  align-items:center;
  justify-content:center;
}

.search-btn:hover{
  color:#111;
}

/* ===============================
   CLEAR BUTTON
================================ */

.clear-btn{
  position:absolute;
  right:44px;
  top:50%;
  transform:translateY(-50%);
  border:none;
  background:none;
  cursor:pointer;
  display:none;
  color:#999;
  font-size:14px;
}



/* ===============================
   RESPONSIVE
================================ */

/* Tablet */
@media (min-width:640px){
  .search-form{
    max-width:700px;
  }
}

/* Desktop */
@media (min-width:1024px){
  .search-form{
    max-width:900px;
  }
}

/* Màn hình lớn */
@media (min-width:1400px){
  .search-form{
    max-width:1100px;
  }
}
/* ===============================
   PRODUCT GRID
================================ */

/* ===============================
   RESPONSIVE GRID (AUTO)
================================ */

/* ===============================
   MOBILE DEFAULT
================================ */

/* ===============================
   RESPONSIVE GRID (AUTO)
================================ */

.grid{
  display:grid;
  gap:14px;
  padding:16px;
  grid-template-columns:repeat(2, 1fr);   /* 🔥 Mobile mặc định 2 cột */

}
.related-grid{
  display:grid;
  gap:14px;
  padding:16px 1px;
  grid-template-columns:repeat(2, 1fr);   /* 🔥 Mobile mặc định 2 cột */
}
@media (min-width:640px){
  .grid,
  .related-grid{
    grid-template-columns:repeat(3, 1fr);
  }
}

@media (min-width:1024px){
  .grid,
  .related-grid{
    grid-template-columns:repeat(4, 1fr);
  }
}

@media (min-width:1400px){
  .grid,
  .related-grid{
    grid-template-columns:repeat(6, 1fr);
  }
}
.card{
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  text-decoration:none;
  color:#111;
  display:flex;
  flex-direction:column;
  box-shadow:0 3px 12px rgba(0,0,0,.05);
  transition:transform .15s ease;
}

.card:active{
  transform:scale(.98);
}

/* Ảnh luôn vuông, không lệch */
.card img{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  display:block;
}

/* Nội dung card */
.card-content{
  padding:10px 12px 14px;
  display:flex;
  flex-direction:column;
  gap:6px;
  flex:1;
}

/* Giới hạn title 2 dòng */
.card-title{
  font-size:14px;
  line-height:1.4;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  min-height:38px;
}

/* Giá */
.price{
  font-weight:700;
  color:#e53935;
  font-size:15px;
  margin-top:auto;
}

/* ===============================
   PRODUCT PAGE
================================ */

/* ===============================
   FIX PRODUCT TITLE SPACING
================================ */

.product-wrapper{
  padding:20px 16px 16px;
  margin-top:10px;   /* 🔥 tạo khoảng cách với header */
}

.product-title{
  font-size:22px;
  line-height:1.35;
  margin-top:10px;   /* 🔥 tránh sát header */
  margin-bottom:18px;
}

.product-image{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  border-radius:16px;
  display:block;
  margin-bottom:16px;
}

.product-price{
  font-size:20px;
  margin-bottom:16px;
}

.buy-btn{
  display:block;
  background:var(--primary-color);
  color:#fff;
  padding:14px;
  text-align:center;
  border-radius:14px;
  margin-bottom:20px;
  font-weight:600;
  text-decoration:none;
}

/* ===============================
   RELATED PRODUCTS (GRID)
================================ */

.related-title{
  margin-top:30px;
  margin-bottom:16px;
  font-size:18px;
}


.related-card{
  background:#fff;
  border-radius:14px;
  overflow:hidden;
  text-decoration:none;
  color:#111;
  box-shadow:0 2px 8px rgba(0,0,0,.05);
  display:flex;
  flex-direction:column;
}

.related-card img{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
}

.related-card .card-content{
  padding:10px;
}

.related-card .card-title{
  font-size:14px;
  line-height:1.4;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  min-height:38px;
}

.related-card .price{
  margin-top:6px;
  font-weight:700;
  color:#e53935;
}

/* ===============================
   STICKY BUY
================================ */

.sticky-buy{
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  background:#fff;
  padding:5px 16px;
  box-shadow:0 -3px 12px rgba(0,0,0,.1);
}

.sticky-buy a{
  display:block;
  background:#ff5722;
  color:#fff;
  text-align:center;
  padding:15px;
  border-radius:14px;
  font-weight:600;
  text-decoration:none;
  font-size:16px;
}

/* ===============================
   FOOTER
================================ */

.main-footer{
  text-align:center;
  padding:24px 24px 90px 24px;
  background:#fff;
  color:#111;
}

.main-footer a{
  color:#111;
  margin:0 10px;
  text-decoration:none;
  font-size:14px;
  font-weight:700;
}

.footer-extra{
  margin-top:20px;
  font-size:14px;
  opacity:.85;
  line-height:1.6;
}

.footer-extra p{
  margin:6px 0;
}

.product-image{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  border-radius:16px;
  display:block;
  margin-bottom:16px;
}

.product-title{
  font-size:22px;
  line-height:1.3;
  margin-bottom:16px;
}

.desc{
  margin-top:16px;
  line-height:1.6;
  font-size:14px;
  color:#444;
}

.related-title{
  margin:24px 16px 12px;
  font-size:16px;
}

.load-more-btn{
  display:block;
  margin:20px auto 40px;
  padding:14px 24px;
  background:var(--primary-color);
  color:#fff;
  border:none;
  border-radius:12px;
  font-size:16px;
  font-weight:600;
  cursor:pointer;
}
/* Nút clear */
.clear-btn{
  position:absolute;
  right:40px;        /* nằm trước kính lúp */
  top:50%;
  transform:translateY(-50%);
  border:none;
  background:none;
  font-size:16px;
  cursor:pointer;
  display:none;      /* 🔥 mặc định ẩn */
  color:#999;
  padding:4px;
}

.clear-btn:hover{
  color:#111;
}
