/* ===== 莫蘭迪配色系統 - 固定文字色彩變數 ===== */
/* 這些是不連動後台的固定文字色彩，用於統一視覺 */
:root {
    /* 主要文字色 - 深灰（高對比） */
    --ys-text-primary: #3d4852;
    /* 次要文字色 - 中灰 */
    --ys-text-secondary: #5a6570;
    /* 輔助文字色 - 淺灰（說明文字、placeholder） */
    --ys-text-muted: #8a939c;
    /* 標題文字色 */
    --ys-text-heading: #2d3748;
    /* 錯誤/刪除色 */
    --ys-text-danger: #c53030;
    /* 白色文字 */
    --ys-text-white: #ffffff;
}

/* ===== 結帳頁面基礎文字樣式 ===== */
.yangsheep-design-checkout-page {
    color: var(--ys-text-primary);
    font-size: 15px;
    line-height: 1.6;
}

/* 段落文字 */
.yangsheep-design-checkout-page p {
    color: var(--ys-text-primary);
    margin-bottom: 12px;
}

/* 說明文字 */
.yangsheep-design-checkout-page .description,
.yangsheep-design-checkout-page .yangsheep-coupon-text,
.yangsheep-design-checkout-page .woocommerce-info {
    color: var(--ys-text-secondary);
    font-size: 14px;
}

/* 標籤文字 */
.yangsheep-design-checkout-page label {
    color: var(--ys-text-primary);
    font-weight: 500;
}

/* 表單欄位文字 */
.yangsheep-design-checkout-page input,
.yangsheep-design-checkout-page select,
.yangsheep-design-checkout-page textarea {
    color: var(--ys-text-primary);
}

/* placeholder 文字 */
.yangsheep-design-checkout-page input::placeholder,
.yangsheep-design-checkout-page textarea::placeholder {
    color: var(--ys-text-muted);
}

/* 區塊順序 */
.yangsheep-login-block {
    order: 1;
}

.yangsheep-review-wrapper {
    order: 2;
}

.yangsheep-smart-coupon {
    order: 3;
}

.yangsheep-coupon-block {
    order: 4;
}

.yangsheep-checkout-country {
    order: 5;
}

.yangsheep-shipping-cards-wrapper {
    order: 6;
}

.yangsheep-customer-details {
    order: 7;
}

.yangsheep-checkout-sidebar-wrapper {
    order: 8;
}

.yangsheep-payment {
    order: 9;
}

/* ===== 桌機版佈局 (>=1000px) ===== */
@media (min-width: 1000px) {

    /* 佈局容器：flex row，stretch 對齊 */
    .yangsheep-checkout-layout {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    /* 側邊欄：20% 寬度 */
    .yangsheep-sidebar-column {
        width: 20%;
        flex-shrink: 0;
        position: relative;
    }

    /* 表單：80% 寬度 */
    .yangsheep-form-column,
    form.checkout.woocommerce-checkout {
        width: 80%;
        flex-shrink: 0;
    }

    /* sidebar-wrapper：在 sidebar-column 內 sticky */
    .yangsheep-checkout-sidebar-wrapper {
        position: sticky;
        top: 120px;
        width: 100%;
        padding-right: 20px;
        box-sizing: border-box;
    }

    /* 當觸底時的狀態 */
    .yangsheep-checkout-sidebar-wrapper.is-bottom {
        position: absolute;
        bottom: 0;
        top: auto;
    }
}

/* ===== 手機版：sidebar-wrapper 留在 form 內 ===== */
@media (max-width: 999.9px) {
    .yangsheep-sidebar-column {
        display: none;
    }

    .yangsheep-checkout-sidebar-wrapper {
        display: block;
    }
}

/* 結帳欄位順序 - 已改用 Grid 和 priority 控制，不再使用 order */
/* CVS 超商欄位樣式已移至 class-yangsheep-third-party-shipping-compat.php */

/* 國家樣式 */
form.checkout {
    display: grid !important;
    grid-template-columns: unset !important;
    grid-row-gap: unset !important;
}

/* 登入樣式 */
.yangsheep-login-text {
    color: var(--login-text-color) !important;
    background: var(--login-text-bg) !important;
    padding: var(--login-text-padding) !important;
}

.yangsheep-logintext-footer {
    margin: 20px 0px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    align-content: center;
}

.yangsheep-loginbutton {
    color: var(--theme-button-text-initial-color);
    border: var(--button-border);
    background-color: var(--theme-button-background-initial-color);
    font-family: var(--buttonFontFamily, var(--fontFamily));
    font-size: var(--buttonFontSize);
    font-weight: var(--buttonFontWeight);
    font-style: var(--buttonFontStyle);
    line-height: var(--buttonLineHeight);
    letter-spacing: var(--buttonLetterSpacing);
    padding: var(--button-padding);
    text-align: center;
    border-radius: var(--buttonBorderRadius, 3px);
}

.yangsheep-login .lost_password {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    margin: 15px 0px 0px 0px !important;
}

.yangsheep-login form.woocommerce-form-login .form-row {
    margin-bottom: 0px !important;
    width: 100%;
}

.woocommerce-form-login__submit {
    width: 100px;
}

.yangsheep-login .lost_password p {
    font-size: 16px !important;
}

.woocommerce-form-login__submit {
    width: 100%;
}

.woocommerce-form-login__rememberme {
    margin: 15px 0px 15px 0px;
}

/* 社群登入 CSS */
#nsl-custom-login-form-5 .nsl-separator,
#nsl-custom-login-form-6 .nsl-separator {
    margin: 10px 0px 0px 0px !important;
}

.yangsheep-design-checkout-page .nsl-container-buttons,
.yangsheep-design-checkout-page #nsl-custom-login-form-1,
.yangsheep-design-checkout-page #nsl-custom-login-form-2,
.yangsheep-design-checkout-page #nsl-custom-login-form-3,
.yangsheep-design-checkout-page #nsl-custom-login-form-4,
.yangsheep-design-checkout-page #nsl-custom-login-form-5,
.yangsheep-design-checkout-page #nsl-custom-login-form-6 {
    width: 100%;
}

.yangsheep-login {
    border: 2px solid var(--theme-form-field-border-initial-color);
    background-color: var(--bgcolor-gray-200);
    margin-bottom: 20px;
}

/* 訂單預覽 */
.yangsheep-review-wrapper {
    margin-bottom: 20px;
}

.ct-order-review table.shop_table {
    margin-bottom: 0px !important;
}

.ct-order-review {
    background: var(--order-review-bg-color) !important;
    border: 2px solid var(--theme-section-border-color) !important;
    /* padding 由 RWD 區塊統一控制 */
    margin-bottom: 20px !important;
    border-radius: var(--block-border-radius, 8px) !important;
}

/* 運輸方式 */
ul#shipping_method {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 20px;
}

ul#shipping_method li {
    margin: 0 !important;
    padding: 5px 10px;
    border: 1px solid;
}

/* 欄位樣式 - 隱藏地址欄位的「選填」文字（超商取貨模式由外掛設為選填） */
#shipping_postcode_field .optional,
#shipping_state_field .optional,
#shipping_city_field .optional,
#shipping_address_1_field .optional,
#shipping_address_2_field .optional,
#billing_postcode_field .optional,
#billing_state_field .optional,
#billing_city_field .optional,
#billing_address_1_field .optional,
#billing_address_2_field .optional {
    display: none !important;
}

.yangsheep-wide50,
#shipping_phone_field {
    width: 48.5%;
}

/* 註解：避免干擾外掛的欄位控制，改用更安全的方式
.yangsheep-wide100 {
    width: 100%;
}
*/

.form-row {
    margin-bottom: 10px;
}

/* 註解：避免干擾 PayNow 等外掛的欄位控制
#shipping_postcode_field {
    display: block;
}
*/

#shipping_postcode_field input {
    background: var(--form-field-bg-color);
    border-color: var(--theme-form-field-border-initial-color);
}

.woocommerce-billing-fields,
.woocommerce-shipping-fields,
.woocommerce-additional-fields,
.yangsheep-checkout-country {
    border: 2px solid var(--theme-section-border-color, #e0e0e0);
    background-color: var(--section-bg-color, #f9f9f9);
    margin-bottom: 20px;
    border-radius: var(--block-border-radius, 8px);
    /* padding 由 RWD 區塊統一控制 */
}

/* ===== 區塊標題 - 統一樣式 ===== */
.woocommerce-billing-fields .yangsheep-h3-title,
.woocommerce-shipping-fields .yangsheep-h3-title,
.woocommerce-additional-fields .yangsheep-h3-title,
.woocommerce-additional-fields h3,
.yangsheep-checkout-country h3,
.yangsheep-order-review h3,
.yangsheep-coupon-block .yangsheep-h3-title,
.yangsheep-shipping-title,
.ct-order-review h3,
h3.yangsheep-h3-title,
h3#order_review_heading,
.yangsheep-payment .yangsheep-h3-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ys-text-heading);
}

/* ===== 同訂購人 / 備註 Checkbox 樣式（與物流卡片一致）===== */
.yangsheep-same-as-billing,
.yangsheep-order-notes-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 15px;
    padding: 0;
}

.yangsheep-same-as-billing span,
.yangsheep-order-notes-toggle span {
    font-size: 16px;
    font-weight: 500;
    color: var(--ys-text-primary);
    line-height: 1.4;
}

/* 隱藏原生 checkbox */
.yangsheep-same-as-billing input[type="checkbox"],
.yangsheep-order-notes-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* 自訂勾選框指示器（與物流卡片相同樣式）*/
.yangsheep-same-as-billing::before,
.yangsheep-order-notes-toggle::before {
    content: '';
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid var(--theme-form-field-border-initial-color, #d0d0d0);
    border-radius: 4px;
    background: #ffffff;
    position: relative;
    transition: all 0.2s ease;
    display: inline-block;
}

/* Hover 狀態 */
.yangsheep-same-as-billing:hover::before,
.yangsheep-order-notes-toggle:hover::before {
    border-color: var(--theme-button-background-initial-color, #6b7a95);
}

/* 勾選狀態 - 勾選框背景 */
.yangsheep-same-as-billing:has(input:checked)::before,
.yangsheep-order-notes-toggle:has(input:checked)::before {
    border-color: var(--theme-button-background-initial-color, #6b7a95);
    background: var(--theme-button-background-initial-color, #6b7a95);
}

/* 勾勾符號（使用 after 偽元素）*/
.yangsheep-same-as-billing::after,
.yangsheep-order-notes-toggle::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    margin-top: -6px;
    width: 6px;
    height: 11px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: all 0.2s ease;
}

/* 勾選狀態 - 顯示勾勾 */
.yangsheep-same-as-billing:has(input:checked)::after,
.yangsheep-order-notes-toggle:has(input:checked)::after {
    transform: rotate(45deg) scale(1);
}

/* 確保容器是 relative 讓 after 定位 */
.yangsheep-same-as-billing,
.yangsheep-order-notes-toggle {
    position: relative;
}

/* 取貨超商 - 樣式已移至 class-yangsheep-third-party-shipping-compat.php */

/* 隱藏超取欄位的「選填」文字 */
#CVSStoreName_field .optional,
#CVSAddress_field .optional,
#CVSTelephone_field .optional,
#payuni_storename_field .optional,
#payuni_storeaddress_field .optional,
#payuni_storeid_field .optional {
    display: none !important;
}

/* 超取欄位由 JS 動態控制顯示，不再用 CSS 強制隱藏
 * 避免與 PayNow/PayUni 外掛的 JS 控制衝突
 * @see yangsheep-checkout.js updateShippingFieldsVisibility()
 */
/*
#payuni_storename_field,
#payuni_storeaddress_field,
#payuni_storeid_field {
    display: none;
}
*/

/* 登入標題 - 樣式已在統一區塊標題中定義 */

/* 強制電話 */
/*
#shipping_phone_field {
    display: block !important;
}
*/

/* 複製收件人 */
.yangsheep-copy span {
    display: none !important;
}

/* 帳單國家隱藏 */
#billing_country_field {
    display: none;
}

/* PAYNOW 圖示 */
#payment li img {
    display: none;
}

/* 運送標題隱藏 */
h3#ship-to-different-address {
    display: none;
}

/* COUPON 區塊 */
.yangsheep-coupon-block {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border: 2px solid var(--theme-section-border-color);
    background-color: var(--section-bg-color);
    border-radius: var(--block-border-radius, 8px);
    margin-bottom: 20px;
    gap: 0;
}

a.woocommerce-remove-coupon {
    font-size: 10px !important;
}

.yangsheep-coupon,
.yangsheep-coupon-point {
    background-color: var(--coupon-block-bg-color);
    padding: 20px;
    box-sizing: border-box;
}

/* 折扣代碼區塊 - 預設佔滿，有購物金時各佔 50% */
.yangsheep-coupon {
    flex: 1 1 50%;
    min-width: 0;
}

/* 購物金區塊 - 預設隱藏，JS 控制顯示 */
.yangsheep-coupon-point {
    flex: 1 1 50%;
    min-width: 0;
    border-left: 1px solid var(--theme-section-border-color);
    display: none;
    border-radius: 0 var(--block-border-radius, 8px) var(--block-border-radius, 8px) 0;
}

/* 購物金區塊顯示時（有 has-content class 或 inline style） */
.yangsheep-coupon-point.has-content,
.yangsheep-coupon-point[style*="display: block"] {
    display: block !important;
}

/* 沒有購物金時，折扣代碼全寬 */
.yangsheep-coupon-block:not(.has-point) .yangsheep-coupon {
    flex: 1 1 100%;
}

.yangsheep-coupon input {
    background: #fff !important;
}

.yangsheep-inputform {
    width: 100%;
    margin: 10px 0 5px !important;
}

.yangsheep-coupon-button {
    padding: 0;
    width: 100%;
    margin-bottom: 0;
}

.yangsheep-coupon-button button {
    padding: 10px 0;
    width: 100%;
    color: var(--theme-button-text-initial-color) !important;
    border-radius: 2px;
    margin-bottom: 0;
}

/* 購物金 */
.yangsheep-h3-point-title {
    margin: 0;
}

.yangsheep-coupon-point .woocommerce-cart-notice {
    background-color: var(--section-bg-color);
    margin-bottom: 0 !important;
    display: block !important;
    padding: 0;
}

.yangsheep-coupon-point .woocommerce-cart-notice::before {
    display: none !important;
}

.yangsheep-coupon-point a.ywpar-button-message {
    display: none !important;
}

.yangsheep-coupon-point .ywpar_apply_discounts_container {
    margin: 10px 0 0 !important;
    display: block !important;
    width: 100% !important;
    color: var(--ys-text-secondary) !important;
}

.yangsheep-coupon-point .ywpar_apply_discounts {
    display: flex;
    flex-direction: column !important;
    gap: 5px;
}

.yangsheep-coupon-point #ywpar-points-max {
    width: 100%;
    max-width: 100% !important;
    background: #fff;
    padding: 0 15px !important;
    text-align: left;
}

.yangsheep-coupon-point .button {
    padding: 12px 0;
    width: 100%;
    color: var(--theme-button-text-initial-color) !important;
    border-radius: 0;
    font-size: 16px;
    line-height: 16px;
    margin-bottom: 0;
}

#yith-par-message-reward-cart {
    display: none !important;
}

#yith-par-message-cart {
    display: block !important;
}

/* 智慧折扣券 */
#coupons_list {
    border: 2px solid var(--theme-section-border-initial-color);
    margin-bottom: 20px;
}

#coupons_list h3 {
    margin-bottom: 10px;
}

/* 結帳 */
.yangsheep-payment {
    border: 2px solid var(--theme-section-border-color);
    border-radius: var(--block-border-radius, 8px);
    margin-bottom: 20px;
}

/* ===== 付款方式 Label 與 Radio 樣式 ===== */
.wc_payment_methods .wc_payment_method label {
    padding: 8px 10px !important;
    display: block;
    cursor: pointer;
}

/* 付款方式 Radio 樣式 - 與主題色一致 */
.wc_payment_methods .wc_payment_method input[type="radio"] {
    accent-color: var(--theme-button-background-initial-color, #6b7a95);
}

/* === 超商同步按鈕區塊 === */
.choose-cvs-row {
    width: 100%;
    margin-bottom: 10px;
}

.choose-cvs-shipping {
    width: 100%;
    background: var(--theme-button-background-initial-color, #6b7a95);
    color: var(--theme-button-text-initial-color, #fff);
    border: none;
    padding: 12px 0;
    border-radius: var(--block-border-radius, 8px);
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

.choose-cvs-shipping:hover {
    background: #425075;
}

/* RWD: >=1000px */
@media(min-width:1000px) {
    .yangsheep-login {
        padding: 20px;
    }

    .yangsheep-login .woocommerce-form-login .form-row-first {
        width: 49% !important;
        margin-right: 1%;
    }

    .yangsheep-login .woocommerce-form-login .form-row-last {
        width: 49% !important;
        margin-left: 1%;
    }

    /* ===== 區塊 padding - 統一 20px ===== */
    .woocommerce-billing-fields,
    .woocommerce-shipping-fields,
    .woocommerce-additional-fields,
    .yangsheep-checkout-country,
    .yangsheep-payment,
    .yangsheep-order-review,
    .ct-order-review {
        padding: 20px !important;
    }

    #yangsheep_copy_field {
        width: 100%;
        margin-bottom: 10px;
        display: block !important;
    }

    #coupons_list {
        padding: 20px;
    }

    /*購買時註冊欄位 */
    .yangsheep-account-fields {
        width: 100% !important;
        margin-top: 15px;
    }

    .yangsheep-account-note {
        font-size: 13px;
        color: var(--ys-text-muted);
        margin-bottom: 10px;
        padding: 10px 15px;
        background: rgba(0, 0, 0, 0.03);
        border-radius: 4px;
    }

    .woocommerce-billing-fields__field-wrapper #account_password_field {
        width: 100% !important;
    }
}

/* RWD: <=999.9px（平板以下通用） */
@media(max-width:999.9px) {
    .yangsheep-login {
        padding: 20px 15px;
    }

    .yangsheep-wide50,
    #shipping_phone_field {
        width: 100%;
    }

    #coupons_list {
        padding: 20px 15px;
    }

    /* ===== 區塊 padding - 統一 20px 15px ===== */
    .woocommerce-billing-fields,
    .woocommerce-shipping-fields,
    .woocommerce-additional-fields,
    .yangsheep-checkout-country,
    .yangsheep-payment,
    .yangsheep-order-review,
    .ct-order-review {
        padding: 20px 15px !important;
    }

    /*購買時註冊欄位 */
    .woocommerce-billing-fields__field-wrapper #account_username_field,
    .woocommerce-billing-fields__field-wrapper #account_password_field {
        width: 100% !important;
    }
}

/* RWD: 平板以上 (>=768px) - 折扣代碼 & 購物金左右並排 */
@media(min-width:768px) {
    .yangsheep-coupon-block {
        flex-direction: row !important;
        padding: 20px 0 !important;
    }

    .yangsheep-coupon-block.has-point {
        padding: 20px 0 !important;
    }

    .yangsheep-coupon,
    .yangsheep-coupon-point {
        flex: 1 1 50%;
        padding: 0 20px;
    }

    .yangsheep-coupon-point.has-content {
        border-left: 1px solid var(--theme-section-border-color);
        border-top: none;
    }
}

/* RWD: 手機版 (<768px) - 折扣代碼 & 購物金上下堆疊 */
@media(max-width:767.9px) {
    .yangsheep-coupon-block {
        flex-direction: column !important;
        padding: 20px 0 !important;
    }

    .yangsheep-coupon,
    .yangsheep-coupon-point {
        margin: 0;
        width: 100%;
        flex: 1 1 100%;
        padding: 0 15px;
    }

    .yangsheep-coupon-point.has-content {
        border-left: none;
        border-top: 1px solid var(--theme-section-border-color);
        margin-top: 20px;
        padding-top: 20px;
    }
}

/* RWD: >=699px */
@media(min-width:699px) {
    .yangsheep-design-checkout-page .nsl-container-buttons {
        display: flex !important;
        gap: 20px;
    }

    .yangsheep-design-checkout-page #nsl-custom-login-form {
        width: 98%;
    }

    form.woocommerce-form-login {
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

/* RWD: <=689.98px */
@media(max-width:689.98px) {
    form.woocommerce-form-login {
        display: flex;
        flex-wrap: wrap;
    }

    .woocommerce-checkout-payment {
        margin-inline: unset !important;
    }

    .yangsheep-payment-block .place-order {
        padding: 0 !important;
        margin-top: 10px;
    }

    .yangsheep-payment-block .woocommerce-checkout-payment .place-order .woocommerce-terms-and-conditions-wrapper {
        margin-bottom: 10px !important;
    }
}

/* ===== 商品明細樣式 (filter 注入) ===== */

/* 商品項目容器 */
.yangsheep-cart-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px;
    width: 100%;
    position: relative;
}

/* 刪除按鈕 */
.yangsheep-cart-item .yangsheep-remove-item {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    color: var(--ys-text-muted);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.yangsheep-cart-item .yangsheep-remove-item:hover {
    color: var(--ys-text-danger);
}

/* 商品圖片 */
.yangsheep-cart-item .yangsheep-item-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 4px;
}

.yangsheep-cart-item .yangsheep-item-image img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: cover !important;
    border-radius: 4px;
}

/* 商品資訊 */
.yangsheep-cart-item .yangsheep-item-info {
    flex: 1;
    min-width: 0;
}

.yangsheep-cart-item .yangsheep-item-name {
    font-size: 14px;
    color: var(--ys-text-primary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.yangsheep-cart-item .yangsheep-item-price {
    font-size: 13px;
    color: var(--ys-text-muted);
}

/* 數量控制 */
.yangsheep-cart-item .yangsheep-item-qty {
    flex-shrink: 0;
}

.yangsheep-quantity-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--theme-section-border-color, #e0e0e0);
    border-radius: 4px;
    overflow: hidden;
}

.yangsheep-qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--ys-text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.yangsheep-qty-btn:hover {
    background: var(--theme-button-background-initial-color, #6b7a95);
    color: var(--ys-text-white);
}

.yangsheep-qty-value {
    min-width: 32px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 28px;
}

/* 小計 */
.yangsheep-cart-item .yangsheep-item-subtotal {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-button-background-initial-color, #6b7a95);
    flex-shrink: 0;
    min-width: 70px;
    text-align: right;
}

/* 隱藏預設數量顯示 */
.woocommerce-checkout-review-order-table .product-quantity {
    display: none !important;
}

/* ===== 自訂商品明細樣式 ===== */

/* 隱藏 WooCommerce 的原始 order_review（保留功能但不顯示）*/
.yangsheep-order-totals .woocommerce-checkout-review-order {
    display: none !important;
}

/* 商品明細外層容器 */
.yangsheep-order-review {
    border: 2px solid var(--theme-section-border-color, #e0e0e0);
    background-color: var(--section-bg-color, #f9f9f9);
    border-radius: var(--block-border-radius, 8px);
    /* padding 由 RWD 區塊統一控制 */
    margin-bottom: 0;
}

.yangsheep-order-review h3 {
    color: inherit;
    /* font-size, font-weight, margin 已在統一區塊標題中定義 */
}

/* 商品項目容器 */
.yangsheep-order-items-container {
    margin-bottom: 0;
}

.yangsheep-order-items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ===== 單個商品項目 - Flex 佈局（簡化結構）===== */
/* 結構：.yangsheep-order-item > .yangsheep-remove-item + .yangsheep-item-content */
.yangsheep-order-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.yangsheep-order-item:last-child {
    border-bottom: none;
}

/* 刪除按鈕 */
.yangsheep-order-item > .yangsheep-remove-item {
    flex-shrink: 0;
    width: 20px !important;
    height: 20px !important;
    border: none !important;
    background: rgba(0, 0, 0, 0.1) !important;
    color: var(--ys-text-secondary) !important;
    border-radius: 50% !important;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px !important;
    text-align: center;
    transition: all 0.2s ease;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.yangsheep-order-item > .yangsheep-remove-item:hover {
    background: #e74c3c !important;
    color: var(--ys-text-white) !important;
}

/* 內容區塊 - 電腦版 Flex 橫向 */
.yangsheep-order-item > .yangsheep-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* 商品圖片 */
.yangsheep-item-content > .yangsheep-item-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
}

.yangsheep-item-content .yangsheep-item-image img {
    width: 50px !important;
    height: 50px !important;
    object-fit: cover;
    border-radius: 4px;
}

/* 商品資訊 */
.yangsheep-item-content > .yangsheep-item-info {
    flex: 1;
    min-width: 0;
}

.yangsheep-order-item .yangsheep-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ys-text-primary);
    margin-bottom: 4px;
}

.yangsheep-order-item .yangsheep-item-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.yangsheep-order-item .yangsheep-item-name a:hover {
    color: var(--theme-button-background-initial-color, #6b7a95);
    text-decoration: underline;
}

.yangsheep-order-item .yangsheep-item-price {
    font-size: 13px;
    color: var(--ys-text-muted);
}

/* 數量控制 */
.yangsheep-item-content > .yangsheep-item-qty {
    flex-shrink: 0;
}

.yangsheep-order-item .yangsheep-quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 4px 8px;
}

.yangsheep-order-item .yangsheep-qty-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--ys-text-secondary);
    line-height: 1;
}

.yangsheep-order-item .yangsheep-qty-btn:hover {
    color: var(--theme-button-background-initial-color, #6b7a95);
}

.yangsheep-order-item .yangsheep-qty-value {
    min-width: 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

/* 小計 */
.yangsheep-item-content > .yangsheep-item-subtotal {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-button-background-initial-color, #6b7a95);
    min-width: 70px;
    text-align: right;
}

/* 限制所有結帳區域的圖片尺寸 */
.ct-order-review img,
.woocommerce-checkout-review-order img,
.yangsheep-review-wrapper img,
.yangsheep-cart-item img {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: cover !important;
    border-radius: 4px !important;
}

/* ct-order-review 標題 - 樣式已在統一區塊標題中定義 */

/* ===== 商品明細 RWD - 手機版 ===== */
@media (max-width: 768px) {
    /* 商品項目：保持 Flex 左右結構 */
    .yangsheep-order-item {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px;
        padding: 12px 0;
    }

    /* 刪除按鈕：靠左固定 */
    .yangsheep-order-item > .yangsheep-remove-item {
        flex-shrink: 0;
        align-self: center;
    }

    /* 內容區塊：手機版使用 Grid 兩行 */
    .yangsheep-order-item > .yangsheep-item-content {
        flex: 1;
        display: grid !important;
        /* 圖片 | 商品資訊（滿寬） */
        grid-template-columns: 50px 1fr;
        grid-template-rows: auto auto;
        gap: 8px;
        min-width: 0;
    }

    /* 上排：圖片 - row 1, col 1 (跨兩行) */
    .yangsheep-item-content > .yangsheep-item-image {
        grid-column: 1;
        grid-row: 1 / 3;
        width: 50px;
        height: 50px;
        align-self: center;
    }

    /* 上排：商品名稱+單價 - row 1, col 2（滿寬）*/
    .yangsheep-item-content > .yangsheep-item-info {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
    }

    .yangsheep-order-item .yangsheep-item-name {
        font-size: 14px;
        margin-bottom: 2px;
    }

    .yangsheep-order-item .yangsheep-item-price {
        font-size: 12px;
        color: var(--ys-text-muted);
    }

    /* 下排：數量控制 + 小計 - row 2, col 2 */
    .yangsheep-item-content > .yangsheep-item-qty {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
    }

    /* 下排：小計 - row 2, col 2（靠右）*/
    .yangsheep-item-content > .yangsheep-item-subtotal {
        grid-column: 2;
        grid-row: 2;
        font-size: 14px;
        font-weight: 600;
        justify-self: end;
        align-self: center;
        min-width: auto;
        text-align: right;
    }

    .yangsheep-order-item .yangsheep-quantity-control {
        padding: 0;
        gap: 2px;
    }

    .yangsheep-order-item .yangsheep-qty-btn {
        width: 28px;
        height: 24px;
        font-size: 22px;
    }

    .yangsheep-order-item .yangsheep-qty-value {
        font-size: 14px;
        min-width: 20px;
    }
}

/* ===== 結帳欄位 Grid 佈局 ===== */

/* 欄位包裝器使用 Grid */
.woocommerce-billing-fields__field-wrapper,
.woocommerce-shipping-fields__field-wrapper {
    display: grid;
    gap: 15px;
}

/* 電腦版：2 欄（姓名+電話） */
@media (min-width: 1000px) {

    .woocommerce-billing-fields__field-wrapper,
    .woocommerce-shipping-fields__field-wrapper {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 地址欄位永遠 100% */
    .woocommerce-billing-fields__field-wrapper #billing_address_1_field,
    .woocommerce-billing-fields__field-wrapper #billing_address_2_field,
    .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field,
    .woocommerce-shipping-fields__field-wrapper #shipping_address_2_field {
        grid-column: 1 / -1;
    }

    /* 電子郵件全寬 */
    .woocommerce-billing-fields__field-wrapper #billing_email_field {
        grid-column: 1 / -1;
    }

    /* 建立帳號區塊全寬 */
    .woocommerce-billing-fields__field-wrapper .yangsheep-create-account {
        grid-column: 1 / -1;
    }

    /* 同訂購人 Checkbox 全寬 */
    .woocommerce-shipping-fields__field-wrapper .yangsheep-copy-billing,
    #yangsheep_copy_billing_field {
        grid-column: 1 / -1;
    }

    /* ===== 收件人姓名電話強制並排（一般模式）===== */
    /* 確保姓名和電話欄位在 Grid 中保持並排 */
    #shipping_last_name_field,
    #shipping_first_name_field,
    #shipping_phone_field {
        grid-column: span 1 !important;
    }
}

/* 平板版：2 欄 */
@media (min-width: 768px) and (max-width: 999.9px) {

    .woocommerce-billing-fields__field-wrapper,
    .woocommerce-shipping-fields__field-wrapper {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 地址欄位永遠 100% */
    .woocommerce-billing-fields__field-wrapper #billing_address_1_field,
    .woocommerce-billing-fields__field-wrapper #billing_address_2_field,
    .woocommerce-shipping-fields__field-wrapper #shipping_address_1_field,
    .woocommerce-shipping-fields__field-wrapper #shipping_address_2_field,
    .woocommerce-billing-fields__field-wrapper #billing_email_field {
        grid-column: 1 / -1;
    }

    /* 建立帳號區塊全寬 */
    .woocommerce-billing-fields__field-wrapper .yangsheep-create-account,
    .woocommerce-billing-fields__field-wrapper .create-account,
    #createaccount_field {
        grid-column: 1 / -1;
    }

    /* 收件人姓名電話強制並排 */
    #shipping_last_name_field,
    #shipping_first_name_field,
    #shipping_phone_field {
        grid-column: span 1 !important;
    }
}

/* 手機版：1 欄 */
@media (max-width: 767.9px) {

    .woocommerce-billing-fields__field-wrapper,
    .woocommerce-shipping-fields__field-wrapper {
        grid-template-columns: 1fr;
    }
}

/* 額外資訊欄位（訂單備註）*/
/* 注意：顯示/隱藏由 PHP template 的 inline style 控制，不要在這裡設定 display */
/* 當啟用「訂單備註開關」時，PHP 會加入 style="display:none;"，由 JS checkbox 控制顯示 */
.woocommerce-additional-fields__field-wrapper {
    /* display 由 PHP/JS 控制 */
}

.woocommerce-additional-fields__field-wrapper #order_comments_field {
    width: 100%;
}

/* ===== 收件人欄位佈局 ===== */
/* 公司欄位現在由 PHP Hook 移除，不再需要 CSS 隱藏
#shipping_company_field {
    display: none !important;
}
*/



/* 訂單備註 Checkbox 樣式已在上方統一定義 */

/* ===== 強制國家欄位顯示（避免被物流隱藏）===== */
#shipping_country_field {
    display: block !important;
    visibility: visible !important;
}

/* ===== 清理 form-row 預設寬度（讓 Grid 正常運作）===== */
.woocommerce-billing-fields__field-wrapper .form-row,
.woocommerce-shipping-fields__field-wrapper .form-row {
    width: auto !important;
    float: none !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
}

/* 確保 Grid 不被覆蓋 */
.woocommerce-billing-fields__field-wrapper,
.woocommerce-shipping-fields__field-wrapper {
    display: grid !important;
}

/* ===== 超取模式：隱藏地址欄位 ===== */
/* 透過 body class 控制，避免被 WooCommerce AJAX 覆蓋 */
body.yangsheep-cvs-mode #shipping_postcode_field,
body.yangsheep-cvs-mode #shipping_state_field,
body.yangsheep-cvs-mode #shipping_city_field,
body.yangsheep-cvs-mode #shipping_address_1_field,
body.yangsheep-cvs-mode #shipping_address_2_field,
body.yangsheep-cvs-mode #shipping-zipcode-fields {
    display: none !important;
}

/* ===== 超取模式：確保收件人欄位保持並排 ===== */
/* 當 Grid 只剩姓名和電話時，確保它們保持在同一行 */
body.yangsheep-cvs-mode .woocommerce-shipping-fields__field-wrapper {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px !important;
}

/* 超取時的姓名欄位 */
body.yangsheep-cvs-mode #shipping_first_name_field,
body.yangsheep-cvs-mode #shipping_last_name_field {
    grid-column: span 1 !important;
}

/* 超取時的電話欄位 */
body.yangsheep-cvs-mode #shipping_phone_field {
    grid-column: span 1 !important;
}

/* 超取時的超商資訊欄位 - 樣式已移至 class-yangsheep-third-party-shipping-compat.php */