/* 会员中心「原站模板」通道的手机适配层
 *
 * 只给 template/default/member/*.htm（Destoon 原站模板）用，与自研通道的
 * member/mobile.css 是两套东西：
 *   - 自研通道的模板是我们自己写的，容器 class 是 .member-*；
 *   - 原站模板是 table 布局：div.main_tb{min-width:1200px} 里套一张表，
 *     <td class="side"> 是 180px 固定侧栏，<td class="main"> 是内容区，
 *     页面内部再用 .menu（页签）/ table.tb（表单与列表）/ .tt（搜索条）。
 * 所以这里的选择器必须顺着原站结构写，不能照抄 mobile.css。
 *
 * 全部规则包在 @media (max-width:1020px) 里，桌面端渲染结果一字不变；
 * 唯一的例外是 .m_nav_btn 的 display:none（它就是给窄屏用的按钮）。
 *
 * 表格两类、处理方式相反，判定顺序不能反（踩过的坑，同 mobile.js）：
 *   - 有 <th>：数据表 → 整表横向滚动（宁可横滑，也别把「订单号」竖排）；
 *   - 没有 <th> 且首列是 td.tl：表单表 → 标签一行、控件一行。
 * 判定由 public/static/member/mobile.js 打 .tb-list / .tb-form 完成
 * （它也是自研通道用的那份），这里只负责被标记后的样式。
 */

/* 窄屏侧栏抽屉的开关按钮：桌面隐藏 */
.m_nav_btn { display: none; }

@media (max-width:1020px) {

	/* ---------- 基础 ---------- */
	html { -webkit-text-size-adjust: 100%; }
	/* 原站 static/script/reset.js 在 screen.width < 1280 时会执行
	   $('body').width(1280)，把整页钉成桌面宽度（这正是手机上横向溢出的
	   真正来源，光改 .main_tb 的 min-width 没用）。inline style 只能被
	   样式表里的 !important 盖掉，所以这里必须带 !important。 */
	body { font-size: 14px; width: auto !important; min-width: 0 !important; }
	.main img { max-width: 100%; height: auto; }
	.main iframe { max-width: 100%; }

	/* ---------- 顶部：固定高度横排 → 换行 + 菜单横滑 ---------- */
	.head { min-width: 0; height: auto; position: static; }
	.head_s { display: none; }
	.head_m {
		display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
		padding: 8px 10px; box-sizing: border-box;
	}
	.head_logo, .head_text { float: none; width: auto; height: auto; overflow: visible; }
	.head_logo img { width: 30px !important; height: 30px !important; margin: 0 !important; }
	.head_text { font-size: 16px; line-height: 1.3; }
	.head_user { float: none; margin-left: auto; padding: 0; }
	.head_user ul { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
	.head_user li { float: none; padding: 0; font-size: 13px; }
	.head_main { order: 3; float: none; width: 100%; }
	.head_main ul {
		display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
		-webkit-overflow-scrolling: touch;
	}
	.head_main ul::-webkit-scrollbar { display: none; }
	.head_main ul a { flex: 0 0 auto; }
	.menu_1, .menu_2 {
		float: none; height: 32px; line-height: 32px; font-size: 14px;
		padding: 0 14px; border-radius: 16px; white-space: nowrap;
	}
	.menu_1 { background: rgba(255, 255, 255, 0.22); }
	.menu_2 { background: rgba(255, 255, 255, 0.08); }
	.m_nav_btn {
		display: inline-flex; align-items: center; gap: 3px;
		height: 30px; padding: 0 12px; border-radius: 15px;
		background: rgba(255, 255, 255, 0.18); color: #FFFFFF;
		font-size: 13px; text-decoration: none; white-space: nowrap;
	}

	/* ---------- 布局：.main_tb 里的排版表改块级 ----------
	   原站结构是 div.main_tb > table > tbody > tr > td.side / td.side_h / td.main。
	   必须用子选择器：内容区自己还套着很多 table（.menu、table.tb、欢迎卡），
	   写成 .main_tb td 会把它们的单元格也变块级，整页竖排。 */
	.main_tb { display: block; width: 100%; min-width: 0; }
	.main_tb > table { display: block; width: 100%; }
	.main_tb > table > tbody,
	.main_tb > table > thead { display: block; width: 100%; }
	.main_tb > table > tbody > tr,
	.main_tb > table > tr { display: block; width: 100%; }
	.main_tb > table > tbody > tr > td,
	.main_tb > table > tr > td {
		display: block; width: auto; min-width: 0; box-sizing: border-box;
	}
	.main { padding: 12px 10px 24px; }

	/* ---------- 侧栏：180px 固定 → 抽屉 ---------- */
	/* 选择器要带 .main_tb 前缀：上面「改块级」那条是 (0,1,3)，只写 .side (0,1,0)
	   会被它盖掉，抽屉就永远展开、也折叠不回去。 */
	.main_tb td.side {
		display: none; width: 100%; min-width: 0;
		background: #FFFFFF; border-bottom: 1px solid #E6EBF2;
	}
	body.mnav-open .main_tb td.side { display: block; }
	.side_head { width: auto; background-position: right 14px center; }
	.side_head div { font-size: 14px; }
	.side_body { width: auto; }
	.side_body ul { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
	.side_body li {
		display: inline-flex; align-items: center; gap: 4px;
		padding: 6px 11px !important;
		background-image: none !important;
		background-color: #F2F5FA; border-radius: 99px; font-size: 13px;
	}
	.side_body li a { text-decoration: none; }
	.side_body li.side-on { background-color: #0067B8; }
	.side_body li.side-on a { color: #FFFFFF; }
	.side_body li span { display: none; }
	.side_body em { position: static; margin: 0 0 0 4px; }
	/* 原站的「收起/展开侧栏」竖条（panel.js 控制）在窄屏没有意义 */
	.main_tb td.side_h, .main_tb td.side_s { display: none; }

	/* ---------- 页签 .menu：一行横滑 ---------- */
	.menu { height: auto; overflow: visible; margin: 0 0 12px; letter-spacing: 0; }
	.menu table {
		display: block; width: 100%; overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
	.menu tbody { display: block; }
	.menu tr {
		display: flex; align-items: center; gap: 6px;
		white-space: nowrap; width: max-content; min-width: 100%;
	}
	.menu td.tab { display: block; float: none !important; font-size: 14px; }
	/* .tab a 原本是 36px 高的整块，同一个 td 里多个链接会各占一行 */
	.menu td.tab a { display: inline-block; height: auto; line-height: 30px; padding: 0 10px; }
	.menu td.tab a + a { margin-left: 2px; }
	.menu td.tab span { display: inline; }
	.menu td.tab_on a { color: #FFFFFF; }

	/* ---------- 状态导航 .nav（订单/信息管理的「全部|待付款|…」条） ---------- */
	.nav { margin: 0 0 10px; background: none; }
	.nav table {
		display: block; width: 100%; overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
	.nav tbody { display: block; }
	.nav tr {
		display: flex; white-space: nowrap;
		width: max-content; min-width: 100%;
	}
	.nav td { display: block; float: none; padding: 8px 10px; font-size: 14px; }

	/* ---------- 搜索条 .tt ---------- */
	.tt {
		display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
		padding: 0 0 12px; background: transparent;
	}
	.tt input[type=text], .tt input[type=search] { flex: 1 1 140px; width: auto !important; }
	.tt select { flex: 0 0 auto; max-width: 100%; }
	.tt .btn, .tt input[type=submit], .tt input[type=button] { flex: 0 0 auto; }

	/* ---------- 表格 ----------
	   数据表（有 th）：整表横向滚动，列宽保持原样。
	   表单表（无 th、首列 td.tl）：标签在上、控件在下。 */
	table.tb.tb-list {
		display: block; width: 100%; overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
	table.tb.tb-list th, table.tb.tb-list td { padding: 8px 6px; font-size: 13px; }
	table.tb.tb-list th { white-space: nowrap; }

	table.tb.tb-form { display: table; width: 100%; }
	table.tb.tb-form tbody, table.tb.tb-form tr { display: block; width: 100%; }
	table.tb.tb-form td {
		display: block; width: auto !important; min-width: 0;
		padding: 8px 10px !important; box-sizing: border-box;
	}
	table.tb.tb-form td.tl {
		width: auto; min-width: 0; text-align: left;
		background: transparent; color: #333333; font-weight: 600;
		padding: 10px 10px 0 !important;
	}
	table.tb.tb-form td input[type=text],
	table.tb.tb-form td input[type=password],
	table.tb.tb-form td input[type=number],
	table.tb.tb-form td input[type=email],
	table.tb.tb-form td input[type=tel],
	table.tb.tb-form td select,
	table.tb.tb-form td textarea { width: 100% !important; box-sizing: border-box; }

	/* ---------- 表单控件（16px 防 iOS 聚焦时自动放大） ---------- */
	input, select, textarea, button { font-size: 16px; }
	input[type=text], input[type=password], input[type=number], input[type=email],
	input[type=tel], input[type=search], select { min-height: 38px; box-sizing: border-box; max-width: 100%; }
	textarea { min-height: 110px; box-sizing: border-box; max-width: 100%; }

	/* ---------- 底部操作条：原站给侧栏留了 192px 左内边距 ---------- */
	.sbt { padding: 12px 0; }
	.btns { min-width: 0; padding: 12px 0; }
	.sbt-fix, .btns-fix { left: 0; padding-left: 12px; padding-right: 12px; }

	/* ---------- 会员首页 index.htm：无 class 的三列排版表 ----------
	   头像(120px) / 会员信息 / 余额(256px) 三列并排，窄屏会把「欢迎，公司名」
	   挤成一列一个字。这里改成竖排，只针对直接挂在 .main 下、又不是数据表
	   的排版表（.tb 有自己的规则，不能一起动）。 */
	.main > table:not(.tb) { display: block; width: 100%; }
	.main > table:not(.tb) > tbody,
	.main > table:not(.tb) > tr { display: block; width: 100%; }
	.main > table:not(.tb) > tbody > tr,
	.main > table:not(.tb) > tr { display: block; width: 100%; }
	.main > table:not(.tb) > tbody > tr > td,
	.main > table:not(.tb) > tr > td {
		display: block; width: auto !important; min-width: 0; padding: 0;
	}
	.iavatar { padding: 4px 0; text-align: center; }
	.iavatar img { width: 80px; height: 80px; }
	.iuser ul { margin: 6px 0 0; padding: 0 2px; }
	.iuser li { padding: 6px 2px; line-height: 1.7; }
	.inum { padding: 8px 0 2px; }
	.istats { height: auto; padding: 10px 0; margin: 12px 0; }
	.istats li {
		width: 25%; height: auto; line-height: 1.5;
		padding: 6px 0; box-sizing: border-box; border-right: none;
	}
	.istats b { font-size: 18px; display: block; line-height: 1.5; }
	.imore li { width: 50%; box-sizing: border-box; }
	.igird li { width: 33.33%; box-sizing: border-box; }
	.inote { padding: 8px 0 12px; }
	/* 首页右栏「会员动态」是固定 340px 的 iframe，窄屏直接隐藏 */
	.main .side-mm { display: none; }

	/* ---------- 头像页的 400x400 裁剪框 ---------- */
	.imageBox {
		width: 100% !important; max-width: 400px;
		height: auto !important; aspect-ratio: 1 / 1;
	}
	.imageBox .thumbBox {
		width: 50%; height: 50%;
		margin-top: -25%; margin-left: -25%;
	}
	/* avatar.htm 在 body 里又引了 api/avatar/cropbox.css（加载顺序在本文件之后），
	   同特异度的规则会被它盖掉，所以这里的覆盖一律带 !important。 */
	.action { width: auto !important; height: auto; margin: 10px 0; }
	.action table, .action tbody, .action td { display: block; width: auto; }
	.action tr { display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; }
	#btnZoomOut, #btnZoomIn, #btnCrop { margin-left: 0 !important; }

	/* ---------- 各页自带的定宽块 ---------- */
	.card-info { padding: 0 12px 12px; }
	.card-info li { width: 50%; }
	.card-list { height: auto; padding: 8px 12px; }
	.card-list img { margin: 4px 10px 0 0; }
	.list-img { width: auto; height: auto; padding: 8px 0; }
	.list-img ul { margin: 0; }
	.list-img i { display: block; margin: 8px 0 0; }
	.warn {
		height: auto; line-height: 22px; padding: 10px 12px 10px 40px;
		margin: 0 0 12px; background-position: 12px center;
	}
	.warn div { float: none; display: inline-block; margin-top: 8px; }
	.limit { margin-top: 12px; }
	.ts { padding: 10px 4px !important; }
	.side_body, .main { word-break: break-word; }

	/* ---------- 分页 ---------- */
	.pages { padding: 16px 0; }
	.pages a, .pages strong, .pages label { display: inline-block; margin-bottom: 6px; }

	/* ---------- 会员名片弹层（鼠标悬停卡片），手机上没有 hover ---------- */
	#destoon-card { width: auto; max-width: calc(100vw - 24px); }
}
