/*
 * Videmi UI Upgrade - Professional E-commerce Style
 * Typography: Inter
 * Primary Color: Original Red (#DA1F26)
 */

:root {
  /* Original Red Palette */
  --vdm-red: #DA1F26;
  --vdm-red-strong: #B8171E;
  --vdm-red-soft: #FDF1F2;
  --vdm-yellow: #FFB347;
  
  /* Neutral Palette */
  --vdm-ink: #1D1D1F; 
  --vdm-text: #4a4a4f; 
  --vdm-muted: #86868B;
  --vdm-line: #EBEBEB;
  --vdm-surface: #FFFFFF;
  --vdm-surface-alt: #F9F9FB;
  
  /* Refined, Crisp Shadows */
  --vdm-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --vdm-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --vdm-shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.1);
  --vdm-shadow-red: 0 4px 12px rgba(218, 31, 38, 0.2);
  
  /* Professional Rounded Corners */
  --vdm-radius-sm: 6px;
  --vdm-radius-md: 8px;
  --vdm-radius-lg: 12px;
}

/* ==========================================================
   GLOBAL & TYPOGRAPHY
========================================================== */
html {
  overflow-x: hidden;
}

body, h1, h2, h3, h4, h5, h6, p, input, button, textarea {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

body {
  overflow-x: hidden;
  color: var(--vdm-text);
  background: var(--vdm-surface-alt);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a, button, .button, input[type="submit"], .box {
  transition: all 0.2s ease-in-out;
}

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid rgba(218, 31, 38, 0.5);
  outline-offset: 2px;
}

/* ==========================================================
   HEADER
========================================================== */
.header-wrapper {
  background: #fff;
  box-shadow: 0 1px 0 var(--vdm-line);
}

.header-main {
  border-bottom: none;
  position: relative;
  z-index: 99 !important; /* Đảm bảo dropdown của phần trên đè bẹp phần dưới */
}

.header-main .header-inner {
  min-height: 80px;
}

#logo img {
  width: auto;
}

.header-bottom {
  border-bottom: 1px solid var(--vdm-line);
  background: #fff;
  position: relative;
  z-index: 90 !important; /* Lớp menu này bị ép nằm dưới lớp header-main */
}

.header-bottom {
  border-bottom: 1px solid var(--vdm-line);
  background: #fff;
}

.header-bottom-nav > li {
  margin: 0 16px;
}

.header-bottom-nav > li > a {
  min-height: 50px;
  color: var(--vdm-ink);
  font-size: 15px;
  font-weight: 600;
  text-transform: none; /* Bo in hoa gắt */
}

.header-bottom-nav > li.active > a,
.header-bottom-nav > li > a:hover {
  color: var(--vdm-red);
}

.nav > li > a > i, .header-button a, .cart-icon, .icon-search, .icon-user {
  color: var(--vdm-ink);
}
.nav > li > a:hover > i, .cart-icon:hover {
  color: var(--vdm-red);
}

.mobile-sidebar .nav > li > a {
  color: var(--vdm-ink);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
}
.mobile-sidebar .nav > li > a:hover {
  color: var(--vdm-red);
  background: var(--vdm-red-soft);
}

/* ==========================================================
   LAYOUT & CONTAINERS
========================================================== */
.home-sale > .col > .col-inner,
.section-title-container,
.row-slider, .products, .shop-container,
.product-main, .product-footer,
.page-wrapper > .row, .blog-wrapper > .row {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================
   FLASH SALE BANNER
========================================================== */
.flash-sale {
  align-items: center;
  margin: 24px auto;
  padding: 20px;
  border: 1px solid var(--vdm-red-soft);
  border-radius: var(--vdm-radius-md);
  background: #fff;
  box-shadow: var(--vdm-shadow-sm);
  border-top: 3px solid var(--vdm-red);
}

.flash-sale .img {
  max-width: 70px;
  margin: 0 auto;
}

.flash-sale .large-3 h2 {
  color: var(--vdm-ink);
  font-size: clamp(24px, 2.5vw, 32px);
  font-weight: 700;
  margin-top: 8px;
}

/* ==========================================================
   SECTION TITLES
========================================================== */
.section-title-container {
  margin-top: 40px;
  margin-bottom: 20px;
}

.section-title b {
  background: var(--vdm-line);
}

.section-title-main {
  color: var(--vdm-ink);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 700;
}

.section-title a {
  padding: 6px 12px;
  color: var(--vdm-red) !important;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--vdm-red-soft);
}

.section-title a:hover {
  background: var(--vdm-red);
  color: #fff !important;
}

/* ==========================================================
   PRODUCT CARDS
========================================================== */
.product-small {
  padding-bottom: 24px;
}

.product-small .box {
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--vdm-line);
  border-radius: var(--vdm-radius-md) !important;
  background: var(--vdm-surface);
  box-shadow: var(--vdm-shadow-sm);
  overflow: hidden !important; /* Ngăn ảnh đâm thủng viền bo tròn */
}

.product-small .box:hover {
  border-color: rgba(218, 31, 38, 0.3);
  box-shadow: var(--vdm-shadow-md);
  transform: translateY(-2px);
}

.product-small .box-image {
  border-radius: var(--vdm-radius-md) var(--vdm-radius-md) 0 0 !important;
  overflow: hidden !important;
  background: var(--vdm-surface) !important;
  transform: translateZ(0); /* Ép Webkit (Chrome/Safari) cắt viền mượt mà */
}

/* Fix lỗi Slider cắt viền Box-shadow của Flatsome */
.slider-wrapper .col {
  padding-top: 8px !important;
  padding-bottom: 12px !important;
}

.product-small .box-image img {
  border-radius: var(--vdm-radius-md) var(--vdm-radius-md) 0 0 !important;
  width: 100% !important;
  height: auto !important; /* Để ảnh vuông tự đẩy chiều cao, chống kéo giãn dọc */
  display: block !important;
  object-fit: cover !important;
  margin: 0 !important;
}

.product-small .box-text {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Đẩy giá và nút xuống đáy */
}

.product-small .box-text .title-wrapper,
.product-small .name {
  margin-bottom: auto;
}

.product-small .box-text h1, .product-small .box-text h2, 
.product-small .box-text h3, .product-small .box-text h4, 
.product-small .box-text .name a,
.product-small .box-text a:not(.button) {
  color: var(--vdm-ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 12px;
  text-align: center;
  
  /* Giới hạn text 3 dòng và hiện ... */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  
  /* Cố định chiều cao tuyệt đối cho 3 dòng (14px * 1.5 * 3 = 63px) */
  height: 63px;
}

.product-small .price-wrapper {
  text-align: center;
  margin-top: auto; /* Luôn ép giá nằm ở dưới cùng của thẻ */
  min-height: 30px;
}

.product-small .price-wrapper del {
  color: var(--vdm-muted);
  font-size: 13px;
  font-weight: 400;
  margin-right: 6px;
}

.product-small .price-wrapper ins {
  color: var(--vdm-red);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

/* Badges - Khôi phục hình tròn chuẩn, kích thước tinh tế */
.product-small .badge-container {
  top: 8px !important; 
  left: 8px !important;
  margin: 0 !important;
  padding: 0 !important;
}

.product-small .badge-circle, 
.product-small .badge-outline, 
.product-small .badge-inner.on-sale {
  width: 38px !important; 
  height: 38px !important;
  min-width: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: var(--vdm-red) !important;
  color: #fff !important;
  border-radius: 50% !important; /* Hình tròn tuyệt đối */
  box-shadow: 0 4px 8px rgba(218, 31, 38, 0.25) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
}

.product-small .badge-circle span.onsale {
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.product-small .badge-inner {
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

/* ==========================================================
   BUTTONS & FORMS
========================================================== */
#wrapper .button:not(.icon):not(.flickity-button), #wrapper button:not(.icon):not(.flickity-button), #wrapper input[type="submit"]:not(.icon), #wrapper .single_add_to_cart_button, #wrapper .checkout-button {
  border-radius: var(--vdm-radius-sm) !important;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  padding: 0 24px;
  text-transform: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Nút Primary (Thêm vào giỏ) */
#wrapper .button.primary:not(.icon), #wrapper .single_add_to_cart_button, #wrapper .checkout-button, #wrapper input[type="submit"]:not(.icon) {
  background: var(--vdm-red) !important;
  color: #fff !important;
  border: 1px solid var(--vdm-red) !important;
}

#wrapper .button.primary, #wrapper .single_add_to_cart_button, #wrapper .checkout-button, #wrapper input[type="submit"] {
  background: var(--vdm-red) !important;
  color: #fff !important;
  border: 1px solid var(--vdm-red) !important;
}

#wrapper .button.primary:hover, #wrapper .single_add_to_cart_button:hover {
  background: var(--vdm-red-strong) !important;
  border-color: var(--vdm-red-strong) !important;
  box-shadow: var(--vdm-shadow-red);
}

/* Nút Secondary (Học thử, Success) */
#wrapper .button.success, #wrapper .btn-hocthu {
  background: #f0fdf4 !important; /* Xanh lá siêu nhạt */
  color: #166534 !important; /* Chữ xanh đậm */
  border: 1px solid #bbf7d0 !important;
  box-shadow: none !important;
}

#wrapper .button.success:hover, #wrapper .btn-hocthu:hover {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  transform: translateY(-1px);
}

#wrapper input[type="text"], #wrapper input[type="email"], #wrapper input[type="search"], #wrapper input[type="password"], #wrapper textarea, #wrapper select {
  border-radius: var(--vdm-radius-sm) !important;
  border: 1px solid #CCC !important;
  padding: 10px 14px !important;
  font-size: 14px !important;
  background: var(--vdm-surface) !important;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03) !important;
  height: auto !important;
  min-height: 44px !important;
  line-height: 1.4 !important;
}

#wrapper input:focus, #wrapper textarea:focus, #wrapper select:focus {
  border-color: var(--vdm-red) !important;
  box-shadow: 0 0 0 2px var(--vdm-red-soft) !important;
  outline: none !important;
}

/* ==========================================================
   SINGLE PRODUCT / POST
========================================================== */
.product-info {
  background: #fff;
  border-radius: var(--vdm-radius-md);
  padding: 24px;
  box-shadow: var(--vdm-shadow-sm);
  border: 1px solid var(--vdm-line);
}

.product-info h1.product-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--vdm-ink);
}

.product-gallery img {
  border-radius: var(--vdm-radius-md);
  border: 1px solid var(--vdm-line);
}



/* Bảng giá Single Product */
.devvn_single_price {
  background: var(--vdm-surface-alt) !important;
  border: 1px solid var(--vdm-line) !important;
  border-radius: var(--vdm-radius-md) !important;
  padding: 16px 20px !important; /* Thu hẹp padding */
  margin-bottom: 20px;
}

.devvn_single_price > div {
  display: flex;
  align-items: center;
  margin-bottom: 8px; /* Thu hẹp khoảng cách giữa các dòng */
}

.devvn_single_price > div:last-child {
  margin-bottom: 0;
  padding-top: 8px; /* Thu hẹp khoảng cách viền đứt */
  border-top: 1px dashed var(--vdm-line);
}

.devvn_single_price span.label {
  width: 85px; /* Chỉnh lại độ rộng label cho cân đối */
  color: var(--vdm-text);
  font-size: 14px; /* Giảm nhẹ size label */
  font-weight: 500;
  flex-shrink: 0;
}

/* Giá Sale (Giá hiện tại - Đập vào mắt người xem) */
.devvn_single_price > div:nth-child(1) span.devvn_price,
.devvn_single_price > div:nth-child(1) span.devvn_price .amount {
  color: var(--vdm-red) !important;
  font-size: 22px !important; /* Giảm size giá một chút cho thanh lịch */
  font-weight: 800 !important;
  line-height: 1.2;
}

/* Giá Thị trường (Gạch ngang - Phụ) */
.devvn_single_price > div:nth-child(2) span.devvn_price del,
.devvn_single_price > div:nth-child(2) span.devvn_price del .amount {
  color: var(--vdm-muted) !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  text-decoration: line-through;
}

/* Tiết kiệm (Xanh lá) */
.devvn_single_price > div:nth-child(3) span.devvn_price.sale_amount,
.devvn_single_price > div:nth-child(3) span.devvn_price.sale_amount .amount {
  color: #16a34a !important; /* Xanh lá */
  font-size: 16px !important;
  font-weight: 700 !important;
}

.entry-content, .product-short-description {
  font-size: 16px;
  line-height: 1.6;
  color: var(--vdm-text);
}

.entry-content h2, .entry-content h3 {
  color: var(--vdm-ink);
  font-weight: 600;
}

/* Modern Tables */
.entry-content table {
  border-radius: var(--vdm-radius-sm);
  border: 1px solid var(--vdm-line);
}
.entry-content table td, .entry-content table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--vdm-line);
  border-right: 1px solid var(--vdm-line);
}
.entry-content table tr:first-child td, .entry-content table th {
  background: var(--vdm-surface-alt);
}

/* ==========================================================
   FOOTER
========================================================== */
#footer {
  border-top: 1px solid var(--vdm-line);
}

.footer-wrapper .widget-title,
#footer .widget-title {
  color: #ffffff !important; /* Sửa lỗi text chìm trên nền tối */
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  text-transform: uppercase;
}

/* ==========================================================
   SHOP PAGE — FIX BỘ LỌC BỊ CHE & WOOCOMMERCE ORDERING
========================================================== */

/* Fix: Bộ lọc sắp xếp không bị dropdown menu che */
.woocommerce-ordering,
.woocommerce-result-count,
.shop-container .woocommerce-notices-wrapper {
  position: relative;
  z-index: 10;
}

/* Fix: Breadcrumb + toolbar row không bị z-index thấp */
.shop-page-toolbar,
.col-breadcrumbs,
.woocommerce-breadcrumb,
.woocommerce .woocommerce-ordering {
  position: relative;
  z-index: 10;
}

/* Dropdown của Flatsome mặc định z-index 99 — đảm bảo không tràn sang nội dung dưới */
.header-bottom .nav > li > .nav-dropdown,
.header-bottom .nav > li > ul.sub-menu {
  z-index: 500;
}

/* ==========================================================
   MEGA DROPDOWN MENU — 2-COLUMN PROFESSIONAL REDESIGN
========================================================== */

/* Container dropdown tổng */
.header-bottom .nav > li.has-dropdown > .nav-dropdown,
.header-bottom .nav > li.menu-item-has-children > ul.sub-menu {
  /* 2-column grid layout, top-to-bottom flow */
  display: grid !important;
  grid-template-columns: repeat(2, auto); /* Cột tự co giãn theo nội dung dài nhất */
  grid-template-rows: auto repeat(7, min-content);
  grid-auto-flow: column;
  gap: 4px 28px; /* Giữ khoảng cách giữa 2 cột vừa đủ */
  padding: 20px 28px 20px;
  background: #ffffff;
  border-top: 3px solid var(--vdm-red);
  border-radius: 0 0 var(--vdm-radius-md) var(--vdm-radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  min-width: 0; 
  width: max-content; /* Tự động co rút vừa khít text */
  position: absolute;
  top: 100%;
  
  /* Hide state - Ép ẩn tuyệt đối lúc mới load trang để chống FOUC (chớp menu) */
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  left: -9999px !important; /* Tránh cản trở click */
  
  /* Animation */
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  transform-origin: top center;
  transform: translateX(-50%) translateY(10px); /* Bắt đầu animation từ giữa */
  z-index: 500;
}

/* Khi hover — show dropdown với animation */
.header-bottom .nav > li.has-dropdown:hover > .nav-dropdown,
.header-bottom .nav > li.has-dropdown.hover > .nav-dropdown,
.header-bottom .nav > li.menu-item-has-children:hover > ul.sub-menu,
.header-bottom .nav > li.menu-item-has-children.hover > ul.sub-menu {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important; /* KHẮC PHỤC LỖI KHÔNG RÊ CHUỘT VÀO MENU ĐƯỢC */
  left: 50% !important;
  transform: translateX(-50%) translateY(0); /* Căn giữa chính xác với menu item */
}

/* Triệt tiêu hoàn toàn mọi loại mũi tên trên dropdown menu */
.nav-dropdown::before,
.nav-dropdown::after,
.nav-dropdown-default::before,
.nav-dropdown-default::after,
.nav-dropdown-has-arrow::before,
.nav-dropdown-has-arrow::after,
.nav-column::before,
.nav-column::after,
ul.sub-menu::before,
ul.sub-menu::after,
li.has-dropdown::before,
li.has-dropdown::after,
li.account-item::before,
li.account-item::after {
  content: none !important;
  display: none !important;
  border: none !important;
  height: 0 !important;
  width: 0 !important;
}


/* Header trong dropdown — tiêu đề nhỏ phân loại (nếu có) */
.header-bottom .nav > li.menu-item-has-children > .nav-dropdown::before,
.header-bottom .nav > li.has-dropdown > .nav-dropdown::before {
  content: 'DANH MỤC KHOÁ HỌC';
  grid-column: 1 / -1;
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--vdm-muted);
  padding: 0 10px 12px;
  border-bottom: 1px solid var(--vdm-line);
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  text-align: center; /* Căn giữa tiêu đề */
}

/* Từng item trong dropdown */
.header-bottom-nav > li.menu-item-has-children > .nav-dropdown > li,
.header-bottom-nav > li.menu-item-has-children > ul.sub-menu > li {
  list-style: none;
  margin: 0;
  padding: 0;
  break-inside: avoid;
}

/* Link trong từng item */
.header-bottom .nav > li.has-dropdown > .nav-dropdown > li > a,
.header-bottom .nav > li.menu-item-has-children > ul.sub-menu > li > a {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 9px 14px !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  color: var(--vdm-ink) !important;
  border-radius: var(--vdm-radius-sm);
  margin: 2px 6px;
  line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
  text-transform: none !important;
  letter-spacing: 0;
  white-space: nowrap !important; /* Giữ text trên 1 dòng để cột tự bóp chặt vừa khít */
  min-height: auto;
}

/* Icon đỏ nhỏ trước mỗi item */
.header-bottom-nav > li.menu-item-has-children > .nav-dropdown > li > a::before,
.header-bottom-nav > li.menu-item-has-children > ul.sub-menu > li > a::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vdm-red);
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
}

/* Hover state — nền đỏ nhạt + chữ đỏ */
.header-bottom-nav > li.menu-item-has-children > .nav-dropdown > li > a:hover,
.header-bottom-nav > li.menu-item-has-children > ul.sub-menu > li > a:hover {
  background: var(--vdm-red-soft) !important;
  color: var(--vdm-red) !important;
  padding-left: 20px !important;
}

.header-bottom-nav > li.menu-item-has-children > .nav-dropdown > li > a:hover::before,
.header-bottom-nav > li.menu-item-has-children > ul.sub-menu > li > a:hover::before {
  opacity: 1;
  transform: scale(1.3);
}

/* Footer dropdown — nút CTA "Xem tất cả" */
.header-bottom-nav > li.menu-item-has-children > .nav-dropdown > li.view-all-link > a,
.header-bottom-nav > li.menu-item-has-children > ul.sub-menu > li.view-all-link > a {
  grid-column: 1 / -1;
  background: var(--vdm-red-soft);
  color: var(--vdm-red) !important;
  font-weight: 700 !important;
  text-align: center;
  justify-content: center;
  margin-top: 4px;
  border-top: 1px solid var(--vdm-line);
}

/* Divider line giữa dropdown và header */
.header-bottom {
  position: relative;
  z-index: 200;
}

/* ==========================================================
   MOBILE RESPONSIVE FIXES
========================================================== */
@media (max-width: 849px) {
  .header-main .header-inner { min-height: 60px; }
  #logo img { max-height: 40px; }
  
  .section-title-main { font-size: 20px; }
  .flash-sale { padding: 12px; margin: 12px; border-radius: 8px; }
  
  .product-small { padding: 0 4px 12px; }
  .product-small .box { border-radius: 8px; }
  .product-small .box-image { border-radius: 8px 8px 0 0; }
  
  .product-small .box-text h1, .product-small .box-text h2, 
  .product-small .box-text h3, .product-small .box-text .name a {
    font-size: 14px; /* Tăng size chữ dễ đọc hơn */
    line-height: 1.4;
    height: 58px; /* 14px * 1.4 * 3 */
  }
  .product-small .price-wrapper ins { font-size: 16px; }
  
  .product-info { padding: 16px; }
  .product-info h1.product-title { font-size: 22px; }
  
  /* Bảng giá Single Product gọn gàng hơn trên mobile */
  .devvn_single_price {
    padding: 16px 16px !important;
  }
  .devvn_single_price span.label {
    width: 85px;
    font-size: 14px;
  }
  .devvn_single_price > div:nth-child(1) span.devvn_price,
  .devvn_single_price > div:nth-child(1) span.devvn_price .amount {
    font-size: 28px !important;
  }
}

/* Ép hiển thị nút Back to top trên Mobile */
@media (max-width: 849px) {
  .back-to-top.active {
    display: block !important;
    bottom: 25px !important; 
    right: 15px !important;
    z-index: 999 !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
  }
}

