/* =====================================================================
   (06/11/2026) รอบ 9 — เมนูข้างมือถือ (offcanvas #psm ใน header_middle_shopping.php) UI ใหม่ตามรูปตัวอย่าง
   หัวโลโก้ + คลื่นน้ำเงิน/ทอง · เมนูมีไอคอน · เมนูที่เลือก/เปิดอยู่เป็นแถบน้ำเงินขอบทอง
   รายการย่อย (แบรนด์/กลุ่ม) เป็นการ์ดเทามีรูป · ปุ่ม Login ขอบทอง · ปุ่ม Messenger
   ===================================================================== */
#psm {
    --psm-navy: #0c2d57;
    --psm-navy2: #1d4f8c;
    --psm-gold: #dcb75c;
    --psm-text: #12345e;
    width: min(86vw, 360px);
    background: linear-gradient(180deg, #ffffff 0%, #f2f5fa 100%);
}
#psm .mobile-header-wrapper-inner { padding-bottom: 28px; }

/* ---------- หัวเมนู: โลโก้ + คลื่น ---------- */
#psm .mobile-header-wrapper-inner .mobile-header-top {
    position: relative;
    overflow: hidden;
    align-items: flex-start;
    padding: 24px 20px 46px;
    background: linear-gradient(140deg, #ffffff 0%, #eef2f8 55%, #e2e8f2 100%);
}
#psm .mobile-header-wrapper-inner .mobile-header-top::before {          /* คลื่นน้ำเงิน มุมขวาล่าง */
    content: "";
    position: absolute;
    right: -38%;
    bottom: -62px;
    width: 125%;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(160deg, #2b62a3 0%, var(--psm-navy) 70%);
    border-top: 3px solid var(--psm-gold);
    box-shadow: 0 -3px 12px rgba(220, 183, 92, .55);
    transform: rotate(-11deg);
}
#psm .mobile-header-top .mobile-header-logo { position: relative; z-index: 1; }
#psm .mobile-header-wrapper-inner .mobile-header-top .mobile-header-logo a img { width: 118px; }

/* ปุ่มปิด: วงกลมขาวมีเงา */
#psm .mobile-menu-close { position: relative; z-index: 1; }
#psm .close-style-wrap .close-style {
    width: 42px;
    height: 42px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(12, 45, 87, .18);
}
#psm .close-style-wrap .close-style > i::before,
#psm .close-style-wrap .close-style > i::after { background-color: var(--psm-navy) !important; }

/* ---------- รายการเมนู ---------- */
#psm .mobile-header-wrapper-inner .mobile-header-content-area { padding: 14px 14px 20px; }
#psm .mobile-menu > li {
    padding: 0;
    margin: 0;
    border-bottom: 1px solid #e3e8ef;
}
#psm .mobile-menu > li:last-child { border-bottom: none; }
#psm .mobile-menu > li.active,
#psm .mobile-menu > li.psm-current { border-bottom-color: transparent; }
#psm .mobile-menu li .menu-expand { display: none !important; }   /* ใช้ลูกศรของเราแทน */

#psm .mobile-menu > li > a {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 40px 13px 14px;
    margin: 4px 0;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--psm-text);
    position: relative;
    transition: background .2s, color .2s;
}
#psm .psm-ico { display: inline-flex; flex: 0 0 auto; color: inherit; }
#psm .psm-ico svg { width: 26px; height: 26px; }
#psm .psm-txt { flex: 1 1 auto; min-width: 0; }

/* ลูกศร: ลิงก์ธรรมดา = ขวา · มีเมนูย่อย = ลง · เปิดอยู่ = ขึ้น */
#psm .mobile-menu > li > a::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-50%) rotate(-45deg);
    transition: transform .2s;
}
#psm .mobile-menu > li:has(> ul.dropdown) > a::after { transform: translateY(-70%) rotate(45deg); }
#psm .mobile-menu > li.active:has(> ul.dropdown) > a::after { transform: translateY(-25%) rotate(-135deg); }

/* เมนูที่เลือก/เปิดอยู่: แถบน้ำเงินขอบทอง */
#psm .mobile-menu > li.active > a,
#psm .mobile-menu > li.psm-current > a {
    background: linear-gradient(90deg, var(--psm-navy) 0%, var(--psm-navy2) 100%);
    color: #fff;
    box-shadow: 0 6px 14px rgba(12, 45, 87, .28), inset 0 -2px 0 var(--psm-gold), 0 4px 10px -4px rgba(220, 183, 92, .9);
}
#psm .mobile-menu > li:hover > a { color: var(--psm-text); }
#psm .mobile-menu > li.active:hover > a,
#psm .mobile-menu > li.psm-current:hover > a { color: #fff; }

/* ---------- รายการย่อย ---------- */
#psm .mobile-menu > li > ul.dropdown { padding: 6px 0 8px 10px; }
#psm .mobile-menu > li > ul.dropdown > li { padding: 0; margin: 0 0 6px; border: 0; }
#psm .mobile-menu > li > ul.dropdown > li > a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 34px 7px 10px;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8f9fc 0%, #ebeef4 100%);
    box-shadow: inset 0 1px 0 #fff, 0 1px 3px rgba(12, 45, 87, .10);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--psm-text);
    position: relative;
}
#psm .mobile-menu > li > ul.dropdown > li > a::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 2px solid #5b6f8c;
    border-bottom: 2px solid #5b6f8c;
    transform: translateY(-50%) rotate(-45deg);
}
#psm .psm-thumb {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #fff;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(12, 45, 87, .12);
}
#psm .psm-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- ส่วนล่าง: Login / ข้อมูลสมาชิก ---------- */
#psm .mobile-header-wrapper-inner .mobile-header-content-area .mobile-header-info-wrap {
    margin: 14px 0 0;
    padding: 18px 0 0;
    border: 0;
    border-top: 1px solid #e3e8ef;
    border-radius: 0;
}
#psm .mobile-header-info-wrap .mobile-menu-wrap { left: 0 !important; }
#psm .mobile-header-info-wrap .mobile-menu > li { border-bottom: 0; }
#psm .mobile-header-info-wrap .mobile-menu > li > a { font-size: 16px; font-weight: 500; padding: 11px 40px 11px 14px; }
#psm .mobile-header-info-wrap .mobile-menu > li > a > i { width: 26px; text-align: center; font-size: 18px; margin: 0 !important; }
#psm .mobile-header-wrapper-inner .mobile-header-content-area .mobile-header-border { border-bottom: 0; }

#psm .mobile-header-info-wrap .mobile-menu > li.psm-login > a {
    justify-content: center;
    padding: 14px 20px;
    border: 2px solid var(--psm-gold);
    border-radius: 999px;
    background: #fff;
    font-size: 21px;
    font-weight: 600;
    color: var(--psm-text);
    box-shadow: 0 6px 16px -4px rgba(220, 183, 92, .75), inset 0 0 0 1px #fff7e3;
}
#psm .mobile-header-info-wrap .mobile-menu > li.psm-login > a .psm-txt { flex: 0 0 auto; }
#psm .mobile-header-info-wrap .mobile-menu > li.psm-login > a::after { display: none; }
#psm .mobile-header-info-wrap .mobile-menu > li.psm-logout > a { color: #b42318; }


/* เมนู PDPA: ไอคอน <i> อยู่นอก <a> → วางซ้อนด้านซ้ายให้อยู่บรรทัดเดียวกัน */
#psm .mobile-header-info-wrap .mobile-menu > li { position: relative; }
#psm .mobile-header-info-wrap .mobile-menu > li > i {
    position: absolute;
    left: 14px;
    top: 18px;
    width: 26px;
    text-align: center;
    font-size: 18px;
    color: var(--psm-text);
    z-index: 1;
    pointer-events: none;
}
#psm .mobile-header-info-wrap .mobile-menu > li > i + a { padding-left: 54px; }

/* ปุ่ม Messenger */
#psm .psm-messenger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 20px 4px 16px;
    padding: 11px 22px;
    border-radius: 14px;
    background: linear-gradient(180deg, #2e95ff 0%, #0866ff 100%);
    color: #fff;
    font-size: 19px;
    font-weight: 600;
    box-shadow: 0 6px 14px rgba(8, 102, 255, .35);
}
#psm .psm-messenger:hover { color: #fff; }
#psm .mobile-social-icon h6 { color: var(--psm-text); }

/* =====================================================================
   (06/11/2026) รอบ 10 — เมนูข้างหน้าสมาชิก (header_middle.php, sessiontab) ใช้หน้าตาเดียวกับหน้าร้าน
   ===================================================================== */
/* ไอคอน mdi ของเมนูที่สร้างจาก fun_genheader_mobile */
#psm .mobile-menu > li > a > i.mdi,
#psm .mobile-menu > li > a > i.fa,
#psm .mobile-menu > li > a > i.fas {
    font-size: 25px !important;
    width: 26px;
    text-align: center;
    top: 0 !important;
    margin: 0 !important;
    flex: 0 0 auto;
}
/* รายการย่อยที่เป็นหน้าปัจจุบัน */
#psm .mobile-menu > li > ul.dropdown > li > a.psm-here {
    font-weight: 700;
    color: var(--psm-navy);
    box-shadow: inset 3px 0 0 var(--psm-gold), 0 1px 3px rgba(12, 45, 87, .10);
}
/* ลิงก์ Login / ติดต่อ / Logout แบบ div (single-mobile-header-info) */
#psm .mobile-header-info-wrap .single-mobile-header-info { margin: 0 0 4px; }
#psm .mobile-header-info-wrap .single-mobile-header-info:empty { display: none; }
#psm .mobile-header-info-wrap .single-mobile-header-info > a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 500;
    color: var(--psm-text);
}
#psm .mobile-header-info-wrap .single-mobile-header-info > a > i { width: 26px; text-align: center; font-size: 18px; margin: 0 !important; }
#psm .mobile-header-info-wrap .single-mobile-header-info.psm-logout > a { color: #b42318; }
#psm .mobile-header-info-wrap .single-mobile-header-info.psm-login > a {
    justify-content: center;
    padding: 14px 20px;
    border: 2px solid var(--psm-gold);
    border-radius: 999px;
    background: #fff;
    font-size: 21px;
    font-weight: 600;
    box-shadow: 0 6px 16px -4px rgba(220, 183, 92, .75);
}
#psm .mobile-menu-wrap + .mobile-header-info-wrap .mobile-menu-wrap { margin-bottom: 6px; }

/* หน้าสมาชิกใช้ viewport initial-scale=0.6 → บนมือถือ (จอสัมผัส) ขยายเมนูกลับเป็นขนาดจริง */
/* (06/11/2026 รอบ 13) zoom ของ #psm.psm-s06 คำนวณด้วย JS ใน header_middle.php (psmFit) ตามสเกลจริงของเครื่อง */

/* =====================================================================
   (06/11/2026) รอบ 11 — มือถือเลื่อนเมนูข้างลงไม่สุด
   เดิม main.css: top/bottom 0 + min-height 100vh → บนมือถือ 100vh สูงกว่าจอที่เห็นจริง (แถบ address/toolbar)
   และหน้าสมาชิกที่ zoom 1.6 แผงเมนูสูง 1.6 เท่าของจอ → ส่วนล่างตกขอบ เลื่อนไม่ถึง
   → ใช้ความสูงจอที่เห็นจริง (dvh) + เผื่อขอบล่าง iPhone (safe-area)
   ===================================================================== */
#psm { min-height: 0; bottom: auto; height: 100vh; height: 100dvh; }
#psm .mobile-header-wrapper-inner { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }

/* =====================================================================
   (06/11/2026) รอบ 12
   - หัวเมนูข้างเตี้ยลง (เดิมเด่นไป) · ปุ่มปิดเล็กลง ย้ายไปมุมขวาบน
   - หัวมือถือหน้าสมาชิก (header.hdr-s06) ขนาดเท่าหน้าสั่งซื้อ: หน้าสมาชิก viewport 0.6 → ขยาย 1.6 บนจอสัมผัส
   - ธงเปลี่ยนภาษาบนหัวมือถือหน้าร้าน (.psm-lang)
   ===================================================================== */
#psm .mobile-header-wrapper-inner .mobile-header-top {
    padding: 14px 16px 30px;
}
#psm .mobile-header-wrapper-inner .mobile-header-top::before {
    height: 76px;
    bottom: -48px;
    border-top-width: 2px;
}
#psm .mobile-header-wrapper-inner .mobile-header-top .mobile-header-logo a img { width: 84px; }
#psm .mobile-menu-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}
#psm .close-style-wrap .close-style {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, .75);
    box-shadow: 0 1px 4px rgba(12, 45, 87, .15);
}

/* (รอบ 13) header.hdr-s06: zoom คำนวณด้วย JS (psmFit) แทนค่า 1.6 ตายตัว — บางเครื่องแสดง 1:1 อยู่แล้ว ขยายซ้ำจะล้นจอ */

/* ธงภาษาบนหัวมือถือหน้าร้าน */
.header_mshop .header-info-right { margin-left: 6px; }
.header_mshop .header-info-right > ul > li { position: relative; list-style: none; }
.header_mshop .psm-lang { display: inline-flex; align-items: center; cursor: pointer; padding: 6px 0; }
.header_mshop .psm-lang img { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.header_mshop .header-info-right .language-dropdown { right: 0; left: auto; }
