/* ==========================================================================
   nShop Wishlist Feature Styles
   Matching nShop Branding: Red #d70018 / Orange #FF5722 / Dark #2F2F2F
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. PDP Desktop Wishlist Button (.wrap-addcart)
   -------------------------------------------------------------------------- */
.btn-wishlist-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.25s ease;
  padding: 0 14px;
  height: 48px;
  color: #4f4f4f;
  outline: none;
  box-sizing: border-box;
  vertical-align: middle;
  user-select: none;
}

.btn-wishlist-toggle:hover {
  border-color: #d70018;
  color: #d70018;
  background: #fff5f5;
}

.btn-wishlist-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), fill 0.2s ease, stroke 0.2s ease;
}

/* Active State: Filled Red with bounce */
.btn-wishlist-toggle.active {
  border-color: #d70018;
  background: #fff5f5;
  color: #d70018;
}

.btn-wishlist-toggle.active svg {
  fill: #d70018;
  stroke: #d70018;
  transform: scale(1.15);
}

.wrap-addcart .btn-wishlist-toggle {
  margin-right: 8px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   2. PDP Mobile Sticky Capsule Bar (.selector-actions)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .selector-actions .btn-wishlist-toggle {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: 1px solid #e8e8e8 !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    flex: 0 0 40px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
  }

  .selector-actions .btn-wishlist-toggle.active {
    background: #fff0f1 !important;
    border-color: #d70018 !important;
  }

  .selector-actions .btn-wishlist-toggle svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* --------------------------------------------------------------------------
   3. Header Desktop Icon & Alignment (.header-actions)
   Chuẩn hóa cụm Search, Heart, Cart thành khối 36x36px với Flexbox & Gap 20px
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 20px !important; /* Căn khoảng cách chính xác 20px giữa TẤT CẢ các icon */
  margin-left: 20px;
}

.header-actions a,
.header-actions .header-action {
  margin: 0 !important; /* Loại bỏ toàn bộ margin-right cũ không đồng đều */
}

.header-actions a.action-account {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  padding: 0 4px !important;
  margin-right: 4px !important;
}

/* Chuẩn hóa cả 3 nút (Search, Heart, Cart) thành khối kích thước chuẩn 36x36px */
.header-actions .header-action_search,
.header-actions .header-action_wishlist,
.header-actions .header-action_cart,
.header-actions .showsearch-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  vertical-align: middle !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 1 !important;
  position: relative !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

.header-actions .header-action_search a.header-action__link,
.header-actions .header-action_wishlist a.header-action__link,
.header-actions .header-action_cart a.header-action__link,
.header-actions a.showsearch-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  position: relative !important;
  text-decoration: none !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  color: inherit !important;
  box-sizing: border-box !important;
}

.header-actions .showsearch-btn svg,
.header-actions .header-action_wishlist .wishlist-icon-svg,
.header-actions .header-action_cart .cart-icon-svg {
  width: 23px !important;
  height: 23px !important;
  display: block !important;
  margin: auto !important;
  transform: none !important; /* Khử mọi độ lệch tâm nhân tạo */
  transition: transform 0.2s ease !important;
}

/* Micro-interaction hover đồng bộ cho cả 3 icon */
.header-actions .header-action_search:hover svg,
.header-actions .header-action_wishlist:hover .wishlist-icon-svg,
.header-actions .header-action_cart:hover .cart-icon-svg {
  transform: scale(1.08) !important;
}

/* Badge số đếm giỏ hàng và yêu thích đồng bộ vị trí trên góc phải khối 36x36 */
.header-action_wishlist .wishlist-count,
.header-action_cart .cart-count {
  position: absolute !important;
  top: -2px !important;
  right: -2px !important;
  bottom: auto !important;
  left: auto !important;
  background: #d70018 !important;
  color: #ffffff !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  min-width: 17px !important;
  height: 17px !important;
  line-height: 17px !important;
  text-align: center !important;
  border-radius: 10px !important;
  padding: 0 4px !important;
  box-shadow: 0 2px 4px rgba(215, 0, 24, 0.35) !important;
  z-index: 10 !important;
  pointer-events: none !important;
}

/* Header Mobile Wishlist Icon */
.actions-wrap-mb .action-wishlist {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: #2F2F2F;
  text-decoration: none;
  line-height: 1;
}

.actions-wrap-mb .action-wishlist .wishlist-count {
  position: absolute;
  top: -5px;
  right: -7px;
  background: #d70018;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 3px;
  display: none;
  box-shadow: 0 2px 4px rgba(215, 0, 24, 0.3);
}

/* --------------------------------------------------------------------------
   4. Desktop Hover Dropdown Menu (.header-action_dropdown-wishlist)
   Replicating Mini-Cart Dropdown UX
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .header-action_wishlist .header-action_dropdown-wishlist {
    display: none;
    position: absolute;
    top: 100%;
    right: -20px;
    z-index: 1000;
    padding-top: 12px; /* Hover bridge giúp chuột không bị mất hover */
    background: transparent;
    border: none;
    box-shadow: none;
    min-width: 400px;
  }

  /* Kích hoạt hiển thị khi hover hoặc khi có class show-action */
  .header-action_wishlist:hover .header-action_dropdown-wishlist,
  .header-action_wishlist.is-hovered .header-action_dropdown-wishlist,
  .header-action_wishlist.show-action .header-action_dropdown-wishlist {
    display: block !important;
  }

  /* Tam giác chỉ lên trên icon Trái tim (căn chính xác tâm 36x36 với offset 20px: 20 + 18 = 38px, trừ nửa tam giác 7px = 31px) */
  .header-action_wishlist .header-action_dropdown-wishlist::before {
    content: '';
    position: absolute;
    top: -2px;
    right: 31px;
    border-width: 7px;
    border-style: solid;
    border-color: transparent transparent #ffffff transparent;
    display: block;
    z-index: 1001;
  }

  .header-action_wishlist .header-action_dropdown-wishlist::after {
    content: '';
    position: absolute;
    top: -4px;
    right: 30px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent #eaeaea transparent;
    display: block;
    z-index: 1000;
  }

  /* Căn chỉnh lại mũi tên tam giác của Giỏ hàng cho chuẩn tâm khối 36x36px (right: 0, tâm 18px -> right: 11px) */
  .header-action_cart .header-action_dropdown::before {
    right: 11px !important;
  }
  .header-action_cart .header-action_dropdown::after {
    right: 10px !important;
  }
}

/* Khối nội dung .site-wishlist (Đồng bộ thiết kế với .site-cart của Mini-Cart) */
.header-action_dropdown-wishlist .site-wishlist {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #333333;
  text-align: left;
  background: #ffffff;
  border: 1px solid #eaeaea;
  border-radius: 12px;
  box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  position: relative;
}

.wishlist-ttbold {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f1f1;
}

.wishlist-ttbold .ttbold {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  color: #111111;
  margin: 0;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
}

.wishlist-ttbold .close-mini-wishlist {
  cursor: pointer;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  color: #666666;
}

.wishlist-ttbold .close-mini-wishlist:hover {
  opacity: 0.7;
}

/* Banner nhắc đăng nhập trong Mini Dropdown */
.wishlist-mini-promo {
  padding: 9px 20px;
  background: #fdf5f5;
  border-bottom: 1px solid #fee2e2;
  font-size: 12px;
  color: #4b5563;
  line-height: 1.4;
}

.wishlist-mini-promo a {
  color: #d70018;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 4px;
}

/* Danh sách cuộn sản phẩm */
.wishlist-view-scroll {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.wishlist-view-scroll::-webkit-scrollbar {
  width: 5px;
}

.wishlist-view-scroll::-webkit-scrollbar-thumb {
  background: #d8d8d8;
  border-radius: 4px;
}

.mini-wishlist-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f5f5f5;
  gap: 12px;
  transition: background-color 0.15s ease;
}

.mini-wishlist-item:last-child {
  border-bottom: none;
}

.mini-wishlist-item:hover {
  background-color: #fafafa;
}

.mini-wishlist-item__thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #ebebeb;
  background: #fafafa;
}

.mini-wishlist-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mini-wishlist-item__details {
  flex: 1;
  min-width: 0;
}

.mini-wishlist-item__title {
  font-size: 13px;
  font-weight: 600;
  color: #222222;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  margin-bottom: 4px;
}

.mini-wishlist-item__title:hover {
  color: #d70018;
}

.mini-wishlist-item__price-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.mini-wishlist-item__price {
  font-size: 13px;
  font-weight: 700;
  color: #d70018;
}

.mini-wishlist-item__compare-price {
  font-size: 11px;
  color: #999999;
  text-decoration: line-through;
}

.mini-wishlist-item__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-mini-wishlist-buy {
  background: #d70018;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease;
}

.btn-mini-wishlist-buy:hover {
  background: #b50014;
  color: #ffffff;
}

.btn-mini-wishlist-buy.disabled,
.btn-mini-wishlist-buy[disabled] {
  background: #e0e0e0;
  color: #888888;
  cursor: not-allowed;
}

.btn-mini-wishlist-buy.btn-choose {
  background: #ffffff;
  color: #d70018;
  border: 1px solid #d70018;
}

.btn-mini-wishlist-remove {
  background: transparent;
  border: none;
  color: #9e9e9e;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-mini-wishlist-remove:hover {
  color: #d70018;
  background: #fee2e2;
}

/* Empty State Trong Dropdown */
.mini-wishlist-empty {
  padding: 36px 20px;
  text-align: center;
}

.svgico-mini-wishlist {
  margin: 0 auto 12px;
  display: flex;
  justify-content: center;
}

.mini-wishlist-empty .empty-txt {
  font-size: 14px;
  color: #666666;
  margin-bottom: 14px;
}

.mini-wishlist-empty .btn-empty-shop {
  display: inline-block;
  background: #d70018;
  color: #ffffff;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.mini-wishlist-empty .btn-empty-shop:hover {
  background: #b50014;
}

/* Footer & 2 Nút Hành Động */
.wishlist-view-footer {
  padding: 14px 20px;
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
}

.wishlist-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wishlist-actions-row .btn-link-wishlist {
  flex: 1;
  text-align: center;
  background: #fff0f1;
  color: #d70018;
  border: 1px solid #ffd0d4;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.wishlist-actions-row .btn-link-wishlist:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b50014;
}

.wishlist-actions-row .btn-buyall-wishlist {
  flex: 1;
  text-align: center;
  background: #d70018;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.wishlist-actions-row .btn-buyall-wishlist:hover {
  background: #b50014;
}

/* --------------------------------------------------------------------------
   5. Mobile Drawer Sheet (.header-action_dropdown-wishlist on Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .header-action_dropdown-wishlist {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 999999 !important;
    display: none !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .header-action_dropdown-wishlist.show-action {
    display: flex !important;
  }

  .header-action_dropdown-wishlist .site-wishlist {
    width: 100% !important;
    max-height: 85vh !important;
    border-radius: 16px 16px 0 0 !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2) !important;
    border: none !important;
    animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes slideUpSheet {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .wishlist-actions-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .wishlist-actions-row .btn-link-wishlist,
  .wishlist-actions-row .btn-buyall-wishlist {
    width: 100% !important;
    padding: 12px 10px !important;
  }
}

/* --------------------------------------------------------------------------
   6. Minimal Fallback Toast
   -------------------------------------------------------------------------- */
.nshop-wishlist-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #d70018;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 9999999;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.nshop-wishlist-toast.show {
  opacity: 1;
  transform: translateY(0);
}
