/* ============================================================
 * FastAdmin 移动端适配样式
 * 仅影响 ≤767px 视口，桌面端零影响
 * 详见 /www/wwwroot/移动端ui适配.md
 * ============================================================ */

/* ---------- 通用：仅手机断点生效 ---------- */
@media (max-width: 767px) {

    /* 基础字号放大，提升可读性 */
    html, body {
        font-size: 15px;
        line-height: 1.5;
    }

    /* iframe 强制全宽，避免内容区被压缩 */
    .content-wrapper,
    .tab-content,
    .tab-content > .tab-pane,
    .tab-content > .tab-pane > iframe,
    .content-wrapper iframe {
        width: 100% !important;
        max-width: 100vw;
    }

    .content {
        padding: 8px !important;
    }

    /* ---------- 顶栏 / Logo ---------- */
    .main-header .logo {
        width: 60px !important;
        padding: 0 5px !important;
        font-size: 16px;
    }
    .main-header .logo .logo-lg {
        display: none !important;
    }
    .main-header .logo .logo-mini {
        display: block !important;
    }
    .main-header .navbar {
        margin-left: 60px !important;
    }

    /* 汉堡按钮放大触控区 */
    .main-header .sidebar-toggle {
        padding: 15px 18px !important;
        font-size: 20px !important;
        min-width: 50px;
        min-height: 50px;
    }

    /* 顶栏右侧用户头像/菜单触控区 */
    .main-header .navbar-custom-menu .navbar-nav > li > a {
        padding: 13px 12px !important;
        min-height: 44px;
    }

    /* 多标签栏（nav-addtabs）已 hidden-xs，再保险隐藏 */
    .nav-addtabs {
        display: none !important;
    }
    /* multipletab 第二级菜单条隐藏 */
    #secondnav {
        display: none !important;
    }
    /* 取消因多标签预留的顶部内边距 */
    .multipletab.multiplenav .content-wrapper,
    .multipletab.multiplenav .right-side {
        padding-top: 50px !important;
    }

    /* ---------- 侧边栏 ---------- */
    .main-sidebar {
        width: 240px !important;
    }
    .sidebar-menu > li > a {
        padding: 14px 15px !important;
        font-size: 15px;
    }
    .sidebar-menu .treeview-menu > li > a {
        padding: 10px 5px 10px 35px !important;
        font-size: 14px;
    }

    /* ---------- 按钮 / 触控区 ---------- */
    .btn {
        min-height: 38px;
        padding: 8px 14px;
        font-size: 14px;
    }
    .btn-xs, .btn-group-xs > .btn {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 13px;
    }
    .btn-sm, .btn-group-sm > .btn {
        min-height: 36px;
        padding: 7px 12px;
    }

    /* 工具栏自动换行，按钮间距 */
    .toolbar,
    .fixed-table-toolbar,
    #toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 0;
    }
    .toolbar > .btn,
    .toolbar > .dropdown,
    .toolbar > .btn-group,
    .fixed-table-toolbar .columns .btn,
    .fixed-table-toolbar .search {
        margin: 0 !important;
    }
    .fixed-table-toolbar .search {
        width: 100% !important;
    }
    .fixed-table-toolbar .search .form-control {
        width: 100% !important;
    }

    /* ---------- 表格 ---------- */
    /* 列表页 panel 留白收紧 */
    .panel-body {
        padding: 8px !important;
    }
    .panel-heading {
        padding: 8px 10px !important;
    }
    .panel-intro > .panel-heading .nav-tabs {
        white-space: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .panel-intro > .panel-heading .nav-tabs > li {
        display: inline-block;
        float: none;
    }

    /* table-nowrap 在手机端取消（恢复多行换行），避免双层横滚 */
    table.table-nowrap tbody > tr > td,
    table.table-nowrap thead > tr > th {
        white-space: normal !important;
        word-break: break-all;
    }

    /* bootstrap-table 横滚容器优化 */
    .bootstrap-table .fixed-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* bootstrap-table card 视图美化（由 JS 在手机端自动开启） */
    .bootstrap-table .table.table-card .card-view {
        padding: 6px 8px;
        border-bottom: 1px dashed #eee;
    }
    .bootstrap-table .table.table-card .card-view .title {
        display: inline-block;
        min-width: 80px;
        color: #888;
        font-weight: 500;
    }

    /* 分页 */
    .fixed-table-pagination .pagination {
        flex-wrap: wrap;
    }
    .fixed-table-pagination .pagination > li > a,
    .fixed-table-pagination .pagination > li > span {
        min-width: 36px;
        min-height: 36px;
        line-height: 36px;
        padding: 0 10px;
    }

    /* ---------- 表单 ---------- */
    .form-horizontal .control-label {
        text-align: left !important;
        padding-top: 4px;
        margin-bottom: 4px;
        font-weight: 500;
    }
    .form-group {
        margin-bottom: 12px;
    }
    .form-control {
        min-height: 38px;
        font-size: 15px;
    }
    select.form-control {
        height: 38px;
    }
    /* selectpicker / sp_container 触控适配 */
    .bootstrap-select > .btn,
    .sp_container {
        min-height: 38px !important;
    }

    /* 表单底部固定按钮：贴底 + 安全区 */
    .fixed-footer {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
        box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.06);
        z-index: 1050;
    }
    .fixed-footer .btn {
        margin: 3px;
    }
    /* 表单底部留出空间，避免 fixed-footer 遮挡最后一个字段 */
    form.form-horizontal,
    form.form-vertical,
    .form-layer .form-body {
        padding-bottom: 70px;
    }

    /* ---------- Layer.js 弹窗 ---------- */
    .layui-layer:not(.layui-layer-iframe):not(.layui-layer-loading):not(.layui-layer-tips) {
        width: 96vw !important;
        max-width: 96vw !important;
        left: 2vw !important;
    }
    .layui-layer-iframe {
        width: 100vw !important;
        max-width: 100vw !important;
        left: 0 !important;
    }
    .layui-layer-iframe iframe {
        width: 100% !important;
    }
    .layui-layer-title {
        font-size: 15px;
        height: 44px;
        line-height: 44px;
        padding: 0 50px 0 15px;
    }
    .layui-layer-setwin a {
        width: 28px;
        height: 28px;
        margin-left: 8px;
    }
    .layui-layer-btn .layui-layer-btn0,
    .layui-layer-btn .layui-layer-btn1 {
        min-height: 38px;
        line-height: 26px;
        padding: 6px 16px;
        font-size: 14px;
    }

    /* ---------- 其他 ---------- */
    /* 面包屑 ribbon 在手机端隐藏 */
    #ribbon {
        display: none !important;
    }
    /* dashboard info-box 收紧 */
    .info-box {
        margin-bottom: 10px;
    }
    /* 卡片型小部件高度自适应 */
    .small-box .icon {
        font-size: 60px;
        top: 15px;
    }

    /* Dashboard 普通表格（非 bootstrap-table）增加横滚保护 */
    .ops-table-wrap,
    .ops-dashboard .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ops-dashboard .ops-table-wrap > .table {
        min-width: 480px;
    }
    /* Dashboard 内的 ops-card 内边距收紧 */
    .ops-dashboard .ops-card {
        padding: 10px;
    }
    .ops-dashboard .ops-summary {
        padding: 10px;
    }
    .ops-dashboard .ops-summary-value {
        font-size: 22px;
    }
    .ops-dashboard .ops-metric-value {
        font-size: 22px;
    }
}

/* ---------- 平板 (768~991px) 轻调 ---------- */
@media (min-width: 768px) and (max-width: 991px) {
    .main-header .logo {
        width: 180px;
    }
    .content {
        padding: 12px;
    }
}

/* ============================================================
 * 活动管理页 (activities/index) 专项移动端适配
 * 该页面有自定义 sticky 栏 + 双侧栏 + 超长工具栏，需单独处理
 * ============================================================ */
@media (max-width: 767px) {

    /* 顶部 sticky 头部：关闭 sticky 防止双层粘连，收紧内边距 */
    .activity-sticky-head {
        position: static !important;
        margin: 0 0 8px 0 !important;
        padding: 8px 8px 0 !important;
        box-shadow: none !important;
    }
    .activity-sticky-head .alert {
        font-size: 12px;
        padding: 8px;
        line-height: 1.45;
    }
    /* 可见性切换 tabs 在手机端允许横滚 */
    .activity-visibility-tabs {
        white-space: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 8px !important;
    }
    .activity-visibility-tabs > li {
        display: inline-block !important;
        float: none !important;
    }
    .activity-visibility-tabs > li > a {
        padding: 8px 12px !important;
    }

    /* 工作区从横向 flex 强制改为单列 */
    .activity-workbench {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* 侧边栏：取消 sticky / 固定宽度 / 高度限制 */
    .activity-sidebar {
        position: static !important;
        width: 100% !important;
        flex-basis: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .activity-sidebar-head {
        padding: 8px 10px !important;
    }
    .activity-group-list {
        max-height: 240px !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .activity-group-item {
        padding: 10px !important;
    }

    /* 工具栏 sticky 块也关闭 sticky，否则手机上挤掉内容 */
    .activity-sticky-actions {
        position: static !important;
        padding: 8px !important;
        margin: 0 0 8px 0 !important;
        box-shadow: none !important;
    }

    /* 城市筛选改为可换行紧凑布局 */
    .activity-city-filter {
        display: block !important;
        padding: 8px !important;
        margin-bottom: 8px !important;
    }
    .activity-city-filter-title {
        line-height: 1.4 !important;
        margin-bottom: 6px !important;
        font-size: 13px;
    }
    .activity-city-list {
        gap: 4px !important;
    }
    .activity-city-item {
        height: 32px !important;
        line-height: 30px !important;
        padding: 0 10px !important;
        font-size: 13px !important;
    }

    /* 工具栏按钮：全部规整为 flex 换行，去掉 pull-right 的偏移 */
    .activity-toolbar-row {
        gap: 6px !important;
        flex-wrap: wrap !important;
    }
    .activity-toolbar-row > .btn,
    .activity-toolbar-row > .btn-group,
    .activity-toolbar-row > .dropdown {
        margin: 0 !important;
    }
    .activity-toolbar-row .pull-right {
        float: none !important;
        margin-left: 0 !important;
    }
    .activity-toolbar-row > .btn-group {
        display: inline-flex;
    }
    /* radio 模式的 btn-group 按钮文字尺寸 */
    .activity-source-switch .btn,
    .activity-view-switch .btn {
        padding: 7px 10px !important;
        font-size: 13px !important;
    }
    /* 防止 inline style margin-left 在手机端拉开布局 */
    .activity-toolbar-row .activity-source-switch,
    .activity-toolbar-row .activity-view-switch {
        margin-left: 0 !important;
    }

    /* 切换按钮里的 badge 数字间距 */
    .activity-source-switch .badge {
        margin-left: 4px;
    }

    /* 主体表格区域不再受 flex 比例约束 */
    .activity-main {
        width: 100%;
        min-width: 0;
    }

    /* 该页 table-nowrap 已被通用规则取消，再额外保留 word-break 防长单元格 */
    .activity-main table td,
    .activity-main table th {
        word-break: break-all;
    }

    /* ---------- 活动管理页：可折叠面板 ---------- */
    .activity-mobile-toggle-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0 14px;
        margin: 0 0 8px 0;
        background: #f4f7fb;
        border: 1px solid #dfe6ef;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        color: #0b57d0;
        user-select: none;
        min-height: 44px;
        line-height: 44px;
        text-align: left;
        outline: none;
        appearance: none;
        -webkit-appearance: none;
        -webkit-tap-highlight-color: rgba(11, 87, 208, 0.12);
        touch-action: manipulation;
    }
    .activity-mobile-toggle-bar:active {
        background: #e6eef8;
    }
    .activity-mobile-toggle-bar .activity-mobile-toggle-title,
    .activity-mobile-toggle-bar .activity-mobile-toggle-hint,
    .activity-mobile-toggle-bar .activity-mobile-toggle-icon {
        pointer-events: none;  /* 防止子元素抢点击，保证 e.target 始终是按钮本体 */
    }
    .activity-mobile-toggle-bar .activity-mobile-toggle-title {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .activity-mobile-toggle-bar .activity-mobile-toggle-hint {
        font-size: 12px;
        font-weight: 400;
        color: #6b7280;
        margin-left: 8px;
    }
    .activity-mobile-toggle-bar .activity-mobile-toggle-icon {
        flex: 0 0 auto;
        margin-left: 10px;
        transition: transform 0.2s ease;
        color: #6b7280;
    }
    .activity-mobile-toggle-bar.is-collapsed .activity-mobile-toggle-icon {
        transform: rotate(-90deg);
    }
    .activity-mobile-collapsible.is-collapsed {
        display: none !important;
    }
}

/* 桌面端确保折叠条不出现，原内容正常显示 */
@media (min-width: 768px) {
    .activity-mobile-toggle-bar {
        display: none !important;
    }
    .activity-mobile-collapsible.is-collapsed {
        display: block !important;
    }
}
