/* 移除所有產品的強制換行與清除浮動 */
.woocommerce ul.products[class*="columns-"] li.product.first {
    clear: none !important;
    margin-left: 0 !important;
}

/* 針對您設定的 4 欄位，重新定義真正的第一個產品位置 */
.woocommerce ul.products.columns-4 li.product:nth-child(4n+1) {
    clear: both !important;
}

/* 移除可能導致空隙的偽元素 */
.woocommerce ul.products::before,
.woocommerce ul.products li.product::before {
    display: none !important;
    content: none !important;
}

/* 放大產品詳情頁下方的相關產品圖片 */
.related.products ul.products li.product img, 
.upsells.products ul.products li.product img {
    width: 100% !important; /* 讓圖片填滿容器 */
    height: auto;
    object-fit: cover;
}

/* 讓詳情頁下方的相關產品圖片放大 */
.related.products ul.products {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* 設定間距 */
}

.related.products ul.products li.product {
    width: calc(25% - 20px) !important; /* 強制改為一排 3 個，圖片會變大 */
    float: none !important;
    margin: 0 !important;
}

.related.products ul.products li.product img {
    width: 100% !important;   /* 強制圖片填滿 li */
    height: auto !important;
    aspect-ratio: 1 / 1;     /* 強制所有縮圖變成正方形，看起來更整齊 */
    object-fit: cover;
}

/* 1. 確保 nav 容器本身有高度並水平排列 */
.nav {
    display: flex;
    align-items: center; /* 垂直居中 */
    height: 100%;       /* 如果 header 有固定高度，這行很重要 */
}

/* 2. 修正 ul 列表 */
.nav ul {
    display: flex;
    flex-direction: row;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center; /* 讓列表內的 li 項目垂直居中 */
}

/* 3. 修正 li 項目與連結 */
.nav li {
    margin: 0 15px;      /* 設定左右間距 */
    display: flex;
    align-items: center; /* 確保 li 內容也垂直居中 */
}

.nav a {
    text-decoration: none;
    line-height: 1;      /* 移除過高的行高，避免文字被往下推 */
    display: block;
}

/* 4. 特別針對 FiboSearch (dgwt-wcas-search-wrapp) 的修正 */
/* 因為搜尋圖示可能會比文字高，這行能確保它不會撐開選單高度 */
.nav .dgwt-wcas-search-wrapp {
    display: flex;
    align-items: center;
    margin-top: 0 !important;
}

.back-to-shop {
    margin-bottom: 20px;
    display: block;
}

.back-button {
    background-color: transparent !important;
    color: #333 !important;
    border: 1px solid #ccc !important;
    padding: 8px 15px !important;
    text-decoration: none;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.back-button:hover {
    background-color: #f5f5f5 !important;
    border-color: #FFD700 !important; /* 滑過時顯示您的品牌金黃色 */
    color: #FFD700 !important;
}

/* 針對手機與平板設備 (螢幕寬度 768px 以下) */
@media screen and (max-width: 768px) {
    /* 1. 縮小 nav 內的連結字體 */
    .nav a {
        font-size: 11px !important; /* 原本可能較大，縮小至 13px */
        letter-spacing: -0.7px;      /* 稍微壓縮字距，增加空間 */
    }

    /* 2. 縮減選單項目之間的左右間距 */
    .nav li {
        margin: 0 6px !important;    /* 將原本的 15px 大幅縮小 */
    }

    /* 3. 確保容器不會因為 FiboSearch 撐開 */
    .nav .dgwt-wcas-search-wrapp {
        transform: scale(0.9);      /* 稍微縮小搜尋圖示 */
        margin: 0 !important;
    }	

/* 1. 強制產品清單 ul 為 Flex 佈局並允許換行 */
    .woocommerce ul.products {
        display: flex !important;
        flex-wrap: wrap !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 2. 設定每個產品佔寬度的一半 (扣除間距) */
    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product {
        width: 42% !important;      /* 兩格各佔 48%，保留 4% 做中間空隙 */
        float: left !important;
        margin-left: 1% !important;
        margin-right: 1% !important;
        margin-bottom: 20px !important;
        clear: none !important;     /* 移除強制換行 */
    }

    /* 3. 確保每兩個產品能自動對齊，移除第奇數個以外的清除浮動 */
    .woocommerce ul.products li.product:nth-child(2n+1) {
        clear: both !important;     /* 每兩張圖換一次行 */
    }

    /* 4. 縮小手機版產品標題字體，避免文字長短不一撐開高度 */
    .woocommerce ul.products li.product h2,
    .woocommerce ul.products li.product .woocommerce-loop-product__title {
        font-size: 14px !important;
        line-height: 1.2 !important;
        height: 2.4em;             /* 限制兩行高度，保持對齊 */
        overflow: hidden;
    }	
}

/* 針對極窄螢幕 (例如 iPhone SE 等寬度 375px 以下的手機) */
@media screen and (max-width: 375px) {
    .nav a {
        font-size: 8px !important;
    }
    .nav li {
        margin: 0 4px !important;
    }
}

/* 1. 放大「選擇檔案」按鈕整體 */
.alg_checkout_files_button, 
#alg_checkout_files_button_1 {
    display: inline-block !important;
    padding: 15px 30px !important; /* 增加內距讓按鈕變大 */
    font-size: 18px !important;    /* 放大字體 */
    font-weight: bold !important;
    color: #ffffff !important;
    background-color: #FFD700 !important; /* 使用您的金色主題色，或改為 #0073aa */
    border: none !important;
    border-radius: 5px !important;
    cursor: pointer !important;
    width: auto !important;
    min-width: 200px !important;
    text-align: center !important;
    margin: 10px 0 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
}

/* 2. 針對手機版：讓按鈕寬度撐滿螢幕，方便手指點擊 */
@media screen and (max-width: 768px) {
    .alg_checkout_files_button, 
    #alg_checkout_files_button_1 {
        display: block !important;
        width: 100% !important;
        padding: 20px !important; /* 手機版再加高一點 */
        font-size: 20px !important;
    }
    
    /* 放大上方的標籤文字 (例如：請上傳付款證明) */
    .alg_checkout_files_upload_container label {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        display: block !important;
    }
}

/* 3. 滑過按鈕時的顏色變化 */
.alg_checkout_files_button:hover, 
#alg_checkout_files_button_1:hover {
    background-color: #e6c200 !important;
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* 1. 精準定位這個按鈕的 ID */
#alg_checkout_files_upload_button_1 {
    display: block !important;
    width: 100% !important;        /* 寬度撐滿容器 */
    max-width: 500px !important;   /* 最大寬度，防止在電腦上太寬 */
    margin: 15px auto !important;  /* 居中並增加間距 */
    padding: 20px 0 !important;    /* 增加高度，這會讓按鈕變得很巨大 */
    font-size: 22px !important;    /* 放大字體 */
    font-weight: 800 !important;   /* 字體加粗 */
    color: #000000 !important;     /* 黑字 */
    background-color: #FFD700 !important; /* 金色背景 */
    border: 2px solid #000 !important;    /* 黑色邊框增加質感 */
    border-radius: 10px !important;       /* 圓角 */
    cursor: pointer !important;
    text-transform: uppercase;
    box-shadow: 0 6px 0 #b8860b !important; /* 增加立體感陰影 */
    transition: all 0.1s ease-in-out !important;
}

/* 2. 按下去的效果（模擬真實按鈕感） */
#alg_checkout_files_upload_button_1:active {
    box-shadow: 0 2px 0 #b8860b !important;
    transform: translateY(4px) !important;
}

/* 3. 滑過顏色稍微變深 */
#alg_checkout_files_upload_button_1:hover {
    background-color: #f2cc00 !important;
}

/* 4. 手機版特別優化 */
@media screen and (max-width: 768px) {
    #alg_checkout_files_upload_button_1 {
        font-size: 24px !important; /* 手機上字體再大一點 */
        padding: 25px 0 !important; /* 手機上點擊區域再加高 */
        border-radius: 8px !important;
    }
}

/* --- 終極修正：針對您的 HTML 結構 --- */

/* 1. 隱藏子選單：針對您的 nav.nav 結構 */
.nav ul li ul.sub-menu {
    display: none !important;                
    position: absolute !important;           
    top: 100% !important;                    
    left: 0 !important;
    z-index: 99999 !important;               
    min-width: 200px !important;                
    background-color: #ffffff !important;   /* 選單背景色 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    padding: 10px 0 !important;
    margin: 0 !important;
}

/* 2. 顯示子選單：滑鼠移上去時 */
.nav ul li:hover > ul.sub-menu {
    display: block !important;
}

/* 3. 確保主選單項目為相對定位，這是子選單絕對定位的基礎 */
.nav ul li {
    position: relative !important;
}

/* 4. 修正子選單內的列表項目樣式 */
.nav ul.sub-menu li {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 5. 修正子選單內的連結文字樣式 */
.nav ul.sub-menu li a {
    display: block !important;
    padding: 10px 20px !important;
    color: #333 !important; /* 子選單文字顏色 */
    font-size: 14px !important;
    text-align: left !important;
}

/* 針對產品頁面的加入購物車表單進行調整 */
.single-product form.cart {
    display: flex;
    flex-direction: column; /* 將橫向排列改為垂直排列 */
    align-items: flex-start; /* 按鈕靠左對齊，若要置中可改為 center */
}

/* 增加數量選擇器和按鈕之間的間距 */
.single-product form.cart .quantity {
    margin-bottom: 15px; /* 下方留一點空間給按鈕 */
    margin-right: 0;    /* 移除原本在右邊的間距 */
	  padding-top: 10px;
}

/* 如果你希望按鈕變成跟數量選擇器一樣寬，或全寬，可以加入以下： */
.single-product form.cart .single_add_to_cart_button {
    width: auto; /* 或者設為 200px 等固定寬度 */
    min-width: 150px;
	  margin-top: 20px;
}

/* 讓數量標籤重新顯示 */
.single-product .quantity label.screen-reader-text {
    clip: auto !important;
    clip-path: none !important;
    height: auto !important;
    margin: 0 0 8px 0 !important;
    overflow: visible !important;
    position: static !important;
    width: auto !important;
    display: block !important; /* 確保它獨佔一行 */
    font-weight: bold; /* 讓標籤加粗更易讀 */
    color: #333; /* 標籤顏色 */
}

/* 留言區基礎樣式 */
.comments-wrapper {
    margin-top: 2rem;
    padding: 2rem;
    background: #f9f9f9;
    border-radius: 10px;
}

.comment-respond h3 {
    color: #8B0000; /* 配合你標題的深紅色 */
}

.comment-form-comment textarea {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
}

/* 提交按鈕樣式 */
.submit {
    background-color: #8B0000;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.submit:hover {
    background-color: #a00000;
}
