/* ============================================================
   小蝦米 SHOP-ME - style.css
   橘色蝦皮風格 | 9:16 直式媒體 | 完整購物介面
   ============================================================ */

:root {
    --shopee:        #ee4d2d;
    --shopee-dark:   #c0392b;
    --shopee-light:  #fff4f2;
    --green:         #27ae60;
    --text-main:     #212121;
    --text-sub:      #757575;
    --bg-main:       #f5f5f5;
    --white:         #ffffff;
    --shadow-sm:     0 2px 8px rgba(0,0,0,0.08);
    --shadow-md:     0 4px 20px rgba(0,0,0,0.12);
    --radius:        10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans TC', -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   頂部導航
   ============================================================ */
.navbar-shopee {
    background: linear-gradient(135deg, #ee4d2d 0%, #c0392b 100%);
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    z-index: 999;
    box-shadow: 0 2px 16px rgba(238,77,45,0.35);
}
.nav-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}
.brand-icon { font-size: 1.4rem; }
.brand-text {
    font-size: 1.1rem;
    font-weight: 900;
    color: white;
    white-space: nowrap;
}
.brand-text em { font-style: normal; font-weight: 400; opacity: 0.85; }

/* 搜尋框 */
.nav-search { flex: 1; max-width: 480px; }
.search-form {
    display: flex;
    background: white;
    border-radius: 2px;
    overflow: hidden;
    height: 36px;
}
.search-form input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0 14px;
    font-size: 0.9rem;
    color: #333;
}
.search-form button {
    background: var(--shopee);
    border: none;
    color: white;
    padding: 0 16px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.search-form button:hover { background: var(--shopee-dark); }

/* 右側操作 */
.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    color: white;
    background: rgba(255,255,255,0.15);
    white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); color: white; }
.btn-seller { background: rgba(255,255,255,0.2); }
.btn-cart {
    position: relative;
    background: transparent;
    padding: 7px 10px;
}
.cart-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: #ffd200;
    color: #333;
    font-size: 0.65rem;
    font-weight: 900;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ============================================================
   跑馬燈
   ============================================================ */
.marquee-bar {
    background: #ffeee9;
    color: var(--shopee);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 6px 0;
    overflow: hidden;
    white-space: nowrap;
}
.marquee-bar span {
    display: inline-block;
    animation: marquee 25s linear infinite;
}
@keyframes marquee {
    from { transform: translateX(100vw); }
    to   { transform: translateX(-100%); }
}

/* ============================================================
   分類導航
   ============================================================ */
.category-bar {
    background: white;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 16px;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    text-decoration: none;
    color: #555;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    gap: 2px;
}
.cat-item:hover { color: var(--shopee); border-bottom-color: var(--shopee); }
.cat-item.active { color: var(--shopee); border-bottom-color: var(--shopee); font-weight: 700; }
.cat-icon { font-size: 1.3rem; }

/* ============================================================
   主佈局（左側欄 + 商品區）
   ============================================================ */
.main-container {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
    max-width: 1400px;
    margin: 16px auto;
    padding: 0 16px;
}
@media (max-width: 960px) {
    .main-container { grid-template-columns: 1fr; }
    .sidebar-banner { display: none !important; }
    .products-area { order: -1; }
}

/* ============================================================
   左側邊欄
   ============================================================ */
.sidebar-banner { display: flex; flex-direction: column; gap: 12px; }
.banner-box {
    background: linear-gradient(135deg, #ee4d2d, #c0392b);
    color: white;
    border-radius: var(--radius);
    padding: 16px;
}
.banner-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 12px; }
.countdown { display: flex; align-items: center; gap: 4px; }
.cd-block {
    background: rgba(0,0,0,0.25);
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
    min-width: 44px;
}
.cd-block span { font-size: 1.3rem; font-weight: 900; display: block; }
.cd-block small { font-size: 0.65rem; opacity: 0.8; }
.cd-sep { font-size: 1.2rem; font-weight: 700; opacity: 0.7; }

.ad-block {
    background: white;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}
.ad-title { font-size: 0.8rem; font-weight: 700; color: #555; margin-bottom: 8px; }
.ad-item { font-size: 0.82rem; padding: 4px 0; color: #444; display: flex; align-items: center; gap: 6px; }

/* ============================================================
   商品區標題
   ============================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--shopee);
}
.product-count { font-size: 0.82rem; color: #999; }

/* ============================================================
   商品格線
   ============================================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
@media (max-width: 1100px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }
@media (max-width: 420px)  { .products-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; } }

/* ============================================================
   商品卡片
   ============================================================ */
.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    opacity: 0;
    transform: translateY(16px);
    cursor: pointer;
}
.product-card.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.25s ease;
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

/* ============================================================
   ⭐ 9:16 媒體容器 - 核心設計
   ============================================================ */
.media-wrap {
    position: relative;
    width: 100%;
    /* 9:16 比例 = 높이 / 넓이 = 16/9 ≈ 177.78% */
    padding-top: 177.78%;
    background: #111;
    overflow: hidden;
}

/* 所有媒體元素都絕對定位填滿容器 */
.media-wrap .thumb-img,
.media-wrap .media-video,
.media-wrap .media-thumb,
.media-wrap .thumb-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumb {
    width: 100%;
    height: 100%;
}

.thumb-img {
    display: block;
    object-fit: cover;
    object-position: center top; /* 優先顯示上半部（臉/主體）*/
    transition: transform 0.4s ease;
}
.product-card:hover .thumb-img { transform: scale(1.04); }

.thumb-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f0f0f0;
    color: #bbb;
    font-size: 2rem;
}
.thumb-placeholder span { font-size: 0.75rem; }

.media-video {
    object-fit: contain;
    background: #000;
}

/* 播放覆蓋層 */
.play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.media-thumb:hover .play-overlay { background: rgba(0,0,0,0.1); }
.play-btn {
    width: 52px;
    height: 52px;
    background: rgba(255,255,255,0.92);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--shopee);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}
.media-thumb:hover .play-btn { transform: scale(1.1); }

/* 影片標籤 */
.badge-video {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(238,77,45,0.92);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 2;
}

/* 分類標籤 */
.badge-category {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 3px;
    z-index: 2;
}

/* 收藏按鈕 */
.btn-fav {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #bbb;
    cursor: pointer;
    z-index: 3;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.btn-fav:hover { transform: scale(1.15); color: var(--shopee); }
.btn-fav .fa-heart.text-danger { color: #e74c3c !important; }

/* ============================================================
   商品資訊區
   ============================================================ */
.product-info { padding: 10px 10px 12px; }

.product-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.product-desc {
    font-size: 0.78rem;
    color: var(--text-sub);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.price {
    font-size: 1rem;
    font-weight: 900;
    color: var(--shopee);
}
.sold-count { font-size: 0.72rem; color: #bbb; }

.btn-addcart {
    width: 100%;
    background: var(--shopee);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 7px 0;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.btn-addcart:hover {
    background: var(--shopee-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(238,77,45,0.3);
}
.btn-addcart:active { transform: translateY(0); }

/* ============================================================
   空狀態
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #bbb;
    grid-column: 1 / -1;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state h4 { color: #888; margin-bottom: 6px; }
.empty-state p { font-size: 0.88rem; }
.btn-primary-shopee {
    display: inline-block;
    margin-top: 16px;
    background: var(--shopee);
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 700;
}

/* ============================================================
   結帳區
   ============================================================ */
.checkout-bar {
    background: white;
    border-top: 3px solid var(--shopee);
    margin-top: 32px;
    padding: 20px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.checkout-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.checkout-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.checkout-label { font-size: 0.82rem; color: #999; white-space: nowrap; }
.checkout-val { font-size: 0.9rem; color: #333; }
.btn-copy {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-copy:hover { background: var(--shopee); color: white; border-color: var(--shopee); }
.btn-linepay {
    background: #06c755;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-linepay:hover { background: #04a847; transform: translateY(-1px); }

/* ============================================================
   購物車抽屜
   ============================================================ */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.cart-overlay.show { opacity: 1; pointer-events: all; }

.cart-drawer {
    position: fixed;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100vh;
    background: white;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: -4px 0 30px rgba(0,0,0,0.15);
}
.cart-drawer.open { right: 0; }
@media (max-width: 420px) { .cart-drawer { width: 100vw; } }

.cart-header {
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--shopee-light);
}
.cart-header h5 { margin: 0; font-weight: 700; color: var(--shopee); }
.btn-close-cart {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
}
.btn-close-cart:hover { color: var(--shopee); }

.cart-body { flex: 1; overflow-y: auto; padding: 16px; }
.cart-empty { text-align: center; padding: 60px 20px; color: #ccc; }
.cart-empty i { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.cart-empty p { font-size: 0.88rem; }

.cart-item {
    border-bottom: 1px solid #f5f5f5;
    padding: 12px 0;
}
.cart-item-name { font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.cart-item-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}
.cart-item-ctrl button {
    width: 26px;
    height: 26px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.cart-item-ctrl button:hover { border-color: var(--shopee); color: var(--shopee); }
.cart-item-price { font-weight: 700; color: var(--shopee); margin-left: auto; }
.btn-remove { background: none; border: none; cursor: pointer; color: #ccc; font-size: 0.8rem; }
.btn-remove:hover { color: #e74c3c; }

.cart-footer {
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    background: white;
}
.cart-total { font-size: 1rem; text-align: right; margin-bottom: 12px; }
.cart-total strong { font-size: 1.3rem; color: var(--shopee); }
.btn-checkout {
    width: 100%;
    background: var(--shopee);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 13px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-checkout:hover { background: var(--shopee-dark); }

/* ============================================================
   Toast 通知
   ============================================================ */
.toast-msg {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.82);
    color: white;
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}
.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   回頂部按鈕
   ============================================================ */
.btn-totop {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--shopee);
    color: white;
    border: none;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(238,77,45,0.4);
    z-index: 500;
    transition: all 0.2s;
}
.btn-totop:hover { background: var(--shopee-dark); transform: translateY(-2px); }

/* ============================================================
   手機版響應式 (max-width: 480px) - 不影響電腦版
   ============================================================ */
@media (max-width: 480px) {
    /* 隱藏搜尋框（手機版空間不夠） */
    .nav-search { display: none !important; }
    
    /* 導覽列緊湊 */
    .navbar-shopee { padding: 0 10px; }
    .nav-inner { gap: 8px; }
    .brand-text { font-size: 0.95rem; }
    
    /* 防止橫向滾動 */
    body { overflow-x: hidden; }
    .main-container { overflow-x: hidden; }
    
    /* 聊聊視窗全寬 */
    .chat-window-box {
        width: calc(100vw - 16px) !important;
        height: 72vh !important;
        right: 8px !important;
        left: 8px !important;
        bottom: 88px !important;
    }
    
    /* 聊聊按鈕位置 */
    #chatFab {
        bottom: 20px !important;
        right: 16px !important;
    }
}

@media (max-width: 960px) {
    .nav-actions { display: flex !important; gap: 8px; }
    .nav-actions .cart-btn { display: flex !important; }
}
