/* =====================================================================
   01-kmis-mobile-bottom-nav.css : เปลือกมือถือของ K-MIS (เขียนใหม่ใน patch10)
   - ไม่บังคับสีใดๆ (เดิมฝังธีมสีแดง/โหมดมืดด้วย !important) สีทั้งหมดมาจากธีมองค์กร (99) และตัวแปร --p
   - แถบเมนูล่าง 5 ปุ่ม + ลิ้นชักเมนูทั้งหมด (bottom sheet) + จัดหน้าให้นิ้วโป้งกดได้ (ปุ่ม ≥ 44px, ตัวอักษรช่องกรอก 16px กัน iOS ซูมเอง)
   - รองรับรอยบากของ iPhone (safe-area) และการติดตั้งเป็นแอป (standalone)
   ส่วนหน้าหลัก/การ์ด/ตารางแบบการ์ดอยู่ใน 95-mobile.css (โหลดหลัง 93/94)
   ===================================================================== */

#kmis-mobile-bottom-nav,
#kmis-mobile-drawer-backdrop,
#kmis-mobile-drawer { display: none; }
.mobile-only-flex { display: none !important; }

@media screen and (max-width: 900px) {
    html { -webkit-text-size-adjust: 100%; }
    body { overscroll-behavior-y: none; -webkit-tap-highlight-color: rgba(30, 58, 95, .12); }

    #desktop-ui { display: block !important; padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
    #mobile-ui { display: none !important; }
    #ssoDivider, #ssoButtonsWrap { display: none !important; }
    .header-divider, .header-text { display: none !important; }
    .mobile-only-flex { display: flex !important; }

    /* หัวเว็บติดบน + เว้นรอยบากด้านบน */
    .header { position: sticky !important; top: 0; z-index: 1000; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px 14px; }
    .header-kmis { font-size: 20px; line-height: 1.1; }
    .header-accessibility-pill { padding: 2px 6px; }

    .app-wrapper { display: block; padding: 0; margin: 0; }
    .navbar { display: none !important; }
    .container { width: 100%; max-width: 100%; margin: 0; padding: 12px 12px 24px 12px; box-sizing: border-box; }

    /* ปุ่ม/ช่องกรอก: กดง่าย และไม่ให้ iOS ซูมหน้าเองตอนแตะช่องกรอก */
    button, .btn, select, input[type="button"], input[type="submit"] { min-height: 44px; }
    input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="tel"], input[type="number"],
    input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea { font-size: 16px; }

    /* ปฏิทิน (FullCalendar) */
    .fc-toolbar { flex-wrap: wrap; gap: 6px; }
    .fc-toolbar-title { font-size: 16px; }

    /* ซ่อนแถบลิขสิทธิ์ติดล่างของเดสก์ท็อป (ซ้อนทับแถบเมนูล่าง) */
    #desktop-ui > div[style*="position: fixed; bottom: 0"] { display: none !important; }

    /* ---------- แถบเมนูล่าง ---------- */
    #kmis-mobile-bottom-nav {
        display: flex; position: fixed; left: 0; bottom: 0; width: 100%; z-index: 1050;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding: 4px 6px env(safe-area-inset-bottom, 0px) 6px; box-sizing: border-box;
        background: #fff; border-top: 1px solid #D5DCE6; box-shadow: 0 -2px 12px rgba(15, 23, 42, .08);
        justify-content: space-around; align-items: stretch; user-select: none;
    }
    .kmis-bnav-btn {
        flex: 1 1 0; min-width: 0; margin: 0 2px; padding: 4px 2px; position: relative;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        background: transparent; border: 0; border-radius: 10px; cursor: pointer;
        color: #64748B; font-family: 'Sarabun', sans-serif; font-size: 11.5px; font-weight: 700; line-height: 1.15;
    }
    .kmis-bnav-btn span { color: inherit; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
    .kmis-bnav-btn .bnav-ico { font-size: 21px; line-height: 1.1; filter: grayscale(1); opacity: .75; }
    .kmis-bnav-btn.active { color: var(--p, #1E3A5F); background: #EEF1F6; }
    .kmis-bnav-btn.active .bnav-ico { filter: none; opacity: 1; }
    .kmis-bnav-btn.active::after { content: ''; position: absolute; top: -5px; left: 22%; right: 22%; height: 3px; background: var(--p, #1E3A5F); border-radius: 0 0 3px 3px; }
    .kmis-bnav-btn:active { transform: scale(.96); }

    /* ---------- ลิ้นชักเมนูทั้งหมด ---------- */
    #kmis-mobile-drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1060; }
    #kmis-mobile-drawer {
        position: fixed; left: 0; bottom: 0; width: 100%; max-height: 86vh; overflow-y: auto; z-index: 1070; box-sizing: border-box;
        background: #fff; color: #1F2937; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 28px rgba(0, 0, 0, .22);
        padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px)) 14px; -webkit-overflow-scrolling: touch;
    }
    .mb-drawer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
    .mb-drawer-item {
        background: #F8FAFC; border: 1px solid #D5DCE6; border-radius: 10px; padding: 12px 4px; min-height: 76px;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
        font-size: 12.5px; font-weight: 700; line-height: 1.25; color: #1F2937; cursor: pointer;
    }
    .mb-drawer-item > span:first-child { filter: grayscale(1); opacity: .85; }
    .mb-drawer-item.mb-admin-btn { background: #F3F5F8; border-color: #C5CEDB; color: var(--p, #1E3A5F); }
    .mb-drawer-item:active { transform: scale(.96); background: #E2E8F0; }
}

@media screen and (max-width: 360px) {
    .mb-drawer-grid { grid-template-columns: repeat(2, 1fr); }
    .kmis-bnav-btn { font-size: 10.5px; }
}
