/* =============================================================================
   ★五通全端响应式统一层（Web / Pad / H5 / 手机）
   适用范围：平台端 5085、总管端 5095、官网 5001、H5 5294
   设计原则：
   1. 覆盖断点 375 / 390 / 768 / 1024 / 1440，横向溢出必须为 0；
   2. 可点元素热区不小于 44px（触屏）；
   3. 宽表格统一口径：一律“容器内横向滚动”，不逐页做成卡片，保证操作一致；
   4. 侧栏在 ≤1024 抽屉化：遮罩点击、Esc、返回手势均可关闭；
   5. 只做布局与尺寸，颜色一律沿用 wtorg-tokens.css，不新造配色。
   ========================================================================== */

/* ★根级防溢出：任何页面在 375px 宽度下都不得出现横向滚动条 */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ★媒体元素自适应，避免固定宽度图片/iframe 撑破布局 */
img,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

/* ★宽表格统一口径：所有列表页使用 .table-responsive / .Wtorg_table_scroll 包裹后横向滚动 */
.table-responsive,
.Wtorg_table_scroll,
[data-wtorg-table-scroll] {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.table-responsive > table,
.Wtorg_table_scroll > table,
[data-wtorg-table-scroll] > table {
    width: 100%;
}

/* ★抽屉打开时锁住页面滚动，避免背景跟着滑动 */
body.wtorg-sidebar-open,
body.w-drawer-open {
    overflow: hidden;
}

/* ★底部安全区（iPhone 刘海屏 / 全面屏） */
.w-tabbar,
.Wtorg_bottom_bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* -----------------------------------------------------------------------------
   ★全局热区（375~1440 全断点生效）：可点元素热区不小于 44px
   说明：这里只改"尺寸与对齐"，不新增任何颜色，视觉风格仍由 wtorg-tokens.css 决定。
   -------------------------------------------------------------------------- */
button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.btn,
.w-btn,
.Wtorg_btn {
    min-height: 44px;
}

/* 导航/菜单/分页/退出等文本型操作：用 Flex 居中撑到 44px，字号与颜色不变 */
.w-nav-link,
.nav-link,
.menu-item,
.page-link,
.pagination a,
.Wtorg_pager a,
.logout-btn,
.Wtorg_task_go {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* 分页页码：高度与宽度都补到 44px，手指点得准
   注意：提高选择器权重，确保覆盖前端框架对 .page-link 的 display/padding 定义 */
.pagination .page-link,
.pagination a,
.page-link {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 表单控件在所有断点统一 44px 高（勾选框/单选框除外，它们由外层 label 提供热区） */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    min-height: 44px;
}

/* 卡片标题右侧的"全部/处理"等短操作链接：宽度也补到 44px */
.w-card-title a,
.w-todo-main a {
    min-width: 44px;
    justify-content: center;
}

/* 弹窗/抽屉/页签关闭按钮（视觉图标不变，热区补到 44×44） */
.w-modal-close,
.w-drawer-close,
.Wtorg_modal_close,
.w-tab-close,
.w-nc-close,
.w-dialog-close,
.modal .close {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 分段控件：原生 radio 只是数据载体，真正可点的是外层 label */
.w-segment label {
    min-height: 44px;
}

/* 勾选框/单选框适当放大，便于触屏命中；外层 label 已具备 44px 热区 */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
}

/* 主内容区独立操作链接（查看/进入/订单号/去处理等）统一 44px 热区 */
.main-content a,
.w-main a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

/* 登录页辅助链接（立即注册/忘记密码） */
.w-auth-foot a,
.login-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

/* 勾选框整行热区：label 包住 input 时，整行不小于 44px */
.form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
}

.form-check .form-check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
}

/* -----------------------------------------------------------------------------
   ≤1440：常规桌面 / 小笔记本，收紧左右留白
   -------------------------------------------------------------------------- */
@media (max-width: 1440px) {
    .w-main,
    .main-content {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* -----------------------------------------------------------------------------
   ≤1024：Pad 横屏 / 竖屏，侧栏抽屉化，触屏热区 44px
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    /* 侧栏抽屉宽度不超过屏幕 86%，右侧始终留出遮罩可点区域 */
    .w-sidebar {
        max-width: 86vw;
    }

    /* 页签提示在窄屏隐藏，给页签本身腾空间 */
    .w-tabbar-tip {
        display: none;
    }

    /* ★触屏热区：按钮、导航、分页、表单控件统一不小于 44px */
    .w-btn,
    .Wtorg_btn,
    .btn,
    .w-nav-link,
    .menu-item,
    .nav-link,
    .page-link,
    .w-tabbar a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        min-height: 44px;
    }

    /* 表格容器允许触摸惯性滚动，禁止把整页撑宽 */
    .table-responsive,
    .Wtorg_table_scroll,
    [data-wtorg-table-scroll] {
        max-width: 100%;
    }
}

/* -----------------------------------------------------------------------------
   ≤768：手机横屏 / 小平板竖屏
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 头部允许换行，避免品牌名 + 用户信息 + 按钮挤出屏幕 */
    .w-header,
    .top-nav {
        flex-wrap: wrap;
        gap: 8px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .w-brand-text,
    .brand-text {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* 用户名过长时隐藏，仅保留头像/角色徽标 */
    .w-user-name {
        display: none;
    }

    .w-main,
    .main-content {
        padding: 12px;
    }

    .card-body {
        padding: 14px;
    }

    /* 卡片内的双列/多列表单在手机上纵向堆叠 */
    .row > [class*="col-md-"],
    .row > [class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* 弹窗类容器不超出可视宽度 */
    .modal-dialog,
    .Wtorg_modal_dialog {
        max-width: calc(100vw - 24px);
        margin: 12px auto;
    }

    /* 表格操作列按钮换行不溢出 */
    .table-responsive td .Wtorg_btn,
    .table-responsive td .btn,
    .Wtorg_table_scroll td .Wtorg_btn {
        margin: 2px 0;
    }
}

/* -----------------------------------------------------------------------------
   ≤390：主流手机（iPhone 12~15、安卓常见宽度）
   -------------------------------------------------------------------------- */
@media (max-width: 390px) {
    html {
        font-size: 15px;
    }

    .w-main,
    .main-content {
        padding: 10px;
    }

    .card-body {
        padding: 12px;
    }

    /* 分页在超窄屏隐藏“上一页/下一页”文字，只保留页码，避免换行溢出 */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* -----------------------------------------------------------------------------
   ≤375：小屏手机（iPhone SE / 老款安卓）
   -------------------------------------------------------------------------- */
@media (max-width: 375px) {
    html {
        font-size: 14px;
    }

    .w-main,
    .main-content {
        padding: 8px;
    }

    .w-brand-text,
    .brand-text {
        max-width: 36vw;
    }

    .Wtorg_btn,
    .w-btn,
    .btn {
        padding-left: 10px;
        padding-right: 10px;
    }
}
