/* ================================================================
   七彩云主机 · 全站浏览器 / 手机宽度兼容层
   作用：统一盒模型、防止横向溢出、窄屏表单与弹窗适配、
        表格横向滚动、超长域名/订单号断行、320px 小屏兜底。
   加载位置：所有前台页面与后台页面 </head> 前最后引入。
   ================================================================ */

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

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

body {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    -webkit-tap-highlight-color: rgba(37, 99, 235, .12);
}

img,
video,
canvas,
iframe {
    max-width: 100%;
}

img {
    height: auto;
}

table {
    max-width: 100%;
    border-collapse: collapse;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

textarea {
    resize: vertical;
}

/* flex / grid 子项允许收缩，避免长域名、长邮箱把卡片撑破 */
.row > *,
.d-flex > *,
.d-inline-flex > *,
.flex > *,
[class*="col-"] {
    min-width: 0;
}

/* 容器不超出视口 */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.content,
.block,
.block-content,
.card,
.modal-content,
.dropdown-menu {
    max-width: 100%;
}

/* 旧浏览器不支持 inset 简写时，固定遮罩仍然铺满屏幕 */
.risk-modal,
.welcome-mask,
.expire-remind-mask,
.img-preview-mask {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.img-preview-mask {
    width: 100% !important;
    height: 100% !important;
}

/* 表格：窄屏统一横向滚动，不压成一字宽 */
.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
    .table-responsive > .table,
    .table-responsive > table {
        min-width: 640px;
    }
}

/* 移动端表格字号略收，避免列与列挤在一起 */
@media (max-width: 767.98px) {
    /* Bootstrap 的负行距在窄屏会把登录/注册卡片顶出屏幕，移动端收敛为 0 */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .row > [class*="col-"] {
        padding-left: 8px;
        padding-right: 8px;
    }

    table.table {
        font-size: 12.5px;
    }

    table.table th,
    table.table td {
        padding: 8px 6px;
        vertical-align: middle;
    }

    /* 弹窗不超出屏幕 */
    .modal-dialog {
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        margin: 10px auto;
    }

    .modal-content {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        overflow: hidden;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
        margin: 0;
    }

    .swal2-popup,
    .layui-layer {
        max-width: calc(100% - 20px) !important;
    }

    .layui-layer.task-popup-layer {
        width: calc(100% - 20px) !important;
        height: auto !important;
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
    }

    .risk-modal-panel,
    .expire-remind-dialog {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
    }

    /* iOS / 微信输入框不小于 16px，避免聚焦自动放大页面 */
    input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    .form-control,
    .form-select {
        min-height: 42px;
    }

    .btn {
        min-height: 40px;
        white-space: normal;
    }

    .btn-sm {
        min-height: 32px;
    }

    .input-group {
        flex-wrap: wrap;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        flex: 1 1 100%;
    }

    .nav-tabs,
    .nav-pills {
        flex-wrap: wrap;
    }

    /* 页面标题栏允许换行，按钮不再被挤出屏幕 */
    .block-header,
    .content-header .block {
        flex-wrap: wrap;
        gap: 8px;
    }

    .block-options {
        max-width: 100%;
    }
}

/* 小于 576px：按钮组、工具栏、分页允许换行 */
@media (max-width: 575.98px) {
    .btn-group {
        flex-wrap: wrap;
    }

    .btn-group > .btn {
        flex: 1 1 auto;
    }

    .btn-toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }

    .page-link {
        padding: 6px 9px;
        font-size: 12px;
    }

    .pagination {
        flex-wrap: wrap;
        padding-left: 0;
    }
}

/* 320px 左右小屏兜底 */
@media (max-width: 359.98px) {
    .stat-card {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .stat-num,
    .agent-data-metric .m-num {
        font-size: 22px !important;
    }

    .home-section-head h2 {
        font-size: 18px !important;
    }

    .agent-data-strip {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .btn {
        padding-left: 10px;
        padding-right: 10px;
        font-size: 13px;
    }
}

/* 刘海屏 / 圆角屏安全区，横屏时也不贴边 */
@supports (padding: env(safe-area-inset-left)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
