/* ═══════════════════════════════════════════════
   BANNER — 任意解析度不失真填滿
   ═══════════════════════════════════════════════

   關鍵原理：
     容器設固定高度（控制 banner 占版面比例）
     img 用 object-fit:cover 填滿容器，超出部分裁切，不壓縮不失真
     !important 覆蓋全局 img { height: auto } 避免衝突

   圖片建議：寬度 ≥ 1920px，不需要換圖，自動適配所有解析度
   ═══════════════════════════════════════════════ */

/* —— Banner：寬度撐滿、高度 auto 等比例、不失真 —— */
#swiper-banner {
    width: 100%;
    overflow: hidden;
}

/* Swiper autoHeight 模式下 slide 需要 height:auto */
#swiper-banner .swiper-slide {
    width: 100%;
    height: auto !important;
}

#swiper-banner .swiper-slide a {
    display: block;
    line-height: 0; /* 消除 img inline 底部空白 */
}

/* 寬度 100% 撐滿，高度 auto 等比例，絕不失真
   !important 覆蓋全局 img { max-width:100%; height:auto } */
#swiper-banner .swiper-slide img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: none !important; /* 允許圖片超過容器自然寬度，隨 viewport 放大 */
}

/* 分頁小點 */
#swiper-banner .swiper-pagination {
    bottom: 12px;
}

/*
 * RWD 響應式優化補丁
 * 補強 Bootstrap 3 + style.css 在平板/手機上的不足
 * 不覆蓋原有樣式，只追加缺少的 RWD 規則
 *
 * 斷點：
 *   手機    xs  < 768px
 *   平板    sm  768px ~ 991px
 *   桌機    md  992px ~ 1199px
 *   大桌機  lg  >= 1200px
 */

/* ═══════════════════════════════════════════════
   1. 全站基礎
   ═══════════════════════════════════════════════ */

/* 防止橫向捲動 */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* 觸控友善：所有可點擊元素最小高度 44px */
@media (max-width: 991px) {
    a, button, .btn,
    .reduc, .add,
    .addcart, .shoucang, .goodnotice {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* 保持 inline 元素正常排列 */
    a.text-link {
        display: inline;
        min-height: unset;
        min-width: unset;
    }
}

/* 字體稍大，手機閱讀更舒適 */
@media (max-width: 767px) {
    body {
        font-size: 15px;
    }
    h3, h4, h5 {
        word-break: break-word;
    }
}

/* ═══════════════════════════════════════════════
   2. 導覽列 / Header
   ═══════════════════════════════════════════════ */

/* 平板：PC header 改為較緊湊佈局 */
@media (min-width: 768px) and (max-width: 991px) {
    .pc-header .container {
        padding: 8px 15px;
    }
    /* logo 縮小 */
    .head-left.logo img {
        max-height: 40px;
        width: auto;
    }
    /* 搜尋列縮窄 */
    .head-center.search {
        padding: 0 10px;
    }
    .head-center .search-hot {
        display: none; /* 平板隱藏熱門搜尋 */
    }
    /* 登入區靠右縮緊 */
    .head-right {
        padding-top: 5px;
    }
}

/* 手機：logo 強制顯示、整齊排列 */
@media (max-width: 767px) {
    .mobile-head .container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 15px;
    }
    .mobile-headright {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .mobile-headright .mobile-login,
    .mobile-headright .mobile-search,
    .mobile-headright .mobile-cart {
        margin-right: 0;
        top: 0;
    }
}

/* ═══════════════════════════════════════════════
   3. 搜尋列
   ═══════════════════════════════════════════════ */

/* 手機彈出搜尋框全寬 */
@media (max-width: 767px) {
    #search-modal .modal-dialog {
        margin: 10px;
    }
    #search-modal .form-control {
        font-size: 16px; /* 防 iOS 自動縮放 */
        height: 44px;
    }
}

/* 平板：桌面搜尋欄排版修正 */
@media (min-width: 768px) and (max-width: 991px) {
    .head-center .input-group .form-control {
        height: 40px;
    }
}

/* ═══════════════════════════════════════════════
   4. 商品列表 (product table)
   ═══════════════════════════════════════════════ */

/* 平板：表格允許橫向捲動，不強迫縮到螢幕內 */
@media (min-width: 768px) and (max-width: 991px) {
    .mt-product-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mt-product-table table {
        min-width: 780px;
    }
    /* 品名欄位限制寬度避免太寬 */
    .setwidth {
        min-width: 160px;
        max-width: 220px;
    }
}

/* 商品數量加減按鈕觸控優化 */
@media (max-width: 991px) {
    .product-number .total-num {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .product-number .reduc,
    .product-number .add {
        width: 36px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        background: #f0f0f0;
        border-radius: 4px;
        cursor: pointer;
        font-size: 18px;
        font-weight: bold;
        user-select: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        min-height: 36px;
    }
    .product-number .product-num {
        width: 50px;
        text-align: center;
        border: 1px solid #ddd;
        border-radius: 4px;
        height: 36px;
        font-size: 15px;
    }
}

/* 手機：商品列表操作按鈕更大 */
@media (max-width: 767px) {
    .addcart, .shoucang, .goodnotice {
        padding: 8px 10px;
    }
    /* 缺貨商品半透明效果在手機也生效 */
    .nogoods {
        opacity: 0.4;
    }
}

/* ═══════════════════════════════════════════════
   5. 購物車 (cart)
   ═══════════════════════════════════════════════ */

/* 平板：表格允許橫向捲動 */
@media (min-width: 768px) and (max-width: 991px) {
    .mt-product-table.hidden-xs {
        display: block !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mt-product-table table {
        min-width: 700px;
    }
}

/* 購物車結帳區塊 */
@media (max-width: 767px) {
    .payment-total {
        padding: 15px;
    }
    .payment-total .total-money {
        font-size: 20px;
    }
}

/* ═══════════════════════════════════════════════
   6. 結帳頁面 (pay / checkout)
   ═══════════════════════════════════════════════ */

@media (max-width: 767px) {
    /* 收件地址欄位堆疊 */
    .pay-address .col-xs-6 {
        width: 100%;
        padding-bottom: 8px;
    }
    /* 付款方式按鈕全寬 */
    .pay-type-item {
        width: 100%;
        margin-bottom: 8px;
    }
    /* 結帳按鈕全寬 */
    .btn-submit-order,
    .pay-submit .btn {
        width: 100%;
        height: 50px;
        font-size: 18px;
        border-radius: 6px;
    }
    /* 輸入框高度增加 */
    .pay-form input[type="text"],
    .pay-form select,
    .pay-form textarea {
        height: 44px;
        font-size: 15px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    /* 平板：付款方式可以兩欄排列 */
    .pay-type-item {
        width: 48%;
        display: inline-block;
        margin-right: 2%;
    }
}

/* ═══════════════════════════════════════════════
   7. 會員中心 (user center)
   ═══════════════════════════════════════════════ */

/* 平板：側欄縮窄，右側欄位完整顯示 */
@media (min-width: 768px) and (max-width: 991px) {
    .usercenter-left {
        font-size: 13px;
    }
    .usercenter-left li {
        font-size: 13px;
    }
    .usercenter-right {
        padding: 20px 10px;
    }
}

/* 手機：側欄改為橫向捲動 tab 列 */
@media (max-width: 767px) {
    /* 整體佈局取消 padding */
    .usercenter .container {
        padding: 0 10px;
    }
    /* 左側欄改為水平捲動導覽列 */
    .usercenter-left {
        border-radius: 0;
        border: none;
        border-bottom: 2px solid #015198;
        padding: 0;
        margin-bottom: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .usercenter-left h4 {
        display: none; /* 手機隱藏大頭照/名稱區 */
    }
    .usercenter-left ul {
        display: inline-flex;
        flex-wrap: nowrap;
        padding: 0 5px;
    }
    .usercenter-left li {
        display: inline-block;
        height: 42px;
        line-height: 42px;
        margin: 0;
        padding: 0 12px;
        white-space: nowrap;
        border-bottom: none;
    }
    .usercenter-left li.active {
        border-bottom: 3px solid #015198;
    }
    .usercenter-left li a {
        padding: 0;
        font-size: 14px;
    }
    /* 右側內容全寬 */
    .usercenter-right {
        padding: 15px 0;
    }
    /* 訂單列表在手機上橫向捲動 */
    .user-order-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ═══════════════════════════════════════════════
   8. 麵包屑 / Breadcrumb
   ═══════════════════════════════════════════════ */

@media (max-width: 767px) {
    .crumbs {
        padding: 10px 15px;
    }
    .crumbs h3 {
        font-size: 18px;
        margin-bottom: 4px;
    }
    .crumbs p {
        font-size: 13px;
        margin: 0;
    }
}

/* ═══════════════════════════════════════════════
   9. 表單元素 (全站)
   ═══════════════════════════════════════════════ */

/* 防止 iOS Safari 自動縮放：輸入框 font-size >= 16px */
@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }
    /* 按鈕更容易點選 */
    .btn {
        padding: 10px 16px;
        font-size: 15px;
    }
    .btn-sm {
        padding: 7px 12px;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════
   10. 下拉選單 (dropdown)
   ═══════════════════════════════════════════════ */

/* 手機：dropdown 更大、更好點 */
@media (max-width: 767px) {
    .dropdown-menu {
        min-width: 160px;
        font-size: 15px;
    }
    .dropdown-menu > li > a {
        padding: 10px 16px;
        line-height: 1.5;
    }
    /* 會員 dropdown 靠右 */
    .pession-group .dropdown-menu {
        left: auto;
        right: 0;
    }
}

/* 平板：dropdown 不超出螢幕邊緣 */
@media (min-width: 768px) and (max-width: 991px) {
    .submenu, .submenu-about {
        max-width: calc(100vw - 30px);
    }
}

/* ═══════════════════════════════════════════════
   11. 登入/註冊頁
   ═══════════════════════════════════════════════ */

@media (max-width: 767px) {
    .login-form,
    .register-form {
        padding: 15px;
    }
    .login-form .form-group,
    .register-form .form-group {
        margin-bottom: 12px;
    }
    .login-form .btn,
    .register-form .btn {
        width: 100%;
        height: 48px;
        font-size: 16px;
    }
}

/* ═══════════════════════════════════════════════
   12. Footer
   ═══════════════════════════════════════════════ */

@media (max-width: 767px) {
    footer {
        padding-top: 20px;
    }
    footer .col-xs-12 {
        margin-bottom: 20px;
    }
    footer h4 {
        font-size: 15px;
    }
    footer .copyright {
        font-size: 12px;
        height: auto;
        padding: 12px 15px;
        line-height: 1.6;
    }
}

/* ═══════════════════════════════════════════════
   13. 表格通用 (所有帶 table-container 的表格)
   ═══════════════════════════════════════════════ */

/* 確保平板以下所有 .table-container 都可橫向捲動 */
@media (max-width: 991px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* 表格內字體稍小，擠進更多欄位 */
    .table-container table {
        font-size: 13px;
    }
    .table-container th,
    .table-container td {
        white-space: nowrap;
        padding: 6px 8px !important;
    }
}

/* ═══════════════════════════════════════════════
   14. AJAX 搜尋建議下拉（預留 class）
   ═══════════════════════════════════════════════ */

.search-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 9999;
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

.search-autocomplete.show {
    display: block;
}

.search-autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-autocomplete-item:hover,
.search-autocomplete-item.active {
    background: #f0f9f8;
}

.search-autocomplete-item .ac-name {
    color: #333;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-autocomplete-item .ac-code {
    color: #999;
    font-size: 12px;
    flex-shrink: 0;
}

.search-autocomplete-item .ac-highlight {
    color: #14a58c;
    font-weight: bold;
}

.search-input-wrap {
    position: relative;
}
