/* ==========================================================================
   FMarket — Single Product Page Redesign
   --------------------------------------------------------------------------
   Enqueue: is_product() — xem functions.php
   ========================================================================== */

/* ── Root tokens ──────────────────────────────────────────────────────── */
:root {
  --fms-orange:  #f76c00;
  --fms-yellow:  #ffd166;
  --fms-amber:   #ffa94d;
  --fms-deep:    #0d1b3d;
  --fms-bg:      #FAFAF6;
  --fms-card:    #ffffff;
  --fms-border:  #eceef4;
  --fms-text:    #3c434a;
  --fms-muted:   #7a8499;
  --fms-radius:  14px;
}

/* ── Layout: remove sidebar, reset push-25 offset ───────────────────── */
body.single-product .widget-area,
body.single-product #secondary {
  display: none !important;
}
/* #primary has classes grid-75 + push-25 from unsemantic-grid.min.css.
   push-25 = position:relative; left:25%. We set width:100% but forgot to
   reset left:25%, so the content was shifted 25% right → overflow. */
body.single-product #primary {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  left: 0 !important;
  position: static !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
body.single-product #main {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ── Product container wrapper — target actual Dokani structure ──────── */
/* Dokani wraps WC content in: #primary > #main > article > .inside-article > .entry-content */
/* (no .woocommerce div — that was removed by dokani_setup_woocommerce) */
body.single-product .inside-article {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 48px !important;
  box-sizing: border-box;
}

/* ── Breadcrumb ──────────────────────────────────────────────────────── */
body.single-product .woocommerce-breadcrumb {
  font-size: 13px;
  color: var(--fms-muted);
  margin-bottom: 20px;
}
body.single-product .woocommerce-breadcrumb a {
  color: var(--fms-orange);
  text-decoration: none;
}
body.single-product .woocommerce-breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Two-column product layout ────────────────────────────────────────── */
body.single-product div.product {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "gallery summary"
    "tabs    tabs"
    "related related";
  gap: 28px 32px;
  align-items: start;
}

/* ── Gallery ─────────────────────────────────────────────────────────── */
body.single-product .woocommerce-product-gallery {
  grid-area: gallery;
  position: sticky;
  top: 80px;
  border-radius: var(--fms-radius);
  overflow: hidden;
  background: #f5f6fa;
}
/* Ensure FlexSlider chain fills full width */
body.single-product .woocommerce-product-gallery,
body.single-product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper,
body.single-product .woocommerce-product-gallery ul.slides,
body.single-product .woocommerce-product-gallery ul.slides li,
body.single-product .woocommerce-product-gallery figure {
  width: 100% !important;
  margin: 0;
}
/* Main image */
body.single-product .woocommerce-product-gallery img {
  width: 100% !important;
  height: auto !important;
  max-height: 520px;
  border-radius: var(--fms-radius);
  object-fit: cover;
  display: block;
  box-shadow: 0 6px 28px rgba(13, 27, 61, 0.10);
}
/* Thumbnails strip */
body.single-product .flex-control-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 0;
  list-style: none;
}
body.single-product .flex-control-thumbs li {
  margin: 0;
}
body.single-product .flex-control-thumbs li img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, opacity 0.2s;
  opacity: 0.7;
}
body.single-product .flex-control-thumbs li img.flex-active,
body.single-product .flex-control-thumbs li img:hover {
  border-color: var(--fms-orange);
  opacity: 1;
}
/* Sale badge */
body.single-product .woocommerce-product-gallery .onsale {
  top: 12px;
  left: 12px;
  background: var(--fms-orange);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  color: #fff;
  min-height: 0;
  line-height: 1.4;
}

/* ── Summary card ────────────────────────────────────────────────────── */
body.single-product .summary.entry-summary {
  grid-area: summary;
  background: var(--fms-card);
  border-radius: var(--fms-radius);
  padding: 22px 20px 20px;
  box-shadow: 0 4px 28px rgba(13, 27, 61, 0.07);
  border: 1px solid var(--fms-border);
  min-width: 0;
  width: 100%;
  align-self: start;
}

/* Product title */
body.single-product .product_title.entry-title {
  font-size: 20px !important;
  line-height: 1.35 !important;
  font-weight: 800;
  color: var(--fms-deep);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

/* Rating */
body.single-product .woocommerce-product-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
body.single-product .star-rating {
  color: var(--fms-amber) !important;
  font-size: 13px;
}
body.single-product .woocommerce-review-link {
  font-size: 12px;
  color: var(--fms-muted);
}

/* Price */
body.single-product p.price,
body.single-product span.price {
  font-size: 30px !important;
  font-weight: 800 !important;
  color: var(--fms-orange) !important;
  display: block;
  margin: 0 0 16px !important;
  line-height: 1.2;
}
body.single-product p.price del,
body.single-product span.price del {
  font-size: 16px !important;
  color: var(--fms-muted) !important;
  font-weight: 400 !important;
  margin-right: 8px;
  opacity: 0.7;
}
body.single-product p.price ins,
body.single-product span.price ins {
  text-decoration: none !important;
  font-size: 30px !important;
  font-weight: 800 !important;
  color: var(--fms-orange) !important;
}

/* Short description divider */
body.single-product .woocommerce-product-details__short-description {
  font-size: 14px;
  color: var(--fms-text);
  line-height: 1.7;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--fms-border);
}
body.single-product .woocommerce-product-details__short-description p {
  margin-bottom: 8px;
}

/* ── Add-to-cart form ────────────────────────────────────────────────── */
body.single-product form.cart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Quantity row */
body.single-product form.cart .quantity {
  display: flex;
  align-items: center;
  background: var(--fms-bg);
  border-radius: 10px;
  border: 1px solid var(--fms-border);
  overflow: hidden;
  width: fit-content;
  height: 44px;
}
body.single-product form.cart .quantity input[type="number"] {
  width: 60px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--fms-deep);
  -moz-appearance: textfield;
  outline: none;
  height: 100%;
}
body.single-product form.cart .quantity input::-webkit-outer-spin-button,
body.single-product form.cart .quantity input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* Add-to-cart button */
body.single-product .single_add_to_cart_button,
body.single-product button.single_add_to_cart_button {
  width: 100%;
  background: linear-gradient(135deg, var(--fms-yellow) 0%, var(--fms-amber) 100%);
  color: var(--fms-deep);
  font-weight: 700;
  font-size: 16px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(255, 169, 77, 0.35);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}
body.single-product .single_add_to_cart_button::before {
  content: "🛒";
  font-size: 18px;
}
body.single-product .single_add_to_cart_button:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 169, 77, 0.5);
}
body.single-product .single_add_to_cart_button.loading {
  opacity: 0.75;
  transform: none;
}

/* Variations (variable products) */
body.single-product .variations {
  width: 100%;
  border: none;
  margin-bottom: 16px;
}
body.single-product .variations td,
body.single-product .variations th {
  border: none;
  padding: 0;
}
body.single-product .variations .label label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fms-deep);
  display: block;
  margin-bottom: 6px;
}
body.single-product .variations select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--fms-border);
  background: var(--fms-bg);
  font-size: 14px;
  color: var(--fms-text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
body.single-product .variations select:focus {
  border-color: var(--fms-amber);
}

/* Reset variation link */
body.single-product .reset_variations {
  font-size: 12px;
  color: var(--fms-muted);
  text-decoration: none;
}

/* ── Product meta (vendor, categories, tags) ──────────────────────── */
body.single-product .product_meta {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--fms-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}
body.single-product .product_meta > span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fms-muted);
}
body.single-product .product_meta > span::before {
  font-size: 14px;
}
body.single-product .product_meta .posted_in::before   { content: "📂"; }
body.single-product .product_meta .tagged_as::before   { content: "🏷️"; }
body.single-product .product_meta .sku_wrapper::before  { content: "🔖"; }
body.single-product .product_meta a {
  color: var(--fms-orange);
  text-decoration: none;
  font-weight: 500;
}
body.single-product .product_meta a:hover {
  text-decoration: underline;
}

/* ── Vendor info box (WC Vendors / Dokan compatible) ─────────────── */
body.single-product .fms-vendor-box {
  background: linear-gradient(135deg, #fff8ee 0%, #fff 100%);
  border: 1px solid #ffe7c0;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
body.single-product .fms-vendor-box .fms-vendor-ico {
  font-size: 28px;
  flex-shrink: 0;
}
body.single-product .fms-vendor-box .fms-vendor-info {
  font-size: 13px;
  color: var(--fms-text);
}
body.single-product .fms-vendor-box .fms-vendor-name {
  font-weight: 700;
  color: var(--fms-deep);
  font-size: 15px;
}
body.single-product .fms-vendor-box .fms-vendor-hint {
  color: var(--fms-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
body.single-product .woocommerce-tabs {
  grid-area: tabs;
  min-width: 0;
  background: var(--fms-card);
  border-radius: var(--fms-radius);
  border: 1px solid var(--fms-border);
  box-shadow: 0 2px 14px rgba(13, 27, 61, 0.04);
  overflow: hidden;
}
body.single-product .woocommerce-tabs ul.tabs {
  background: var(--fms-bg);
  border-bottom: 1px solid var(--fms-border);
  padding: 0 20px;
  margin: 0;
  display: flex;
  gap: 0;
  list-style: none;
}
body.single-product .woocommerce-tabs ul.tabs li {
  margin: 0;
  border: none;
  background: transparent;
}
body.single-product .woocommerce-tabs ul.tabs li a {
  display: block;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fms-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  position: relative;
  bottom: -1px;
}
body.single-product .woocommerce-tabs ul.tabs li.active a {
  color: var(--fms-orange);
  border-bottom-color: var(--fms-orange);
  background: transparent;
}
body.single-product .woocommerce-tabs ul.tabs li a:hover {
  color: var(--fms-orange);
}
body.single-product .woocommerce-tabs .panel {
  padding: 24px 28px;
  font-size: 14px;
  color: var(--fms-text);
  line-height: 1.8;
}
body.single-product .woocommerce-tabs .panel h2 {
  font-size: 17px;
  color: var(--fms-deep);
  margin-bottom: 16px;
  font-weight: 700;
  display: none; /* ẩn heading lặp — tab label đã rõ ràng */
}

/* ── Related products ───────────────────────────────────────────── */
body.single-product .related.products {
  grid-area: related;
  min-width: 0;
}
body.single-product .related.products > h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--fms-deep);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--fms-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
body.single-product .related.products > h2::before {
  content: "🛍️";
  font-size: 18px;
}
body.single-product .related.products ul.products,
body.single-product .upsells.products ul.products {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 8px !important;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (max-width: 768px) {
  body.single-product .related.products ul.products,
  body.single-product .upsells.products ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Notices / messages ─────────────────────────────────────────── */
body.single-product .woocommerce-message,
body.single-product .woocommerce-info {
  border-top-color: var(--fms-amber);
  background: #fff8ee;
  border-radius: 8px;
  font-size: 14px;
}
body.single-product .woocommerce-message a.button,
body.single-product .woocommerce-info a.button {
  background: var(--fms-orange);
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Upsells section ────────────────────────────────────────────── */
body.single-product .upsells.products > h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--fms-deep);
  margin-bottom: 18px;
}
body.single-product .upsells.products ul.products {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ── Minimal horizontal cards (related/upsells) ───────────────── */
body.single-product .related .products li.product,
body.single-product .upsells .products li.product {
  background: var(--fms-card);
  border-radius: 10px;
  border: 1px solid var(--fms-border);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(13,27,61,.05);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch;
  float: none !important;
  width: 100% !important;
}
body.single-product .related .products li.product:hover,
body.single-product .upsells .products li.product:hover {
  box-shadow: 0 4px 14px rgba(13,27,61,.12);
  border-color: #d0d4e0;
}
/* Grid layout: image | info */
body.single-product .related .products li.product a.woocommerce-loop-product__link,
body.single-product .upsells .products li.product a.woocommerce-loop-product__link {
  display: grid !important;
  grid-template-columns: 72px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding: 8px 10px 8px 8px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
/* Image 72×72 */
body.single-product .related .products li.product a img,
body.single-product .upsells .products li.product a img {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 72px !important;
  height: 72px !important;
  aspect-ratio: unset !important;
  object-fit: cover !important;
  border-radius: 6px;
  display: block;
  align-self: center;
  transition: opacity 0.2s ease;
}
body.single-product .related .products li.product:hover a img,
body.single-product .upsells .products li.product:hover a img {
  opacity: 0.9;
}
/* Title */
body.single-product .related .products li.product .woocommerce-loop-product__title,
body.single-product .upsells .products li.product .woocommerce-loop-product__title {
  grid-column: 2;
  grid-row: 1;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--fms-deep) !important;
  padding: 0 !important;
  margin: 0 0 3px !important;
  line-height: 1.4;
  white-space: normal !important;
  overflow: hidden;
  text-overflow: unset !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  align-self: end;
}
/* Price */
body.single-product .related .products li.product .price,
body.single-product .upsells .products li.product .price {
  grid-column: 2;
  grid-row: 2;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--fms-orange) !important;
  padding: 0 !important;
  margin: 0 !important;
  display: block;
  align-self: start;
}

/* ── Mobile responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  body.single-product div.product {
    grid-template-columns: 1fr;
    grid-template-areas:
      "gallery"
      "summary"
      "tabs"
      "related";
    gap: 20px;
  }
  body.single-product .woocommerce-product-gallery {
    position: static;
  }
  body.single-product .summary.entry-summary {
    padding: 20px 16px;
  }
  body.single-product p.price,
  body.single-product span.price {
    font-size: 24px !important;
  }
  body.single-product .product_title.entry-title {
    font-size: 19px;
  }
  body.single-product .woocommerce-tabs .panel {
    padding: 16px 16px;
  }
}

@media (max-width: 480px) {
  body.single-product .related.products ul.products,
  body.single-product .upsells.products ul.products {
    grid-template-columns: 1fr !important;
  }
}
