/**
 * //JW 2026/01/13 V4 SKM WWW 會員登入功能樣式
 * - header 人頭按鈕的 dropdown 選單
 * - 網頁版：已登入時顯示會員等級+名稱
 * - 手機版：dropdown 內顯示名稱
 */

/* ==================== Dropdown 容器 ==================== */
.v4-member-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

/* ==================== 觸發按鈕 ==================== */
.v4-member-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.v4-member-trigger:hover {
    opacity: 0.8;
}

/* ==================== V4 Header 人頭 icon 登入紅點 ==================== */
/* //JW 2026/01/16 需求：登入後人頭 icon 右下角要有小紅點提示；登出後消失 */
.v4-member-icon {
    position: relative;
    display: inline-block;
    line-height: 0;
}
.v4-member-icon--dot::after {
    content: "";
    position: absolute;
    /* //JW 2026/01/16 依截圖需求：紅點要壓在人像身體上（往左上靠），並稍微大一點 */
    width: 10px;
    height: 10px;
    right: 6px;
    bottom: 6px;
    transform: none;
    border-radius: 50%;
    background: #d0343d;
    border: 2px solid #fff;
    /* //JW 2026/01/16 白邊外不需要灰色細線 */
    box-shadow: none;
    pointer-events: none;
}

/* ==================== 會員等級+名稱（網頁版） ==================== */
.v4-member-level-name {
    font-size: 14px;
    line-height: 1.4;
    white-space: nowrap;
}

.v4-member-level {
    font-weight: 600;
}

.v4-member-level.red-color {
    color: #d0343d !important;
}

.v4-member-level-point-desc.red-color {
    color: #d0343d !important;
    font-weight: bold;
}

.v4-member-name {
    margin-left: 5px;
    color: #212121;
}

/* 會員等級樣式 */
.v4-level-normal {
    color: #d0343d;
}

.v4-level-silver {
    color: #888;
}

.v4-level-gold {
    color: #B8860B;
}

/* ==================== Dropdown 選單 ==================== */
/* //JW 2026/01/13 使用高特異性確保不被父容器 .menu-right 的 flex 影響 */
/* 覆蓋 header2.css 的 .header-main-menu ul { gap: 20px; } */
.v4-member-dropdown-wrapper ul.v4-member-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 100px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: 8px;
    margin-bottom: 0;
    padding: 0;
    list-style: none;
    /* 確保垂直排列，並移除 header2.css 的 gap */
    display: none;
    flex-direction: column;
    gap: 0;
}

.v4-member-dropdown-wrapper ul.v4-member-dropdown.show {
    display: flex;
}

/* 小三角形（指向上方） */
.v4-member-dropdown-wrapper ul.v4-member-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 12px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #e0e0e0;
}

.v4-member-dropdown-wrapper ul.v4-member-dropdown::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 13px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #fff;
}

/* ==================== Dropdown 項目 ==================== */
.v4-member-dropdown-wrapper ul.v4-member-dropdown > li {
    display: block;
    width: 100%;
    flex-shrink: 0;
    border-bottom: 1px solid #e0e0e0;
}

.v4-member-dropdown-wrapper ul.v4-member-dropdown > li:last-child {
    border-bottom: none;
}

.v4-member-dropdown-wrapper ul.v4-member-dropdown > li > a {
    display: block;
    padding: 10px 16px;
    color: #212121;
    text-decoration: none;
    font-size: 14px;
    text-align: left;
    transition: background-color 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.v4-member-dropdown-wrapper ul.v4-member-dropdown > li > a:hover {
    background-color: #f5f5f5;
}

/* ==================== 手機版 Dropdown Header（顯示名稱） ==================== */
.v4-member-dropdown-wrapper ul.v4-member-dropdown > li.v4-dropdown-header {
    padding: 12px 16px;
    background-color: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    text-align: center;
}

.v4-dropdown-header .v4-member-level {
    display: block;
    margin-bottom: 2px;
}

.v4-dropdown-header .v4-member-name {
    display: block;
    margin-left: 0;
    color: #666;
}

/* ==================== 手機版樣式調整 ==================== */
.v4-member-dropdown-wrapper ul.v4-member-dropdown-mobile {
    right: 0;
}

/* ==================== V4 OAuth Login Modal ==================== */
/* //JW 2026/01/13 仿 V5 SKMEATS 的 modal 樣式，寬度 360px，高度 500px */
#V4_Modal_Login_Area .modal-dialog {
    /* main_v4.css 會用 !important 強制 modal-dialog 寬度，這裡要更強制覆蓋 */
    max-width: 360px !important;
    width: 360px !important;
    min-width: 0 !important;
    margin: 1.75rem auto !important;
    overflow: hidden !important;
}

#V4_Modal_Login_Area .modal-content {
    border-radius: 10px;
    overflow: hidden !important;
    background: #fff !important;
    padding: 0 !important;
    border: 0 !important;
    position: relative; /* //JW 2026/01/18 讓 preloader 相對於 modal-content 定位 */
}

#V4_Modal_Login_Area .modal-header.s5 {
    position: absolute;
    top: 0;
    right: 0;
    border-bottom: none;
    padding: 8px 12px;
    background: transparent;
    z-index: 10;
}

#V4_Modal_Login_Area .close {
    font-size: 24px;
    opacity: 0.6;
    color: #333;
    text-shadow: none;
}

#V4_Modal_Login_Area .close:hover {
    opacity: 1;
}

#V4_Modal_Login_Area iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
}

/* main_v4.css 會讓 modal.show 往下位移，V4 login 要置中 */
#V4_Modal_Login_Area.modal.show .modal-dialog {
    transform: none !important;
}

/* 避免 modal 本身出現第二層捲動 */
#V4_Modal_Login_Area {
    overflow: hidden !important;
}

/* Loading Spinner - 覆蓋在 modal 上 */
#v4-dialog-log-preloader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    background: rgba(255, 255, 255, 0.95);
    z-index: 99997;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

#v4-dialog-log-preloader .spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #DF0716;
    border-radius: 50%;
    animation: v4-spin 1s linear infinite;
}

@keyframes v4-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* //JW 2026/01/18 preloader 已移到 modal-content 內部，不再需要 modal-dialog 的 position: relative */

/* 手機版調整 */
@media (max-width: 400px) {
    #V4_Modal_Login_Area .modal-dialog {
        max-width: calc(100vw - 40px) !important;
        width: calc(100vw - 40px) !important;
        min-width: 0 !important;
        margin: 1rem auto !important;
    }
}

/* ==================== RWD 響應式調整 ==================== */
@media (max-width: 991px) {
    /* 手機版不顯示會員等級+名稱 */
    .v4-member-level-name {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .v4-member-dropdown-wrapper ul.v4-member-dropdown {
        min-width: 100px;
    }
    
    .v4-member-dropdown-wrapper ul.v4-member-dropdown > li > a {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .v4-member-dropdown-wrapper ul.v4-member-dropdown > li.v4-dropdown-header {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ==================== V4 mobile header: 未登入時右上角不錯位 ==================== */
/* //JW 2026/01/24 修正：mobile header 的 .menu-right 內有一個 span 同時包住「放大鏡 + 人頭 dropdown」
 * span 內又包含 div（block），在小寬度時容易被拆行，造成放大鏡掉下來
 * 這裡強制 span 變成 flex row，讓兩個 icon 永遠同行
 */
/* //JW 2026/01/24：不只避免換行，也要避免同一行內 baseline 對齊造成「放大鏡偏下、人頭偏上」 */
@media (max-width: 767px) {
    .header__mobile .header-main-menu .menu-right > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        white-space: nowrap;
        line-height: 0;
    }

    .header__mobile .header-main-menu .menu-right > span > a.icon-style {
        display: inline-flex;
        align-items: center;
        line-height: 0;
    }

    .header__mobile .header-main-menu .menu-right > span > a.icon-style svg {
        display: block;
    }

    .header__mobile .header-main-menu .menu-right > span .v4-member-dropdown-wrapper {
        display: inline-flex;
        align-items: center;
        line-height: 0;
    }
}

@media (max-width: 420px) {
    .header__mobile .header-main-menu .menu-right {
        gap: 8px;
    }

    /* //JW 2026/01/24 讓未登入的「加入會員」在超小寬度不要把 icon 擠到拆行 */
    #a_member_redirect_header_mobile {
        font-size: 13px;
        white-space: nowrap;
    }
}
