/* ============================================================
   mobile_nav.css — แถบบน + drawer มือถือ (ใช้คู่กับ mobile_nav.php)
   คัดลอกกฎมาจากบล็อกมือถือของ home.css เพื่อให้หน้าอื่นหน้าตาเหมือนกัน
   โหลด "ต่อจาก" CSS ของหน้านั้น ๆ  ตัวอย่าง:
       <link rel="stylesheet" href="all_css/cart.css">
       <link rel="stylesheet" href="all_css/mobile_nav.css">
   สีทั้งหมดมาจากพาเลตใน CLAUDE.md (teal #04757B, charcoal #242424, cream #F4F1EB, tan #BB7E5D)
   ============================================================ */

/* element เฉพาะมือถือ: ซ่อนบนเดสก์ท็อป */
.m-topbar,
.m-drawer,
.m-drawer-overlay { display: none; }

@media (max-width: 1024px) {

    /* ซ่อน navbar เดสก์ท็อปของหน้านั้น */
    .allnavbar { display: none; }

    /* ดันเนื้อหาทั้งหน้าลงมาพ้นแถบบนที่เป็น fixed สูง 58px
       (หน้าไหนต้องการระยะต่างจากนี้ ให้ override ในไฟล์ CSS ของหน้านั้น) */
    body { padding-top: 58px; }

    /* ตาข่ายกันพลาด: ทุกหน้าผ่านการตรวจว่าไม่มี element ล้นจอแล้ว (26 ก.ย. 2026)
       บรรทัดนี้กันกรณีเนื้อหาในอนาคตยาวผิดคาด (เช่น ชื่อสินค้ายาวมาก) ทำให้ปัดหน้าจอซ้าย-ขวาได้
       ใส่ที่ body อย่างเดียว ไม่ใส่ที่ html เพื่อไม่ให้กระทบ position:sticky ของหน้าไหน */
    body { overflow-x: hidden; }

    /* ---------- Top bar: hamburger | logo | cart + profile ---------- */
    .m-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0; left: 0;
        width: 100%;
        height: 58px;
        padding: 0 12px;
        background: #f4f4f4;
        box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
        z-index: 200;
        box-sizing: border-box;
    }
    /* โลโก้ absolute กึ่งกลางจอจริง */
    .m-topbar .m-logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
    }
    .m-topbar .m-logo img { height: 40px; display: block; }

    /* ปุ่ม hamburger (ซ้ายสุด) */
    .m-burger {
        width: 42px; height: 42px;
        display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 5px;
        background: none; border: none; cursor: pointer; border-radius: 8px;
        transition: background .2s ease;
    }
    .m-burger span {
        display: block; width: 24px; height: 2.5px;
        background: #242424; border-radius: 2px;
        transition: transform .25s ease, opacity .25s ease;
    }
    .m-burger:active { background: rgba(4, 117, 123, .12); }

    /* กลุ่มขวา: ตะกร้า + โปรไฟล์ */
    .m-actions { display: flex; align-items: center; gap: 4px; }
    .m-cart, .m-profile {
        display: flex; align-items: center; justify-content: center;
        width: 42px; height: 42px;
        font-size: 24px; color: #242424;
        text-decoration: none; border-radius: 50%;
        transition: background .25s ease, color .25s ease;
    }
    .m-cart:active, .m-profile:active { background: rgba(4, 117, 123, .12); color: #04757B; }
    .m-cart { position: relative; }
    .m-cart .m-cart-count {
        position: absolute; top: 3px; right: 0;
        min-width: 17px; height: 17px; padding: 0 4px;
        background: #BB7E5D; color: #FFFFFF;
        font-size: 11px; line-height: 17px; text-align: center;
        border-radius: 9px;
    }

    /* ---------- Drawer (สไลด์จากซ้าย) ---------- */
    .m-drawer-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 299;
        opacity: 0; visibility: hidden;
        transition: opacity .3s ease, visibility .3s ease;
    }
    .m-drawer-overlay.open { opacity: 1; visibility: visible; }

    .m-drawer {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0;
        width: 80%; max-width: 320px; height: 100%;
        background: #FFFFFF;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform .32s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 2px 0 18px rgba(0, 0, 0, .18);
        overflow-y: auto;
    }
    .m-drawer.open { transform: translateX(0); }

    .m-drawer-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 16px 18px; border-bottom: 1px solid #E0E0DE;
    }
    .m-drawer-logo { height: 40px; }
    .m-drawer-close {
        display: flex; align-items: center; justify-content: center;
        width: 38px; height: 38px;
        background: none; border: none; cursor: pointer;
        font-size: 24px; color: #242424; border-radius: 50%;
    }
    .m-drawer-close:active { background: #F4F4F4; }

    .m-drawer-user {
        display: flex; align-items: center; gap: 10px;
        padding: 14px 18px;
        background: #F4F1EB; color: #04757B;
        text-decoration: none; font-weight: 600;
    }
    .m-drawer-user iconify-icon { font-size: 24px; }

    .m-drawer-links { display: flex; flex-direction: column; padding: 8px 0; }
    .m-drawer-links a {
        display: flex; align-items: center; gap: 14px;
        padding: 14px 20px;
        color: #242424; text-decoration: none; font-size: 16px;
        border-left: 3px solid transparent;
        transition: background .2s ease, color .2s ease, border-color .2s ease;
    }
    .m-drawer-links a iconify-icon { font-size: 22px; color: #04757B; }
    .m-drawer-links a:active { background: #F4F1EB; }
    .m-drawer-links a.active {
        background: #F4F1EB; color: #04757B; font-weight: 600;
        border-left-color: #04757B;
    }
    .m-drawer-links a.m-drawer-logout iconify-icon { color: #BB7E5D; }
}

@media (max-width: 480px) {
    .m-topbar .m-logo img { height: 34px; }
}
