/*
 Theme Name: Affiliate168 Child
 Theme URI: https://affiliate168.com
 Description: Child theme for GeneratePress used by Affiliate168
 Author: Thanarak
 Template: generatepress
 Version: 1.0.0
 Text Domain: affiliate168-child
*/

/* ---------- Utilities ---------- */
.container{max-width:1200px;margin:0 auto;padding:0 20px}
.section-pad{padding:56px 0}
.section-pad.alt{background:#f8fafc}
.bg-white{background:#fff}
.muted{color:#6b7280}

/* ---------- Hero ---------- */
.hero-wrap{
  background: linear-gradient(180deg,#f7f9fc,#fff);
  padding:72px 0 48px;
  margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
}
.hero-badges{display:flex;gap:8px;justify-content:center;margin-bottom:8px;flex-wrap:wrap}
.badge{background:#eef2ff;color:#1a3a6e;border-radius:999px;padding:6px 10px;font-weight:700;font-size:.85rem}
.hero-title{font-size:44px;font-weight:800;color:#1a3a6e;margin:6px 0 8px}
.hero-sub{font-size:18px;color:#4b5563;margin:0 0 18px}
.hero-ctas{display:flex;gap:12px;justify-content:center;flex-wrap:wrap}
.hero-cta{display:inline-block;padding:12px 18px;border-radius:999px;font-weight:700;text-decoration:none;transition:.15s}
.hero-cta.primary{background:#FF5722;color:#fff;box-shadow:0 8px 20px rgba(255,87,34,.25)}
.hero-cta.primary:hover{transform:translateY(-2px);filter:brightness(1.05)}
.hero-cta.ghost{border:2px solid #FF5722;color:#FF5722}
.hero-cta.ghost:hover{background:#fff2ee}

/* ---------- Headings ---------- */
.h-section-title{font-weight:800;color:#1a3a6e;text-align:center;margin:0 0 22px}
.h-section-title .mark{color:#c41e24}
.h-section-title::after{content:'';display:block;width:72px;height:4px;border-radius:3px;background:#c41e24;margin:10px auto 0}

/* ---------- Reasons ---------- */
.reasons-grid{display:grid;gap:16px;grid-template-columns:repeat(3,minmax(0,1fr))}
.reason-card{background:#fff;border:1px solid #eef2f7;border-radius:16px;padding:18px;box-shadow:0 8px 24px rgba(0,0,0,.06);text-align:center}
.reason-ic{font-size:28px}
.reason-ttl{font-weight:800;margin:6px 0 4px}
.reason-txt{color:#444}
@media (max-width:900px){.reasons-grid{grid-template-columns:1fr}}

/* ---------- Categories ---------- */
.cat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px}
.cat-card{display:block;background:#fff;border:1px solid #eef2f7;border-radius:12px;overflow:hidden;text-decoration:none;transition:transform .18s, box-shadow .18s}
.cat-card:hover{transform:translateY(-3px);box-shadow:0 10px 24px rgba(0,0,0,.08)}
.cat-card img{width:100%;height:160px;object-fit:cover;display:block}
.cat-meta{padding:12px}
.cat-name{font-weight:800;color:#1a3a6e;margin-bottom:2px}
.cat-count{color:#6b7280;font-size:.9rem}

/* ---------- Product Grid (เฉพาะในหน้าแรก) ---------- */
.product-grid .products{display:grid !important;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px;margin:0;padding:0}
@media (max-width:1024px){.product-grid .products{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:768px){.product-grid .products{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:480px){.product-grid .products{grid-template-columns:1fr}}

.product-grid ul.products li.product{
  float:none !important; width:auto !important; margin:0 !important; list-style:none !important;
  display:flex;flex-direction:column;background:#fff;border-radius:16px;box-shadow:0 8px 22px rgba(0,0,0,.06);
  padding:14px 14px 16px; transition:transform .15s, box-shadow .15s; overflow:hidden;
}
.product-grid ul.products li.product:hover{transform:translateY(-2px);box-shadow:0 12px 30px rgba(0,0,0,.10)}
.product-grid ul.products li.product a.woocommerce-LoopProduct-link img{
  width:100%; aspect-ratio:1/1; object-fit:contain; background:#f7f9fc; border-radius:12px;
}
.product-grid ul.products li.product .woocommerce-loop-product__title{
  font-size:1.05rem;font-weight:700;color:#1a3a6e;margin:10px 2px 6px;line-height:1.35;
  display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:2.8em;
}
.product-grid ul.products li.product .price{color:#c41e24;font-weight:800;margin:2px 2px 8px}
.product-grid ul.products li.product a.button{margin-top:auto;background:#FF5722 !important;color:#fff !important;border-radius:10px;padding:10px 16px;font-weight:700;box-shadow:0 6px 14px rgba(255,87,34,.25);transition:transform .15s, filter .15s}
.product-grid ul.products li.product a.button:hover{transform:translateY(-2px);filter:brightness(1.04)}

.more-cta{display:flex;justify-content:center;margin-top:14px}
.btn-outline{display:inline-block;border:2px solid #1a3a6e;color:#1a3a6e;border-radius:999px;padding:10px 16px;font-weight:700;text-decoration:none}
.btn-outline:hover{background:#eef2ff}

/* ---------- CTA ---------- */
.cta-wrap{background:linear-gradient(135deg,#f8fafc 0%, #e2e8f0 100%)}
.cta-title{font-size:28px;font-weight:800;color:#1a3a6e;margin:0 0 8px}
.cta-sub{color:#4b5563;margin:0 0 18px}

/* ---------- Compare Table ---------- */
.compare-table table{width:100%;border-collapse:collapse;margin-top:20px;box-shadow:0 6px 18px rgba(0,0,0,.06);border-radius:12px;overflow:hidden;background:#fff}
.compare-table th,.compare-table td{padding:14px 16px;text-align:center;border-bottom:1px solid #e5e7eb}
.compare-table th{background:#f7f9fc;font-weight:800;color:#1a3a6e}
.compare-table tr:hover td{background:#f9fafb}
.compare-table td:first-child{font-weight:700;color:#111827;text-align:left}

/* ---------- Small screens ---------- */
@media (max-width:768px){
  .hero-title{font-size:36px}
  .section-pad{padding:44px 0}
}

/* ---------- Accessibility & helpers (Appended) ---------- */
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.sr-only-focusable:active,.sr-only-focusable:focus{position:static!important;width:auto;height:auto;margin:0;overflow:visible;clip:auto;white-space:normal}

/* ===== Aff168 Sale Badge on Single Product ===== */
.woocommerce div.product .aff-sale-badge{
  position:absolute; top:10px; left:10px; z-index:3;
  display:inline-block;
  background:#F9C74F; /* เหลืองแบบ Shopee */
  color:#5b3b00;
  padding:8px 10px 6px;
  border-radius:8px 8px 8px 0;
  font-weight:800; line-height:1; font-size:13px;
  box-shadow:0 6px 16px rgba(0,0,0,.12);
}
.woocommerce div.product .aff-sale-badge strong{ font-weight:900 }

/* ให้กรอบภาพเป็นตำแหน่งอิงสำหรับ badge */
.woocommerce div.product div.images{ position:relative }

/* ซ่อน badge เดิมให้หมด */
.woocommerce span.onsale{ display:none !important; }

/* ===== Aff168 Pro Sale Badge (Single Product) ===== */
/* วาง badge ที่มุมขวาบนของรูป + สไตล์ริบบิ้นพรีเมียม */
.woocommerce div.product .aff-sale-badge{
  position: absolute;
  top: 14px; right: 14px; left: auto !important; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px 9px;
  border-radius: 12px;
  font-weight: 800; line-height: 1; font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #FFB800 0%, #F59E0B 45%, #F59E0B 55%, #D97706 100%);
  box-shadow: 0 10px 24px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.25);
  transform: translateZ(0);
}

/* ตัวเลข % ใหญ่ เด่น */
.woocommerce div.product .aff-sale-badge strong{
  font-weight: 900; font-size: 15px; letter-spacing: .2px;
}

/* รอยพับริบบิ้นขวาล่าง */
.woocommerce div.product .aff-sale-badge::after{
  content: "";
  position: absolute;
  right: 10px; bottom: -8px;
  border-width: 8px 8px 0 8px;
  border-style: solid;
  border-color: #C2410C transparent transparent transparent; /* เฉดเข้มของพื้นหลัง */
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.12));
}

/* เพิ่มแอนิเมชันเล็กน้อยเวลา hover ที่รูป */
.woocommerce div.product div.images:hover .aff-sale-badge{
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.25);
}

/* ให้กรอบภาพเป็นตำแหน่งอ้างอิง */
.woocommerce div.product div.images{ position: relative }

/* กันป้ายเดิม "Sale!" ของธีม */
.woocommerce span.onsale{ display: none !important; }

/* รองรับจอเล็ก */
@media (max-width: 480px){
  .woocommerce div.product .aff-sale-badge{
    top: 10px; right: 10px;
    padding: 9px 12px 8px; border-radius: 10px; font-size: 12px;
  }
  .woocommerce div.product .aff-sale-badge strong{ font-size: 14px; }
}

/* Compare table when class is applied directly on <table> */
table.compare-table{width:100%;border-collapse:collapse;margin-top:20px;box-shadow:0 6px 18px rgba(0,0,0,.06);border-radius:12px;overflow:hidden;background:#fff}
table.compare-table th,table.compare-table td{padding:14px 16px;text-align:center;border-bottom:1px solid #e5e7eb}
table.compare-table th{background:#f7f9fc;font-weight:800;color:#1a3a6e}
table.compare-table tr:hover td{background:#f9fafb}
table.compare-table td:first-child{font-weight:700;color:#111827;text-align:left}

/* Buy button inside compare table */
.compare-table .buy-btn{
  display:inline-block;background:#FF5722;color:#fff;padding:10px 18px;border-radius:999px;font-weight:700;text-decoration:none;transition:.2s;box-shadow:0 6px 14px rgba(255,87,34,.25)
}
.compare-table .buy-btn:hover{background:#e64a19;transform:translateY(-2px)}

/* ===== Shop Pro Layout (Archive / Category) ===== */

/* ซ่อน Sidebar + ขยายคอนเทนต์ (กันเหนียว) */
.aff-shop .sidebar,
.woocommerce-shop .sidebar,
.tax-product_cat .sidebar,
.tax-product_tag .sidebar { display:none !important; }
.aff-shop .site-content .content-area,
.woocommerce-shop .site-content .content-area,
.tax-product_cat .site-content .content-area { width:100% }

/* หัวข้อ & แถบคำอธิบาย */
.woocommerce .woocommerce-breadcrumb { margin-bottom: 8px; }
.woocommerce-products-header { margin-bottom: 6px; }
.woocommerce .woocommerce-result-count { color:#6b7280; font-weight:600; }

/* Sorting Bar */
.woocommerce .woocommerce-ordering select{
  border:1px solid #e5e7eb; border-radius:12px; padding:10px 12px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
}

/* กริดสินค้า */
.woocommerce ul.products { gap:18px !important; }
.woocommerce ul.products li.product{
  float:none !important; width:auto !important; margin:0 !important;
  display:flex; flex-direction:column; background:#fff;
  border:1px solid #eef2f7; border-radius:16px; overflow:hidden;
  box-shadow:0 8px 24px rgba(0,0,0,.06);
  transition:transform .15s ease, box-shadow .15s ease;
}
.woocommerce ul.products li.product:hover{
  transform: translateY(-2px);
  box-shadow:0 14px 32px rgba(0,0,0,.10);
}

/* รูปสินค้าอัตราส่วน 1:1 */
.woocommerce ul.products li.product a img{
  width:100%; aspect-ratio:1/1; object-fit:contain;
  background:#f7f9fc; border-bottom:1px solid #eef2f7;
}

/* ชื่อสินค้า */
.woocommerce ul.products li.product .woocommerce-loop-product__title{
  font-size:1.05rem; font-weight:800; color:#1a3a6e;
  margin:12px 12px 6px; line-height:1.35;
  display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  min-height:2.8em;
}

/* ราคา */
.woocommerce ul.products li.product .price{
  color:#c41e24; font-weight:900; margin:0 12px 10px;
}
.woocommerce ul.products li.product .price del{ color:#9ca3af; font-weight:600; }
.woocommerce ul.products li.product .price ins{ text-decoration:none }

/* ปุ่ม “ซื้อที่ Shopee” */
.woocommerce ul.products li.product a.button{
  margin: auto 12px 14px; align-self:flex-start;
  background:#FF5722 !important; color:#fff !important;
  border-radius:999px; padding:10px 16px; font-weight:800;
  box-shadow:0 6px 16px rgba(255,87,34,.25);
  transition: transform .15s ease, filter .15s ease;
}
.woocommerce ul.products li.product a.button:hover{
  transform: translateY(-2px); filter: brightness(1.04);
}

/* Responsive columns (ใช้ CSS Grid ของ Woo เอง) */
@media (max-width: 1024px){
  .woocommerce ul.products{ grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
}
@media (max-width: 768px){
  .woocommerce ul.products{ grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
}
@media (max-width: 480px){
  .woocommerce ul.products{ grid-template-columns: 1fr !important; }
}

/* ===== Loop Sale Badge on Product Cards ===== */
.woocommerce ul.products li.product{ position:relative }
.woocommerce ul.products li.product .aff-sale-badge--loop{
  position:absolute; top:10px; left:10px; z-index:3;
  display:inline-block; padding:7px 9px 6px;
  background:#F59E0B; color:#fff; border-radius:10px 10px 10px 0;
  font-weight:800; line-height:1; font-size:12px;
  box-shadow:0 6px 14px rgba(0,0,0,.12);
}
.woocommerce ul.products li.product .aff-sale-badge--loop strong{ font-weight:900 }

/* ===== /shop/ Pro Grid & Cards ===== */

/* คอนเทนต์เต็มกว้าง (กันธีมแทรก sidebar) */
.aff-shop .site-content .content-area{ width:100% }

/* กริด 3 คอลัมน์ (แท็บเล็ต 2 / มือถือ 1) */
.woocommerce ul.products{
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 24px !important;
  margin: 12px 0 32px !important;
}

/* การ์ดสินค้า */
.woocommerce ul.products li.product{
  float: none !important; width: auto !important; margin: 0 !important;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid #eef2f7; border-radius: 16px;
  overflow: hidden; box-shadow: 0 8px 22px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.woocommerce ul.products li.product:hover{
  transform: translateY(-2px);
  border-color:#e5e7eb;
  box-shadow: 0 14px 32px rgba(0,0,0,.10);
}

/* รูปสินค้า: สี่เหลี่ยม 1:1 สูงคงที่ */
.woocommerce ul.products li.product a img{
  width: 100%; aspect-ratio: 1 / 1; height: 240px;
  object-fit: contain; background:#f7f9fc;
  border-bottom: 1px solid #eef2f7;
}

/* ชื่อสินค้า: 2 บรรทัด สูงเท่ากัน */
.woocommerce ul.products li.product .woocommerce-loop-product__title{
  margin: 12px 14px 6px; color:#1a3a6e; font-weight: 800; font-size: 1.02rem;
  line-height: 1.35; display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  min-height: 2.8em;
}

/* ราคา */
.woocommerce ul/products li.product .price{
  margin: 0 14px 10px; color:#c41e24; font-weight: 900;
}
.woocommerce ul.products li.product .price del{ color:#9ca3af; font-weight:600; margin-right:6px }
.woocommerce ul.products li.product .price ins{ text-decoration: none; }

/* ปุ่ม CTA เต็มแถว */
.woocommerce ul.products li.product a.button{
  margin: auto 14px 14px; /* ดันปุ่มลงก้นการ์ด */
  align-self: stretch; text-align:center;
  background:#FF5722 !important; color:#fff !important;
  border-radius: 999px; padding: 11px 16px; font-weight: 800;
  box-shadow: 0 8px 18px rgba(255,87,34,.25);
  transition: transform .15s ease, filter .15s ease;
}
.woocommerce ul.products li.product a.button:hover{
  transform: translateY(-2px); filter: brightness(1.05);
}

/* ป้ายลด X% (มุมขวาบน) – ใช้ชุดเดียวกับหน้าเดี่ยว */
.woocommerce ul.products li.product .aff-sale-badge{
  position:absolute; top:12px; right:12px; z-index:3;
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 12px 7px; border-radius:12px;
  font-weight:800; font-size:12px; color:#fff;
  background: linear-gradient(135deg, #FFB800 0%, #F59E0B 45%, #F59E0B 55%, #D97706 100%);
  box-shadow:0 8px 20px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.25);
}
.woocommerce ul.products li.product .aff-sale-badge strong{ font-size:13px }

/* ให้กรอบภาพเป็นตำแหน่งอ้างอิงสำหรับ badge */
.woocommerce ul.products li.product .woocommerce-LoopProduct-link{ position:relative; display:block }

/* Sorting/Result bar */
.woocommerce .woocommerce-result-count{ color:#6b7280; font-weight:600; }
.woocommerce .woocommerce-ordering select{
  border:1px solid #e5e7eb; border-radius:12px; padding:10px 12px;
  box-shadow:0 2px 10px rgba(0,0,0,.05);
}

/* Responsive */
@media (max-width: 992px){
  .woocommerce ul.products{ grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .woocommerce ul.products li.product a img{ height: 220px; }
}
@media (max-width: 540px){
  .woocommerce ul.products{ grid-template-columns: 1fr !important; }
  .woocommerce ul.products li.product a img{ height: 210px; }
}

/* Ensure loop badge uses top-right even if older left rule exists */
.woocommerce ul.products li.product .aff-sale-badge--loop{ left:auto !important; right:12px !important; }