/**
 * WooCommerce Header 工具列 — 前台樣式
 * 搜尋、會員中心、購物車三個圖示的外觀與面板動畫
 */

/* ══════════════════════════════════════════
   工具列容器
══════════════════════════════════════════ */
.dy-wht-wrap {
	display: flex;
	align-items: center;
	gap: 16px;
}

/* ══════════════════════════════════════════
   圖示按鈕通用
══════════════════════════════════════════ */
.dy-wht-btn,
.dy-wht-btn:hover,
.dy-wht-btn:focus,
.dy-wht-btn:active {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	/* 強制清除 theme / browser 預設樣式 */
	background: transparent !important;
	background-color: transparent !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	outline: none;
	padding: 0 !important;
	margin: 0;
	cursor: pointer;
	text-decoration: none;
	color: inherit;
	/* 寬高 auto，讓 label 文字能撐開按鈕 */
	width: auto;
	height: auto;
}

/* 圖示容器：固定 24x24，讓兩張圖疊加切換 */
.dy-wht-icon-wrap {
	position: relative;
	width: 24px;
	height: 24px;
	flex-shrink: 0;
}

/* 標題文字（圖示旁的說明，位置由 flex-direction 控制） */
.dy-wht-label {
	font-size: 13px;
	white-space: nowrap;
	color: inherit;
}

/* ── 圖示：預設 / Hover 兩張疊加切換 ── */
.dy-wht-icon {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
	transition: opacity 0.25s ease;
}

/* SVG 回退圖示（無自訂圖時） */
.dy-wht-icon.dy-wht-svg {
	position: relative;
	width: 100%;
	height: 100%;
}

.dy-wht-icon--default {
	opacity: 1;
}

.dy-wht-icon--hover {
	opacity: 0;
}

.dy-wht-btn:hover .dy-wht-icon--default {
	opacity: 0;
}

.dy-wht-btn:hover .dy-wht-icon--hover {
	opacity: 1;
}

/* ── 有商品時的圖示切換 ── */
.dy-wht-icon.is-hidden {
	opacity: 0 !important;
}

/* 有商品：預設顯示 has-items 圖，hover 顯示 has-items-hover 圖 */
.dy-wht-icon-wrap.has-items .dy-wht-icon--has-items {
	opacity: 1;
}
.dy-wht-icon-wrap.has-items .dy-wht-icon--has-items-hover {
	opacity: 0;
}
.dy-wht-btn:hover .dy-wht-icon-wrap.has-items .dy-wht-icon--has-items {
	opacity: 0;
}
.dy-wht-btn:hover .dy-wht-icon-wrap.has-items .dy-wht-icon--has-items-hover {
	opacity: 1;
}

/* ══════════════════════════════════════════
   購物車數量角標
══════════════════════════════════════════ */
.dy-wht-cart-count {
	position: absolute;
	top: 0;
	right: 0;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #e74c3c;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	/* 用 flex 讓數字 span 置中 */
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	/* 預設隱藏，有商品時加 .is-visible 顯示 */
	opacity: 0;
	transform: scale(0.5);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.dy-wht-cart-count.is-visible {
	opacity: 1;
	transform: scale(1);
}

/* 有自訂圖示時：隱藏紅色背景，圖片撐滿容器 */
.dy-wht-cart-count.has-img {
	background: transparent !important;
	border-radius: 0;
}

.dy-wht-cart-count__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}

/* 數字疊在圖示上方 */
.dy-wht-cart-count__num {
	position: relative;
	z-index: 2;
	line-height: 1;
	/* 確保 Elementor top/left 位移可雙向調整 */
	top: 0;
	left: 0;
}

/* ══════════════════════════════════════════
   搜尋面板 — 三種模式共用基礎
══════════════════════════════════════════ */
.dy-wht-search-panel {
	/* 全部隱藏，開啟時加 .is-open */
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
	opacity: 0;
	z-index: 99999;
}

.dy-wht-search-panel.is-open {
	visibility: visible;
	pointer-events: auto;
	opacity: 1;
}

/* 搜尋 input 框 */
.dy-wht-search-input-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.dy-wht-search-icon-inner {
	position: absolute;
	left: 16px;
	width: 20px;
	height: 20px;
	pointer-events: none;
	color: inherit;
	opacity: 0.6;
}

.dy-wht-search-input {
	width: 100%;
	background: transparent;
	border: none;
	border-bottom: 2px solid currentColor;
	outline: none;
	padding: 12px 16px 12px 48px;
	font-size: 18px;
	color: inherit;
}

.dy-wht-search-input::placeholder {
	opacity: 0.5;
}

/* inline 模式：input 與 placeholder 顏色繼承父層（深色 header 預設為白色） */
.dy-wht-search--inline .dy-wht-search-input {
	color: currentColor;
}

.dy-wht-search--inline .dy-wht-search-input::placeholder {
	color: currentColor;
	opacity: 0.7;
}

/* 搜尋 loading 旋轉圈 */
.dy-wht-search-loading {
	position: absolute;
	right: 16px;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255,255,255,0.3);
	border-top-color: currentColor;
	border-radius: 50%;
	display: none;
	animation: dy-wht-spin 0.7s linear infinite;
}

.dy-wht-search-panel.is-loading .dy-wht-search-loading {
	display: block;
}

@keyframes dy-wht-spin {
	to { transform: rotate(360deg); }
}

/* 搜尋結果 */
.dy-wht-search-results {
	margin-top: 16px;
	max-height: 60vh;
	overflow-y: auto;
}

.dy-wht-search-result-item {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 12px 0;
	border-bottom: 1px solid rgba(255,255,255,0.1);
	text-decoration: none;
	color: inherit;
	transition: opacity 0.2s;
}

.dy-wht-search-result-item:hover {
	opacity: 0.75;
}

.dy-wht-search-result-item:last-child {
	border-bottom: none;
}

.dy-wht-search-result-img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
	background: rgba(255,255,255,0.1);
}

.dy-wht-search-result-info {
	flex: 1;
}

.dy-wht-search-result-name {
	font-size: 14px;
	font-weight: 500;
	margin-bottom: 4px;
}

.dy-wht-search-result-price {
	font-size: 13px;
	opacity: 0.75;
}

.dy-wht-search-no-result {
	text-align: center;
	opacity: 0.6;
	padding: 24px 0;
	font-size: 14px;
}

/* 關閉按鈕 */
.dy-wht-search-close {
	position: absolute;
	background: none;
	border: none;
	cursor: pointer;
	color: inherit;
	opacity: 0.7;
	transition: opacity 0.2s;
	padding: 8px;
}

.dy-wht-search-close svg {
	width: 24px;
	height: 24px;
	display: block;
}

.dy-wht-search-close:hover {
	opacity: 1;
}

/* 遮罩 */
.dy-wht-search-overlay {
	position: fixed;
	inset: 0;
	z-index: 99998;
	display: none;
}

.dy-wht-search-overlay.is-visible {
	display: block;
}

/* ── 模式一：全螢幕遮罩 ── */
.dy-wht-search--fullscreen {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	transform: none;
}

.dy-wht-search--fullscreen .dy-wht-search-inner {
	width: 90%;
	max-width: 680px;
}

.dy-wht-search--fullscreen .dy-wht-search-close {
	top: 24px;
	right: 24px;
}

/* ── 模式二：左側滑入 ── */
.dy-wht-search--sidebar-left {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: 360px;
	max-width: 90vw;
	background: #1a1a1a;
	color: #ffffff;
	padding: 60px 32px 32px;
	transform: translateX(-100%);
	box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}

.dy-wht-search--sidebar-left.is-open {
	transform: translateX(0);
}

.dy-wht-search--sidebar-left .dy-wht-search-close {
	top: 16px;
	right: 16px;
}

/* ── 模式三：Header 下方全寬 ── */
.dy-wht-search--header-bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	background: #ffffff;
	color: #1a1a1a;
	padding: 0 5%;
	box-shadow: 0 4px 20px rgba(0,0,0,0.12);
	transform: translateY(-100%);
}

.dy-wht-search--header-bar.is-open {
	transform: translateY(0);
}

.dy-wht-search--header-bar .dy-wht-search-inner {
	max-width: 900px;
	margin: 0 auto;
}

.dy-wht-search--header-bar .dy-wht-search-input {
	font-size: 20px;
	padding: 20px 16px 20px 52px;
	border-bottom-color: #e0e0e0;
	color: #1a1a1a;
}

.dy-wht-search--header-bar .dy-wht-search-icon-inner {
	color: #1a1a1a;
}

.dy-wht-search--header-bar .dy-wht-search-close {
	top: 50%;
	right: 0;
	transform: translateY(-50%);
	color: #1a1a1a;
}

.dy-wht-search--header-bar .dy-wht-search-result-item {
	border-bottom-color: #eeeeee;
	color: #1a1a1a;
}

.dy-wht-search--header-bar .dy-wht-search-results {
	max-height: 50vh;
}

/* ── 模式四：Inline 展開（圖示旁滑出） ── */

/* inline 模式：panel 不是固定定位，而是跟著 .dy-wht-search-item 絕對定位 */
.dy-wht-search-item {
	position: relative;
}

.dy-wht-search--inline {
	position: absolute;
	top: 50%;
	right: 100%;
	transform: translateY(-50%);
	transform-origin: right center;
	white-space: nowrap;
	background: transparent;
	color: inherit;
	/* 收起：寬度 0 + opacity 0，不用 overflow:hidden 避免截掉下拉結果 */
	width: 0;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	overflow: visible;
	transition: width 0.3s ease, opacity 0.25s ease, visibility 0.25s;
	display: flex;
	align-items: center;
	padding: 0;
}

.dy-wht-search--inline.is-open {
	width: 220px;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.dy-wht-search--inline .dy-wht-search-inner {
	width: 100%;
	display: flex;
	flex-direction: column;
}

.dy-wht-search--inline .dy-wht-search-input-wrap {
	width: 100%;
}

.dy-wht-search--inline .dy-wht-search-input {
	width: 100%;
	font-size: 14px;
	padding: 6px 32px 6px 36px;
	border-bottom-width: 1px;
}

.dy-wht-search--inline .dy-wht-search-icon-inner {
	left: 8px;
	width: 16px;
	height: 16px;
}

/* inline 模式的搜尋結果：浮動下拉 */
.dy-wht-search--inline .dy-wht-search-results {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	left: 0;
	background: #fff;
	color: #1a1a1a;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.15);
	max-height: 320px;
	overflow-y: auto;
	padding: 8px 12px;
	z-index: 9999;
}

.dy-wht-search--inline .dy-wht-search-result-item {
	border-bottom-color: #eeeeee;
	color: #1a1a1a;
}

.dy-wht-search--inline .dy-wht-search-result-img {
	width: 40px;
	height: 40px;
}

.dy-wht-search--inline .dy-wht-search-result-name {
	font-size: 13px;
}

.dy-wht-search--inline .dy-wht-search-result-price {
	font-size: 12px;
}

/* inline 模式隱藏關閉按鈕（點外部關閉） */
.dy-wht-search--inline .dy-wht-search-close {
	display: none;
}

/* inline 模式不需要搜尋 loading 遮罩 */
.dy-wht-search--inline ~ .dy-wht-search-overlay {
	display: none !important;
}

/* ══════════════════════════════════════════
   Mini Cart 側邊抽屜
══════════════════════════════════════════ */
.dy-wht-minicart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 380px;
	max-width: 92vw;
	background: #ffffff;
	z-index: 99999;
	transform: translateX(100%);
	transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: -8px 0 32px rgba(0,0,0,0.12);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.dy-wht-minicart-drawer.is-open {
	transform: translateX(0);
}

/* 整體 inner 分三段：header / 商品列表(可捲) / footer(小計+按鈕) */
.dy-wht-minicart-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

/* ── Header ── */
.dy-wht-minicart-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid #f0f0f0;
	flex-shrink: 0;
}

.dy-wht-minicart-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: #1a1a1a;
}

.dy-wht-minicart-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #f5f5f5;
	border: none;
	cursor: pointer;
	color: #555;
	transition: background 0.2s, color 0.2s;
	padding: 0;
	flex-shrink: 0;
}

.dy-wht-minicart-close:hover {
	background: #1a1a1a;
	color: #ffffff;
}

.dy-wht-minicart-close svg {
	width: 16px;
	height: 16px;
	display: block;
}

/* ── 商品列表（可捲動區）── 所有樣式加 !important 蓋過佈景主題與 Elementor ── */
.dy-wht-minicart-content {
	flex: 1 !important;
	overflow-y: auto !important;
	overflow-x: hidden !important;
	padding: 0 24px !important;
	max-height: none !important;
	scrollbar-width: thin;
	scrollbar-color: #ddd transparent;
}

.dy-wht-minicart-content::-webkit-scrollbar {
	width: 4px;
}

.dy-wht-minicart-content::-webkit-scrollbar-thumb {
	background: #ddd;
	border-radius: 2px;
}

/* Elementor Menu Cart 商品清單容器 */
.dy-wht-minicart-content .elementor-menu-cart__products {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	max-height: none !important;
	overflow: visible !important;
}

/* 空購物車提示 */
.dy-wht-minicart-content .elementor-menu-cart__empty-message,
.dy-wht-minicart-content .woocommerce-mini-cart__empty-message {
	text-align: center !important;
	color: #aaa !important;
	padding: 60px 0 !important;
	font-size: 14px !important;
	line-height: 1.6 !important;
}

/* ── 商品列：圖片左、右側為資訊區（name+price 垂直），刪除按鈕絕對定位右上 ── */
.dy-wht-minicart-content .elementor-menu-cart__product {
	display: grid !important;
	grid-template-columns: 60px 1fr !important;
	grid-template-rows: auto auto !important;
	grid-template-areas:
		"img  name"
		"img  price" !important;
	column-gap: 12px !important;
	row-gap: 0 !important;
	padding: 14px 32px 14px 0 !important; /* right 留空給刪除按鈕 */
	border-top: none !important;
	border-left: none !important;
	border-right: none !important;
	border-bottom: 1px solid #f0f0f0 !important;
	position: relative !important;
	background: transparent !important;
	margin: 0 !important;
	align-items: start !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product:last-child {
	border-bottom: none !important;
}

/* 圖片欄：固定 60x60，跨兩行 */
.dy-wht-minicart-content .elementor-menu-cart__product-image {
	grid-area: img !important;
	align-self: center !important;
	width: 60px !important;
	height: 60px !important;
	flex-shrink: 0 !important;
	margin: 0 !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-image a {
	display: block !important;
	width: 60px !important;
	height: 60px !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-image img {
	width: 60px !important;
	height: 60px !important;
	min-width: 60px !important;
	max-width: 60px !important;
	object-fit: cover !important;
	border-radius: 6px !important;
	border: 1px solid #efefef !important;
	display: block !important;
	margin: 0 !important;
}

/* 商品名稱欄 */
.dy-wht-minicart-content .elementor-menu-cart__product-name {
	grid-area: name !important;
	min-width: 0 !important;
	padding: 2px 0 0 !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-name a {
	font-size: 13px !important;
	font-weight: 500 !important;
	line-height: 1.5 !important;
	color: #1a1a1a !important;
	text-decoration: none !important;
	display: -webkit-box !important;
	-webkit-line-clamp: 2 !important;
	-webkit-box-orient: vertical !important;
	overflow: hidden !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-name a:hover {
	color: #555 !important;
}

/* 規格（variation dl） */
.dy-wht-minicart-content .elementor-menu-cart__product-name .variation {
	margin: 2px 0 0 !important;
	padding: 0 !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-name .variation dt,
.dy-wht-minicart-content .elementor-menu-cart__product-name .variation dd {
	display: inline !important;
	font-size: 11px !important;
	color: #aaa !important;
	margin: 0 !important;
}

/* 數量 × 單價（grid 第二行，圖片右側） */
.dy-wht-minicart-content .elementor-menu-cart__product-price {
	grid-area: price !important;
	font-size: 12px !important;
	color: #888 !important;
	margin-top: 3px !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-price .quantity {
	font-size: 12px !important;
	color: #888 !important;
	display: block !important;
}

/* 刪除按鈕：絕對定位，右側垂直置中 */
.dy-wht-minicart-content .elementor-menu-cart__product-remove {
	position: absolute !important;
	top: 50% !important;
	right: 0 !important;
	transform: translateY(-50%) !important;
}

/* Elementor 輸出兩個刪除連結（elementor_remove + remove_from_cart），隱藏第二個 */
.dy-wht-minicart-content .elementor-menu-cart__product-remove a:nth-child(2) {
	display: none !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-remove .remove_from_cart_button,
.dy-wht-minicart-content .elementor-menu-cart__product-remove .elementor_remove_from_cart_button {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 22px !important;
	height: 22px !important;
	border-radius: 50% !important;
	background: #f0f0f0 !important;
	color: #888 !important;
	font-size: 14px !important;
	line-height: 1 !important;
	text-decoration: none !important;
	transition: background 0.2s, color 0.2s !important;
	padding: 0 !important;
	margin: 0 !important;
	border: none !important;
	box-shadow: none !important;
}

.dy-wht-minicart-content .elementor-menu-cart__product-remove .remove_from_cart_button:hover,
.dy-wht-minicart-content .elementor-menu-cart__product-remove .elementor_remove_from_cart_button:hover {
	background: #e74c3c !important;
	color: #ffffff !important;
}

/* 叉叉圖示（用 ::after 偽元素繪製，不依賴字型） */
.dy-wht-minicart-content .elementor-menu-cart__product-remove .remove_from_cart_button::after,
.dy-wht-minicart-content .elementor-menu-cart__product-remove .elementor_remove_from_cart_button::after {
	content: '×' !important;
	font-size: 16px !important;
	line-height: 1 !important;
	color: inherit !important;
}

/* ── 小計區塊 ── */
.dy-wht-minicart-content .elementor-menu-cart__subtotal {
	display: flex !important;
	justify-content: center !important;
	align-items: center !important;
	gap: 6px !important;
	margin: 12px 0 0 !important;
	padding: 13px 16px !important;
	font-size: 15px !important;
	font-weight: 600 !important;
	color: #1a1a1a !important;
	border: 1px solid #e0e0e0 !important;
	border-radius: 6px !important;
	background: transparent !important;
}

.dy-wht-minicart-content .elementor-menu-cart__subtotal .woocommerce-Price-amount {
	font-size: 15px !important;
	font-weight: 600 !important;
	color: inherit !important;
}

/* ── 按鈕區 ── */
.dy-wht-minicart-content .elementor-menu-cart__footer-buttons {
	display: flex !important;
	gap: 10px !important;
	margin: 10px 0 0 !important;
	padding: 0 !important;
	flex-wrap: nowrap !important;
}

.dy-wht-minicart-content .elementor-menu-cart__footer-buttons .elementor-button {
	flex: 1 !important;
	display: block !important;
	text-align: center !important;
	padding: 13px 8px !important;
	border-radius: 6px !important;
	font-weight: 500 !important;
	font-size: 14px !important;
	text-decoration: none !important;
	transition: opacity 0.2s, transform 0.15s, background 0.2s, color 0.2s !important;
	border: 1px solid #e0e0e0 !important;
	box-shadow: none !important;
	line-height: 1.4 !important;
}

.dy-wht-minicart-content .elementor-menu-cart__footer-buttons .elementor-button:hover {
	transform: translateY(-1px) !important;
}

/* 查看購物車（白底有框） */
.dy-wht-minicart-content .elementor-button--view-cart {
	background: #ffffff !important;
	color: #1a1a1a !important;
	border-color: #d0d0d0 !important;
}

/* 結帳（深色實心） */
.dy-wht-minicart-content .elementor-button--checkout {
	background: #1a1a1a !important;
	color: #ffffff !important;
	border-color: #1a1a1a !important;
}

/* ── 自訂按鈕區塊 ── */
.dy-wht-minicart-custom-btns {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 8px;
}

.dy-wht-minicart-custom-btn {
	display: block;
	text-align: center;
	padding: 13px 8px;
	border-radius: 6px;
	font-weight: 500;
	font-size: 14px;
	text-decoration: none;
	border: 1px solid #d0d0d0;
	transition: background 0.2s, color 0.2s, transform 0.15s;
	letter-spacing: 0.01em;
}

.dy-wht-minicart-custom-btn:hover {
	transform: translateY(-1px);
}

/* Mini Cart 遮罩 */
.dy-wht-minicart-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.35);
	z-index: 99998;
	display: none;
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
}

.dy-wht-minicart-overlay.is-visible {
	display: block;
}

/* ══════════════════════════════════════════
   RWD
══════════════════════════════════════════ */
@media (max-width: 768px) {
	.dy-wht-search--sidebar-left {
		width: 85vw;
	}

	.dy-wht-search--fullscreen .dy-wht-search-inner {
		width: 92%;
	}

	.dy-wht-minicart-drawer {
		width: 85vw;
	}
}
