/**
 * 順豐快遞購物車樣式
 */

/* 全局覆蓋WooCommerce默認圖片樣式 */
.woocommerce .sf-express-cart-container img,
.woocommerce-page .sf-express-cart-container img {
    max-width: none;
    height: auto;
}

/* 購物車容器 */
.sf-express-cart-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* 購物車標題 */
.sf-express-cart-title {
    font-size: 24px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* 產品信息區域 */
.sf-express-cart-products {
    margin-bottom: 30px;
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 購物車表頭 */
.sf-express-cart-header {
    display: flex;
    background-color: #f8f8f8;
    padding: 12px 10px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
}

/* 購物車列 */
.sf-express-cart-column {
    padding: 8px;
}

.product-name {
    flex: 3;
}

.product-variation,
.product-quantity {
    flex: 1;
    text-align: center;
}

.product-price,
.product-subtotal,
.product-remove {
    flex: 1;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* 購物車項目 */
.sf-express-cart-item {
    display: flex;
    padding: 15px 10px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.sf-express-cart-item:last-child {
    border-bottom: none;
}

/* 產品名稱和圖片 */
.sf-express-cart-column.product-name {
    display: flex;
    align-items: center;
}

.product-image {
    margin-right: 15px;
    flex-shrink: 0;
}

/* 覆蓋WooCommerce默認圖片樣式 */
.woocommerce .sf-express-cart-item .product-image img,
.woocommerce-page .sf-express-cart-item .product-image img,
.sf-express-cart-item .product-image img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #eee;
    max-width: none;
}

.product-info {
    flex: 1;
}

.sf-express-quantity-control {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    margin: 0 auto !important;
}

.sf-express-cart-item .sf-express-qty-btn {
    width: 30px !important;
    height: 30px !important;
    background-color: #f7f7f7 !important;
    border: 1px solid #ddd !important;
    cursor: pointer !important;
    font-size: 16px !important;
    line-height: 1 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    vertical-align: middle !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.sf-express-cart-item .sf-express-qty-btn:hover {
    background-color: #e7e7e7 !important;
}

.sf-express-cart-item .sf-express-qty-btn.minus {
    border-radius: 3px 0 0 3px !important;
    border-right: none !important;
}

.sf-express-cart-item .sf-express-qty-btn.plus {
    border-radius: 0 3px 3px 0 !important;
    border-left: none !important;
}

.sf-express-cart-item .sf-express-qty-input {
    width: 50px !important;
    height: 40px !important;
    text-align: center !important;
    border: 1px solid #ddd !important;
    border-left: none !important;
    border-right: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
    appearance: none !important;
    display: inline-block !important;
    vertical-align: middle !important;
    min-height: 36px !important;
    font-size: 14px !important;
    background-color: #fff !important;
    box-shadow: none !important;
    float: none !important;
}

/* 更新購物車按鈕 */
.sf-express-cart-actions-top {
    text-align: right;
    margin: 15px 0;
}

.update-cart {
    background-color: #f7f7f7;
    border: 1px solid #ccc;
    padding: 8px 15px;
    border-radius: 3px;
    cursor: pointer;
}

.update-cart:hover {
    background-color: #e7e7e7;
}

/* 購物車底部區域 */
.sf-express-cart-footer {
    display: flex;
    flex-wrap: wrap;
    margin-top: 20px;
    gap: 20px;
}

/* 運送方式區域 (60%) */
.sf-express-cart-shipping {
    flex: 6;
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sf-express-cart-shipping h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

/* 國家選擇器 */
.sf-express-shipping-country-selector {
    margin: 15px 0;
}

.sf-express-shipping-country-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.sf-express-shipping-country-selector select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: #fff;
    font-size: 14px;
}

/* 運送方式選項 */
.sf-express-shipping-options {
    margin-top: 15px;
}

.sf-express-shipping-option {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sf-express-shipping-option:hover {
    background-color: #f9f9f9;
}

.sf-express-shipping-option input {
    margin-right: 10px;
}

/* 訂單信息區域 (40%) */
.sf-express-cart-totals {
    flex: 4;
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sf-express-cart-totals h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.sf-express-cart-totals table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.sf-express-cart-totals th,
.sf-express-cart-totals td {
    padding: 10px 5px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

.sf-express-cart-totals td {
    text-align: right;
}

.sf-express-cart-totals .order-total {
    font-weight: bold;
    font-size: 1.1em;
}

.sf-express-cart-totals .order-total th,
.sf-express-cart-totals .order-total td {
    padding-top: 15px;
    border-top: 2px solid #eee;
}

/* 下一步按鈕 */
.sf-express-cart-actions {
    margin-top: 20px;
    text-align: right;
}

.checkout-button {
    background-color: #0073aa;
    color: #fff;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.checkout-button:hover {
    background-color: #005f8b;
}

/* 桌面版和移動版顯示控制 */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

/* 響應式設計 */
@media (max-width: 768px) {
    /* 手機版容器調整 - 去掉大部分padding，只保留左右5px */
    .sf-express-cart-container {
        padding: 15px 5px;
        margin: 0;
    }

    .sf-express-cart-footer {
        flex-direction: column;
    }

    .sf-express-cart-shipping,
    .sf-express-cart-totals {
        flex: 1 1 100%;
    }

    /* 產品信息區域手機版優化 */
    .sf-express-cart-products {
        margin: 0 5px 20px 5px;
    }

    /* 運送和總計區域手機版優化 */
    .sf-express-cart-shipping,
    .sf-express-cart-totals {
        margin: 0 5px;
        padding: 15px;
    }

    .sf-express-cart-header {
        display: none;
    }

    .sf-express-cart-item {
        flex-wrap: wrap;
        position: relative;
        padding-bottom: 20px;
    }

    .sf-express-cart-column {
        flex: 1 1 50%;
        text-align: left;
        padding: 5px 10px;
    }

    .product-name {
        flex: 1 1 100%;
        font-weight: bold;
    }

    /* 隱藏移動版的小計 */
    .product-subtotal {
        display: none;
    }

    .product-quantity {
        order: 3;
        flex: 1 1 100%;
        margin-top: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .sf-express-quantity-control {
        display: flex !important;
        justify-content: flex-start !important;
        margin-left: 0 !important;
    }

    /* 移動版刪除按鈕容器 */
    .product-remove {
        display: none; /* 隱藏桌面版的刪除按鈕 */
    }

    /* 在手機版中將刪除按鈕加到數量控制列 */
    .sf-express-cart-item .remove-product-btn {
        display: none;
    }

    /* 手機版刪除按鈕 - 只在手機版顯示 */
    .mobile-only {
        display: inline-block !important;
    }

    .sf-express-cart-item .mobile-delete-btn {
        margin-left: 10px;
        color: #e74c3c;
        font-weight: bold;
        font-size: 10px;
        cursor: pointer;
        transition: color 0.3s ease;
        background-color: transparent;
        border: 1px solid #e74c3c;
        border-radius: 3px;
        padding: 5px 10px;
        text-align: center;
    }

    .product-price {
        order: 4;
        display: none; /* 隱藏桌面版價格，使用移動版單價 */
    }

    /* 移動版顯示控制 */
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    /* 移動版產品信息佈局 */
    .product-info {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .product-color {
        font-size: 0.9em;
        color: #666;
    }

    .product-size {
        font-size: 0.9em;
        color: #666;
        margin-top: 3px;
    }

    /* 規格信息和單價在同一行的樣式 */
    .product-variation-price-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 5px;
    }

    .product-variation-info {
        font-size: 0.9em;
        color: #666;
    }

    .variation-text {
        flex: 1;
    }

    .product-unit-price {
        font-size: 0.95em;
        font-weight: bold;
        color: #333;
        text-align: right;
        margin-left: 10px;
    }
}

/* 隱藏WooCommerce原生元素 */
.woocommerce-shipping-calculator,
.woocommerce-shipping-destination {
    display: none;
}

/* 確保運送方式顯示 */
.woocommerce-shipping-totals.shipping,
.woocommerce-checkout-review-order-table .shipping {
    display: block !important;
}

/* 隱藏多餘的sf-express-shipping-options元素，但保留運送方式顯示 */
.sf-express-shipping-options {
    display: none;
}

/* 加載中動畫 */
.sf-express-loading {
    position: relative;
    opacity: 0.5;
    pointer-events: none;
}

.sf-express-loading:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: sf-express-spin 0.8s linear infinite;
}

@keyframes sf-express-spin {
    to { transform: rotate(360deg); }
}


/* 產品刪除按鈕樣式 */
.remove-product-btn {
    display: inline-block;
    color: #e74c3c;
    font-weight: bold;
    font-size: 10px;
    cursor: pointer;
    transition: color 0.3s ease;
    background-color: transparent;
    border: 1px solid #e74c3c;
    border-radius: 3px;
    padding: 5px 10px;
    text-align: center;
}

.remove-product-btn:hover {
    color: #fff;
    background-color: #e74c3c;
}

/* 移動版刪除按鈕 */
.mobile-remove-btn {
    display: none;
    color: #e74c3c;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.3s ease;
    background-color: transparent;
    border: 1px solid #e74c3c;
    border-radius: 3px;
    padding: 5px 10px;
    text-align: center;
    margin-left: 10px;
}

.mobile-remove-btn:hover {
    color: #fff;
    background-color: #e74c3c;
}