/* =========================================================================
   1. HEADER 基礎區域樣式
   ========================================================================= */
header {
    background-color: transparent;
    z-index: 100;
    position: relative;
}

.header-main-row {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 26px;
    font-weight: 700;
    color: #1d1d1f;
    text-decoration: none;
    letter-spacing: 1.5px;
    transition: color 0.4s ease; 
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    padding: 8px 12px 8px 35px;
    border-radius: 20px;
    border: 1px solid #e5e5e7;
    background-color: #f5f5f7;
    color: #333333;
    outline: none;
    font-size: 14px;
    transition: all 0.4s ease;
    width: 160px;
}

.search-box input:focus {
    width: 220px;
    border-color: #0071e3 !important;
    background-color: #ffffff !important;
    color: #333333 !important;
    box-shadow: 0 0 8px rgba(0, 113, 227, 0.15);
}

.search-box i {
    position: absolute;
    left: 12px;
    color: #86868b;
    transition: color 0.4s ease;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #1d1d1f;
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    text-decoration: none;
}

.icon-btn i {
    display: inline-block;
    position: relative;
    z-index: 2;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), color 0.4s ease;
}

.icon-btn .badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background-color: #ff3b30;
    color: white;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    z-index: 3;
}

.icon-btn.is-active-cart,
.icon-btn.is-active-member {
    color: #0071e3 !important;
}


/* =========================================================================
   2. 導覽列與選單 (NAV & DROPDOWN)
   ========================================================================= */
.header-nav-row { padding: 12px 0; }
nav { display: flex; justify-content: center; gap: 20px; align-items: center; flex-wrap: wrap; }

.nav-item-wrapper {
    position: relative;
    display: inline-block;
}

.nav-cat-btn { 
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    color: #515154; 
    font-weight: 500; 
    font-size: 15px; 
    padding: 6px 14px; 
    border-radius: 12px;
    display: inline-flex; 
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    text-decoration: none;
    font-family: inherit;
}

.nav-cat-btn:hover { 
    color: #0071e3; 
    background-color: transparent;
}

.nav-cat-btn .arrow-icon {
    font-size: 11px;
    color: #86868b;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), color 0.3s ease;
}

.nav-item-wrapper.active .nav-cat-btn {
    color: #0071e3;
    background-color: transparent;
}

.nav-item-wrapper.active .arrow-icon {
    transform: rotate(180deg);
    color: #0071e3;
}

.nav-dropdown-card {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(234, 234, 234, 0.9);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 8px;
    min-width: 170px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.nav-dropdown-card.active {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.nav-main-all-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 10px;
    color: #0071e3;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid #f5f5f7;
    margin-bottom: 4px;
    transition: background-color 0.2s ease;
}

.nav-main-all-link:hover {
    background-color: #eef4fc;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 10px;
    color: #1d1d1f;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-sub-item:hover {
    background-color: #f5f5f7;
    color: #0071e3;
    font-weight: 500;
}

.nav-cat-btn span,
.nav-main-all-link span,
.nav-sub-item span {
    display: inline-block;
    position: relative;
    z-index: 2;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), color 0.4s ease;
}

@media (hover: hover) {
    .icon-btn:hover i { color: #0071e3 !important; transform: scale(0.88) translateY(2px); }
    .nav-cat-btn:hover span,
    .nav-main-all-link:hover span,
    .nav-sub-item:hover span { color: #0071e3 !important; transform: scale(0.88) translateY(2px) !important; }
}

.icon-btn:active, .icon-btn.watermark-active { color: #0071e3 !important; }
.icon-btn:active i, .icon-btn.watermark-active i,
.nav-cat-btn:active span, .nav-cat-btn.watermark-active span,
.nav-main-all-link:active span, .nav-main-all-link.watermark-active span,
.nav-sub-item:active span, .nav-sub-item.watermark-active span {
    color: #0071e3 !important;
    transform: scale(0.88) translateY(2px) !important;
}


/* =========================================================================
   3. 會員下拉選單 (MEMBER DROPDOWN CARD)
   ========================================================================= */
.user-wrapper, .cart-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-card {
    position: absolute;
    top: 115%;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(234, 234, 234, 0.9);
    border-radius: 18px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 12px 14px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-sizing: border-box;
}

.dropdown-card.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.user-dropdown { 
    width: 320px; 
}

/* 未登入狀態 */
.user-unlogged-box { text-align: center; padding: 10px 0; }
.user-unlogged-title { font-size: 15px; font-weight: 700; color: #1d1d1f; margin-bottom: 4px; }
.user-unlogged-desc { font-size: 13px; color: #86868b; margin-bottom: 18px; }

.btn-user-login {
    display: block; width: 100%; padding: 10px; background-color: #0071e3; color: #ffffff;
    border-radius: 10px; text-align: center; text-decoration: none; font-size: 14px; font-weight: 500;
    margin-bottom: 8px; transition: background-color 0.2s;
}
.btn-user-login:hover { background-color: #005bb5; }

.btn-user-register {
    display: block; width: 100%; padding: 10px; background-color: #f5f5f7; color: #1d1d1f;
    border: 1px solid #d2d2d7; border-radius: 10px; text-align: center; text-decoration: none;
    font-size: 14px; font-weight: 500; transition: background-color 0.2s;
}
.btn-user-register:hover { background-color: #e5e5ea; }

/* 1. 已登入 Header */
.user-profile-header {
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 8px;
    padding-bottom: 10px; 
    border-bottom: 1px solid #f5f5f7;
}

/* 左側：大頭貼欄位 */
.user-avatar-col { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    width: 68px;
    flex-shrink: 0; 
    text-align: center;
}

.user-avatar-box {
    width: 44px; 
    height: 44px; 
    border-radius: 50%; 
    background-color: #0071e3;
    color: #ffffff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 18px;
    overflow: hidden;
    margin: 0 auto;
}

.user-avatar-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upgrade-threshold-text { 
    font-size: 9px; 
    color: #0071e3; 
    font-weight: 700;
    margin-top: 4px; 
    white-space: nowrap; 
    text-align: center;
    width: 100%;
}

/* 中間：暱稱與等級 */
.user-info-middle { 
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    min-width: 0; 
    flex: 1; 
}

/* 修正：允許暱稱列水平並排顯示等級圖示，避免被裁切 */
.user-nickname-text { 
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px; 
    font-weight: 700; 
    color: #1d1d1f; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

/* 等級標籤 */
.user-level-tag {
    display: inline-flex; 
    align-items: center; 
    gap: 4px; 
    font-size: 11px; 
    font-weight: 700;
    color: #d97706; 
    background-color: #fef3c7; 
    padding: 3px 8px; 
    border-radius: 6px; 
    white-space: nowrap;
    width: fit-content;
    max-width: 100%;
}

/* 修正：同時涵蓋 .user-level-icon 與 .level-custom-icon (支援 <img> 與 <i>) */
img.user-level-icon,
img.level-custom-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
    flex-shrink: 0;
    display: inline-block;
}

i.user-level-icon,
i.level-custom-icon {
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-perks-box {
    background-color: #f8fafc; 
    border: 1px solid #e2e8f0; 
    border-radius: 8px; 
    padding: 4px 6px; 
    text-align: right; 
    flex-shrink: 0; 
    max-width: 105px;
}
.user-perks-title { font-size: 9px; color: #64748b; font-weight: 600; display: block; }
.user-perks-desc { font-size: 10px; font-weight: 700; color: #0071e3; line-height: 1.2; text-decoration: none; display: block; }


/* 2. 資產與任務齊頭對齊 */
.user-stats-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f7;
}

.user-stat-row {
    display: flex;
    align-items: center;
    font-size: 12px;
}

.stat-label {
    width: 44px; 
    flex-shrink: 0;
    color: #6e6e73;
    font-weight: 600;
    text-align: left;
}

.stat-tags-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.stat-badge {
    color: #1d1d1f;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}


/* 3. 訂單狀態區塊 */
.user-order-status-box { 
    padding: 10px 0; 
    border-bottom: 1px solid #f5f5f7; 
}

.order-status-header { 
    font-size: 13px; 
    font-weight: 700; 
    color: #1d1d1f; 
    margin-bottom: 8px; 
}

.order-status-grid { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 6px; 
}

.order-status-item { 
    font-size: 12px; 
    color: #333336; 
    text-decoration: none; 
    padding: 6px 4px; 
    border-radius: 8px; 
    background-color: #f5f5f7;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.order-status-item:hover { 
    background-color: #eef4fc; 
    color: #0071e3; 
}


/* 4. 底部三個按鈕風格統一 (會員中心主頁、商品追蹤清單、登出帳號) */
.user-actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

/* 基礎通用按鈕 (全水平居中對齊) */
.user-btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.user-btn-action i {
    font-size: 14px;
    transition: color 0.2s ease;
}

/* 藍色品牌按鈕 (會員中心主頁、商品追蹤清單) */
.user-btn-action.btn-blue-primary {
    background-color: #f4f8ff;
    border: 1px solid #0071e3;
    color: #0071e3;
}

.user-btn-action.btn-blue-primary:hover {
    background-color: #0071e3;
    border-color: #0071e3;
    color: #ffffff;
}

/* 登出帳號按鈕專屬風格 */
.user-btn-action.btn-logout-danger {
    background-color: #fff5f5;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.user-btn-action.btn-logout-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}


/* =========================================================================
   5. 追蹤清單抽屜選單 (WISHLIST SIDE DRAWER)
   ========================================================================= */
.wishlist-drawer-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); z-index: 9998;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.wishlist-drawer-overlay.active { opacity: 1; visibility: visible; }

.wishlist-drawer {
    position: fixed; top: 0; right: -380px; width: 360px; height: 100vh;
    background: #ffffff; z-index: 9999; box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.wishlist-drawer.active { right: 0; }

.wishlist-drawer-header {
    display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #f5f5f7;
}
.drawer-title { font-size: 15px; font-weight: 700; color: #1d1d1f; }
.drawer-close-btn { background: none; border: none; font-size: 20px; color: #86868b; cursor: pointer; }

.wishlist-drawer-body { flex: 1; overflow-y: auto; padding: 15px 20px; display: flex; flex-direction: column; gap: 12px; }
.drawer-loading-text, .drawer-empty-text { text-align: center; color: #86868b; font-size: 13px; margin-top: 30px; }

.wishlist-drawer-item { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid #f8f8f8; }
.wishlist-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #f5f5f7; flex-shrink: 0; }
.wishlist-item-info { flex: 1; min-width: 0; }
.wishlist-item-title { font-size: 12px; font-weight: 600; color: #1d1d1f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wishlist-item-price { font-size: 12px; font-weight: 700; color: #0071e3; margin-top: 2px; }

.wishlist-actions { display: flex; align-items: center; gap: 6px; }
.btn-drawer-add-cart {
    background: #0071e3; color: #ffffff; border: none; padding: 5px 8px; border-radius: 6px; font-size: 11px; cursor: pointer;
}
.btn-drawer-remove { background: none; border: none; color: #86868b; font-size: 13px; cursor: pointer; padding: 4px; }
.btn-drawer-remove:hover { color: #ff3b30; }

.wishlist-drawer-footer { padding: 15px 20px; border-top: 1px solid #f5f5f7; }
.btn-full-wishlist {
    display: block; width: 100%; padding: 11px; background: #f5f5f7; color: #1d1d1f; text-align: center;
    border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 600;
}
.btn-full-wishlist:hover { background: #e5e5ea; }