/* CSS cho trang Sản phẩm và Chi tiết sản phẩm */
:root {
  --product-primary: #062f2b;
  --product-secondary: #0d4b44;
  --product-accent: #d2b26b;
  --product-bg-light: #f4f7f6;
  --product-text: #17312d;
  --product-text-muted: #5e7a76;
  --product-card-bg: #f9f4ec;
}

body,
.products-page,
.product-detail-page {
  background: #ffffff !important;
  color: var(--product-text);
  font-family: var(--font-ui), sans-serif;
  margin: 0;
}

.product-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Hero Section */
.product-hero {
  height: 550px !important;
  background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url("../images/PNG/prod_banner_3.png");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  color: #ffffff;
}

.product-hero__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.product-hero__text {
  max-width: 500px;
}

.product-hero__text h1 {
  font-family: var(--font-display, serif);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.1;
  margin: 0 0 20px;
  text-transform: uppercase;
}

.product-hero__text p {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 30px;
  opacity: 0.9;
}

.product-hero__image {
  max-width: 500px;
}

.product-hero__image img {
  width: 100%;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
}

.product-hero .breadcrumb {
  margin-top: 40px;
  font-size: 14px;
  color: #ffffff;
  opacity: 0.8;
}

.product-hero .breadcrumb a {
  color: #ffffff;
  text-decoration: none;
}

.product-hero .breadcrumb span {
  font-weight: 700;
  color: var(--product-accent);
}

/* Main Layout Grid */
.product-main {
  padding: 80px 0;
}

.product-grid-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
}

/* Sidebar Filters */
.product-sidebar {
  display: flex;
  flex-direction: column;
}

.filter-widget h3 {
  font-size: 18px;
  color: var(--product-primary);
  margin-bottom: 20px;
  font-weight: 800;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

/* Price Range */
.price-range-slider {
  padding: 10px 0;
}

.range-track {
  height: 4px;
  background: #eee;
  position: relative;
  border-radius: 2px;
}

.range-fill {
  position: absolute;
  height: 100%;
  background: var(--product-accent);
  left: 10%;
  right: 10%;
}

.range-handle {
  width: 12px;
  height: 12px;
  background: var(--product-primary);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.price-values {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  font-size: 13px;
  color: #666;
}

.btn-filter-apply {
  background: var(--product-primary);
  color: #ffffff;
  border: 0;
  padding: 6px 15px;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 15px;
  cursor: pointer;
}

/* Categories List */
.category-list {
  list-style: none;
  padding: 0;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  cursor: pointer;
}

.category-item input {
  cursor: pointer;
}

/* Expert Support Widget */
.expert-support-widget {
  background: #def4f0;
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: 300px;
  margin-top: 30px;
}

.expert-face {
  position: absolute;
  bottom: 0;
  left: -10px;
  height: 90%;
  width: auto;
  z-index: 1;
  object-fit: contain;
}

.expert-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  z-index: 2;
  position: relative;
}

.expert-info h4 {
  font-size: 20px;
  color: #0d423b;
  line-height: 1.2;
  margin: 10px 0 30px;
  max-width: 150px;
  font-weight: 800;
  border-bottom: none;
}

.expert-info p {
  font-size: 13px;
  font-weight: 700;
  color: #0d423b;
  line-height: 1.4;
}

.expert-phone {
  background: #ffffff;
  border: 1px solid #0d423b33;
  border-radius: 30px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0d423b;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  margin-top: auto;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.expert-phone img {
  width: 18px;
  height: 18px;
}

/* Toolbar (Sort) */
.product-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
}

.sort-label {
  font-size: 14px;
  color: #666;
}

.sort-select {
  border: 1px solid #eee;
  padding: 8px 15px;
  border-radius: 6px;
  outline: none;
}

/* Product Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
}

.product-card {
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
}

.product-card__image {
  background: var(--product-card-bg);
  height: 300px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.product-card__image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.badge-sale,
.badge-hot {
  position: absolute;
  top: 15px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
}

.badge-sale {
  background: #27937f;
  left: 15px;
}

.badge-hot {
  background: #d88a7a;
  right: 15px;
}

.product-card__btn {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

/* Nút mua ngay thiết kế mới */
.product-card .s4-buy-btn {
  background: #ffffff;
  border: 1px solid #0d423b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  height: 44px;
}

.product-card .s4-buy-text {
  padding: 0 15px;
  font-size: 13px;
  font-weight: 700;
  color: #0d423b;
  text-transform: none;
}

.product-card .s4-buy-icon-wrap {
  background: #0d423b;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card .s4-buy-icon {
  width: 20px;
  filter: brightness(0) invert(1);
}

.product-card__info {
  padding: 35px 25px 25px;
  /* Tăng padding top để nhường chỗ cho nút */
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.product-card__info h3 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.4;
  font-weight: 700;
}

.product-card__info h3 a {
  color: var(--product-primary);
  text-decoration: none;
}

.product-price {
  font-weight: 700;
  font-size: 16px;
  color: #d88a7a;
}

.price-old {
  font-size: 13px;
  color: #999;
  text-decoration: line-through;
  margin-right: 8px;
  font-weight: 400;
}

.price-new {
  color: #d88a7a;
}

/* Detail Page */
.product-detail-main {
  padding: 40px 0 0 0;
}

.product-detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  /* Thu hẹp phần bên phải (info) một chút */
  gap: 60px;
  margin-bottom: 80px;
  align-items: flex-start;
}

/* Gallery */
.product-gallery {
  display: flex;
  gap: 30px;
}

.gallery-thumbs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 160px;
  /* Tăng độ rộng để hình thu nhỏ to hơn */
  height: 100%;
}

.thumb-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  justify-content: center;
}

.thumb-nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--product-secondary);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  z-index: 5;
  color: var(--product-secondary);
}

.thumb-nav:hover {
  background: var(--product-secondary);
  color: #ffffff;
}

.thumb-nav svg {
  display: block;
}

.thumb-item {
  width: 160px;
  height: 160px;
  border: 1px solid #eee;
  border-radius: 15px;
  overflow: hidden;
  cursor: pointer;
  background: var(--product-card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  transition: all 0.2s;
}

.thumb-item.active {
  border-color: var(--product-secondary);
  border-width: 2px;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-main {
  flex: 1;
  aspect-ratio: 1 / 1;
  /* Đảm bảo là hình vuông */
  background: #064038;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* Thêm border nhẹ */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow: hidden;
}

.gallery-main img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: auto;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.2));
  transition: opacity 0.3s ease;
}

/* Summary */
.product-summary h1 {
  font-size: 32px;
  margin: 0 0 10px;
  color: var(--product-primary);
}

.product-subtitle {
  font-size: 16px;
  color: #666;
  margin-bottom: 25px;
}

.detail-price {
  font-size: 28px;
  font-weight: 800;
  color: #d88a7a;
  margin-bottom: 30px;
}

.detail-options {
  margin-bottom: 30px;
}

.option-group {
  margin-bottom: 20px;
}

.option-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.option-list {
  display: flex;
  gap: 10px;
}

.option-btn {
  border: 1px solid #eee;
  padding: 8px 20px;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.option-btn.active {
  background: var(--product-secondary);
  color: #ffffff;
  border-color: var(--product-secondary);
}

.purchase-actions {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 40px;
}

.quantity-box {
  display: flex;
  align-items: center;
  border: 1px solid #eee;
  border-radius: 8px;
  height: 45px;
}

.qty-btn {
  width: 40px;
  height: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 18px;
}

.qty-input {
  width: 50px;
  border: 0;
  text-align: center;
  font-weight: 700;
}

.buy-now-btn {
  flex: 1;
  height: 45px;
  background: var(--product-secondary);
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.buy-now-btn img {
  width: 20px;
  filter: brightness(0) invert(1);
}

.product-policy-box {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 30px;
}

.policy-badges {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: #ffffff;
}

.policy-divider {
  width: 1px;
  height: 30px;
  background: #e0e0e0;
  margin: 0 20px;
}

.policy-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #064038;
  font-weight: 600;
  line-height: 1.3;
}

.policy-item img {
  width: 28px;
}

.promo-note {
  background: #f8cc84;
  padding: 8px 20px;
  font-size: 13px;
  color: #6d542b;
  font-weight: 700;
}

/* Tabs */
.product-tabs {
  padding-top: 50px;
}

.tabs-nav {
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: none;
}

.tab-divider {
  color: #064038;
  font-weight: 300;
  opacity: 0.5;
}

.tab-link {
  padding-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #999;
  text-decoration: none;
  position: relative;
  transition: color 0.2s;
}

.tab-link.active {
  color: #064038;
}

.tab-border {
  height: 2px;
  background: #06473f;
  width: 100%;
  margin-bottom: 40px;
}

.tab-content {
  line-height: 1.8;
  color: #444;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

#detail-description-display {
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

/* ── Markdown rendered content styles ── */
#detail-description-display h1,
#detail-description-display h2,
#detail-description-display h3,
#detail-description-display h4,
#detail-description-display h5,
#detail-description-display h6 {
  color: var(--product-primary);
  font-weight: 800;
  margin: 32px 0 12px;
  line-height: 1.3;
}

#detail-description-display h1 {
  font-size: 26px;
  border-bottom: 2px solid var(--product-accent);
  padding-bottom: 8px;
}

#detail-description-display h2 {
  font-size: 22px;
  border-bottom: 1px solid #e8e0d4;
  padding-bottom: 6px;
}

#detail-description-display h3 {
  font-size: 18px;
}

#detail-description-display h4 {
  font-size: 16px;
}

#detail-description-display p {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.8;
}

#detail-description-display strong {
  color: var(--product-primary);
}

#detail-description-display em {
  color: #666;
}

/* Blockquote */
#detail-description-display blockquote {
  border-left: 4px solid var(--product-accent);
  background: #faf8f3;
  margin: 20px 0;
  padding: 14px 20px;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #666;
}

/* Code */
#detail-description-display code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #c7254e;
}

/* Horizontal rule */
#detail-description-display hr {
  border: none;
  border-top: 1px solid #e8e0d4;
  margin: 30px 0;
}

/* Lists */
#detail-description-display ul,
#detail-description-display ol {
  padding-left: 24px;
  margin: 0 0 16px;
}

#detail-description-display li {
  margin-bottom: 6px;
  font-size: 15px;
}

/* Table */
#detail-description-display table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 30px;
  font-size: 14px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#detail-description-display thead tr {
  background: var(--product-primary);
  color: #fff;
  font-weight: 700;
}

#detail-description-display thead th {
  padding: 12px 16px;
  text-align: left;
}

#detail-description-display tbody tr:nth-child(odd) {
  background: #f9f6f0;
}

#detail-description-display tbody tr:nth-child(even) {
  background: #fff;
}

#detail-description-display tbody tr:hover {
  background: #f0ebe1;
  transition: background 0.15s;
}

#detail-description-display td {
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  color: #444;
}

/* Images inside markdown — constrained to container width */
#detail-description-display img {
  display: block;
  max-width: 100% !important;
  width: 100%;
  height: auto !important;
  object-fit: contain;
  margin: 24px auto;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

.tab-content h4 {
  margin: 30px 0 10px;
  color: var(--product-primary);
}

/* Related Section */
.related-products-section {
  background: #fafafa;
}

.related-products-section h2 {
  text-align: left;
  margin-bottom: 50px;
  font-size: 28px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 40px;
  padding: 10px 20px;
  background: #f0f0f0;
  border-radius: 8px;
  text-decoration: none;
  color: #666;
  font-weight: 700;
  font-size: 14px;
}

/* Responsive */
/* Tablet (768px - 1080px) */
@media (min-width: 768px) and (max-width: 1080px) {
  .product-grid-layout {
    grid-template-columns: 240px 1fr;
    gap: 20px;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 50px;
  }

  .product-gallery {
    max-width: 700px;
    margin: 0 auto !important;
    width: 100%;
  }

  .product-summary {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
  }
}

/* Mobile (< 767px) */
@media (max-width: 767px) {
  .product-container {
    padding: 0 15px;
  }

  .product-hero {
    height: auto !important;
    min-height: 580px !important;
    padding: 60px 20px 40px !important;
    background-position: 75% bottom !important;
    background-size: cover !important;
    display: flex !important;
    align-items: flex-start !important;
  }

  .product-hero__inner {
    flex-direction: column !important;
    text-align: left !important;
    align-items: flex-start !important;
  }

  .product-hero__text {
    max-width: 100% !important;
  }

  .product-hero__text h1 {
    color: #ffffff !important;
    font-size: 28px !important;
    line-height: 1.2 !important;
    margin-bottom: 16px !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
  }

  .product-hero__text p {
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    margin-bottom: 20px !important;
    max-width: 100% !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5) !important;
  }

  .product-hero .breadcrumb {
    font-size: 13px !important;
    margin-top: 20px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    color: #ffffff !important;
  }

  .product-hero .breadcrumb a {
    color: #ffffff !important;
    text-decoration: none !important;
  }

  .product-hero .breadcrumb span {
    color: #ffd880 !important; /* Brighter gold color */
  }

  .product-hero__image {
    margin-top: 30px !important;
    max-width: 100% !important;
    text-align: center !important;
  }

  .product-grid-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 30px !important;
  }

  .product-sidebar {
    display: contents !important;
  }

  /* Specific widget ordering in the overall grid */
  .product-sidebar .filter-widget:nth-of-type(3) {
    order: 1 !important;
    /* Search box */
    margin-bottom: 30px !important;
  }

  .product-sidebar .filter-widget:nth-of-type(1) {
    order: 2 !important;
    /* Advanced Filter */
    margin-bottom: 30px !important;
  }

  .product-sidebar .filter-widget:nth-of-type(2) {
    order: 3 !important;
    /* Categories */
    margin-bottom: 30px !important;
  }

  .product-content {
    order: 4 !important;
    /* Products and Pagination */
  }

  .expert-support-widget {
    order: 5 !important;
    /* Move to the absolute bottom */
    min-height: auto !important;
    padding: 30px 20px !important;
    margin: 20px auto 0 !important;
    max-width: 350px !important;
    width: 100% !important;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .product-gallery {
    flex-direction: column-reverse !important;
    gap: 20px !important;
  }

  .gallery-thumbs {
    flex-direction: row !important;
    width: 100% !important;
    height: auto !important;
    overflow: hidden !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 0 !important;
  }

  .thumb-list {
    flex-direction: row !important;
    gap: 15px !important;
    overflow-x: auto !important;
    flex: 1 !important;
    padding: 0 10px !important;
    scrollbar-width: none !important;
    /* Hide scrollbar */
  }

  .thumb-list::-webkit-scrollbar {
    display: none !important;
  }

  .thumb-item {
    width: 80px !important;
    height: 80px !important;
    flex-shrink: 0 !important;
  }

  .thumb-nav {
    transform: rotate(-90deg) !important;
    flex-shrink: 0 !important;
    width: 32px !important;
    height: 32px !important;
  }

  .gallery-main {
    padding: 20px;
  }

  .purchase-actions {
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 15px !important;
  }

  .quantity-box {
    width: auto !important;
    min-width: 110px !important;
    height: 48px !important;
  }

  .buy-now-btn {
    flex: 1 !important;
    height: 48px !important;
    margin: 0 !important;
  }

  .tabs-nav {
    gap: 20px;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 10px;
  }

  .tab-link {
    font-size: 15px;
    white-space: nowrap;
  }

  .ys-toolbar {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .ys-toolbar > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .ys-sort-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .ys-sort-tab {
    flex: 0 0 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    justify-content: center !important;
    text-align: center !important;
  }
}