/**
 * ACS Admin 响应式适配样式
 *
 * 作者: VT SEO团队
 * 日期: 2026-02-22
 * 版本: 1.0.0
 *
 * 功能说明:
 *   - 手机端 (<768px): 侧边栏抽屉化、搜索表单竖排、表格横滚、弹窗自适应
 *   - 平板端 (768-1024px): 侧边栏mini化、搜索表单2列、通知栏缩小
 *   - 桌面端 (>1024px): 保持原样不变
 *
 * 重要: 本文件使用 !important 覆盖 ry-ui.css 中对搜索表单的 display:none 规则
 *       这是唯一使用 !important 的地方，原因是 ry-ui.css:624-628 已用 display:none 隐藏搜索
 */


/* ============================================
   1. 手机端 — 侧边栏抽屉式
   ============================================ */
@media (max-width: 767px) {

    /* --- 侧边栏：抽屉模式 --- */
    body.fixed-sidebar .navbar-static-side {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 10001;
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 侧边栏打开状态 */
    body.sidebar-open .navbar-static-side {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* 侧边栏遮罩层 (通过 JS 创建) */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* 覆盖原有的 mini-navbar 行为 — 手机端不折叠为mini */
    body.mini-navbar .navbar-static-side {
        width: 220px;
    }

    body.mini-navbar .sidebar-collapse .nav li a .nav-label,
    body.mini-navbar .sidebar-collapse .nav li a .fa.arrow,
    body.mini-navbar .sidebar-collapse .logo-lg {
        display: inline;
        opacity: 1;
    }

    body.mini-navbar .sidebar-collapse .nav-second-level,
    body.mini-navbar .sidebar-collapse .nav-third-level {
        display: block;
    }

    body.mini-navbar .sidebar-collapse .nav li a {
        text-align: left;
        padding: 10px 20px;
    }

    /* 右侧内容区：全宽 */
    body.fixed-sidebar #page-wrapper,
    body.mini-navbar #page-wrapper {
        margin-left: 0;
        width: 100%;
    }

    /* --- 顶部导航栏 --- */
    .navbar-static-top {
        position: relative;
    }

    .navbar-header {
        width: auto !important;
    }

    /* 汉堡菜单按钮：手机端始终显示 */
    .navbar-minimalize {
        display: inline-block;
        padding: 10px 15px;
        font-size: 18px;
    }

    /* 通知预警区域：允许横向滚动 */
    ul.welcome-message {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding: 0 5px;
        max-width: 100%;
    }

    ul.welcome-message > li {
        flex-shrink: 0;
    }

    ul.welcome-message > li > a {
        font-size: 11px;
        padding: 8px 6px;
        white-space: nowrap;
    }

    /* 用户菜单 */
    .dropdown.user-menu {
        position: static;
    }

    .dropdown.user-menu .dropdown-menu {
        position: absolute;
        right: 5px;
        left: auto;
        min-width: 120px;
    }

    /* --- 多页签栏 --- */
    .content-tabs {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        white-space: nowrap;
        overflow: hidden;
    }

    .content-tabs .page-tabs-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .content-tabs .page-tabs-content > a {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* 页签滚动按钮 */
    .roll-nav {
        flex-shrink: 0;
    }

    /* --- 主内容 iframe 区域 --- */
    #content-main {
        height: calc(100vh - 130px);
        -webkit-overflow-scrolling: touch;
    }

    #content-main iframe {
        width: 100%;
        height: 100%;
    }
}


/* ============================================
   2. 手机端 — 搜索表单 + 表格 (子页面 iframe 内)
   ============================================ */
@media (max-width: 767px) {

    /* 基础字号提升: 手机端默认 14px (桌面端 13px 在手机上太小) */
    body {
        font-size: 14px !important;
    }

    /* 灰色背景内边距 */
    body.gray-bg {
        padding: 8px;
    }

    /* 核心覆盖: ry-ui.css:624-628 隐藏了搜索表单，这里强制显示 */
    .search-collapse {
        display: block !important;
        padding: 10px;
    }

    /* 搜索表单项：改为垂直堆叠 */
    .select-list ul {
        display: flex;
        flex-direction: column;
        padding: 0;
        margin: 0;
    }

    .select-list ul li {
        float: none !important;
        width: 100% !important;
        margin-bottom: 10px;
        display: block;
    }

    /* 搜索标签 — RuoYi 用 <p> 标签 (非 <label>) */
    .select-list ul li p {
        float: none !important;
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 4px;
        font-size: 13px;
        color: #64748b;
        font-weight: 500;
    }

    /* 搜索输入框 — 全宽显示 */
    .select-list ul li input,
    .select-list ul li select,
    .select-list ul li .input-group,
    .select-list ul li .form-control {
        width: 100% !important;
        float: none !important;
        min-height: 40px;
        font-size: 14px !important;
    }

    /* 日期范围 */
    .select-list .select-time {
        width: 100%;
    }

    .select-list .select-time input {
        width: 100% !important;
        min-height: 40px;
    }

    /* 搜索/重置按钮 — 全宽并排 */
    .select-list ul li:last-child {
        display: flex;
        gap: 8px;
    }

    .select-list ul li a.btn,
    .select-list ul li a[onclick*="handleQuery"],
    .select-list ul li a[onclick*="resetQuery"] {
        flex: 1;
        text-align: center;
        min-height: 44px !important;
        line-height: 32px;
        font-size: 14px !important;
        border-radius: 6px;
    }

    /* --- 操作按钮工具栏 --- */
    #toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 10px;
    }

    #toolbar .btn {
        font-size: 12px;
        padding: 6px 10px;
        min-height: 36px;
    }

    /* --- 数据表格：横向滚动 --- */
    .select-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .select-table .fixed-table-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .select-table table {
        min-width: 600px;
    }

    /* Bootstrap Table 表头 */
    .select-table .fixed-table-header {
        overflow-x: hidden;
    }

    /* 表格字体 */
    .select-table table td,
    .select-table table th {
        font-size: 12px;
        padding: 6px 5px;
        white-space: nowrap;
    }

    /* 表格内操作按钮 */
    .select-table table td .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
    }

    .select-table table td .btn-xs,
    .select-table table td .btn-sm {
        min-height: 30px;
        min-width: 30px;
        padding: 4px 6px;
    }

    /* 表格工具栏 */
    .fixed-table-toolbar {
        flex-wrap: wrap;
    }

    .fixed-table-toolbar .columns,
    .fixed-table-toolbar .search {
        margin-bottom: 5px;
    }

    /* 分页器 */
    .fixed-table-pagination {
        flex-wrap: wrap;
    }

    .fixed-table-pagination .pagination-detail,
    .fixed-table-pagination .pagination {
        width: 100%;
        text-align: center;
        margin: 4px 0;
    }

    .fixed-table-pagination .pagination > li > a {
        padding: 6px 10px;
        font-size: 13px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }
}


/* ============================================
   3. 手机端 — Layer 弹窗适配
   ============================================ */
@media (max-width: 767px) {

    /* Layer 弹窗：限制最大宽度 */
    .layui-layer {
        max-width: calc(100vw - 16px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* iframe 类型弹窗：几乎全屏 */
    .layui-layer-iframe {
        width: calc(100vw - 16px) !important;
        left: 8px !important;
    }

    /* 弹窗标题 */
    .layui-layer-title {
        font-size: 14px;
        padding: 0 10px;
    }

    /* 弹窗内容 */
    .layui-layer-content {
        padding: 10px;
    }

    /* 弹窗按钮 */
    .layui-layer-btn a {
        font-size: 13px;
        padding: 6px 15px;
    }
}


/* ============================================
   4. 手机端 — 表单弹窗内部
   ============================================ */
@media (max-width: 767px) {

    /* 水平表单改为垂直排列 */
    .form-horizontal .form-group {
        margin-left: 0;
        margin-right: 0;
    }

    .form-horizontal .control-label,
    .form-horizontal .col-sm-1,
    .form-horizontal .col-sm-2,
    .form-horizontal .col-sm-3,
    .form-horizontal .col-sm-4,
    .form-horizontal .col-sm-5,
    .form-horizontal .col-sm-6,
    .form-horizontal .col-sm-7,
    .form-horizontal .col-sm-8,
    .form-horizontal .col-sm-9,
    .form-horizontal .col-sm-10,
    .form-horizontal .col-sm-11,
    .form-horizontal .col-sm-12 {
        width: 100%;
        float: none;
        padding-left: 10px;
        padding-right: 10px;
    }

    .form-horizontal .control-label {
        text-align: left;
        margin-bottom: 4px;
        padding-top: 0;
    }

    /* 表单元素撑满 */
    .form-horizontal .form-control {
        width: 100%;
    }

    /* 日期选择器宽度 */
    .form-horizontal .input-group {
        width: 100%;
    }

    /* row 布局修复 */
    .form-horizontal .row .col-xs-6,
    .form-horizontal .row .col-sm-6 {
        width: 100%;
    }

    /* 表单按钮栏 */
    .form-horizontal .form-group .col-sm-offset-2,
    .form-horizontal .form-group .col-sm-offset-3 {
        margin-left: 0;
        padding-left: 10px;
    }

    /* iCheck 复选框/单选框 */
    .form-horizontal .iCheck-helper {
        width: 22px;
        height: 22px;
    }
}


/* ============================================
   5. 手机端 — 登录页
   ============================================
   login.html DOM 结构:
     body > div.container > div.container_main(980px)
       > div.main_body(50%, 530px) > div.main_body_right(padding:40px)
         > h2(padding-bottom:60px) + form#signupForm
           > div.input_column(height:60px)
               > div.icons(float:left) + input(width:210px, float:left)
           > div.input_column (验证码行)
               > div.icons + input + div.yzm(width:110px, float:left)
           > button.btn.btn-primary.btn-block(height:60px, margin-top:40px)
   ============================================ */
@media (max-width: 767px) {

    /* A1: 外层容器 — container_main 固定 980px 在手机上溢出 */
    .container {
        padding: 0 10px;
    }

    .container_main {
        width: 100% !important;
        height: auto !important;
    }

    /* A2: 登录卡片 — 50% of 980px = 490px 超出手机屏宽 */
    .main_body {
        width: 100% !important;
        max-width: 400px;
        height: auto !important;
        min-height: auto;
        margin: 0 auto;
        flex-direction: column;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
    }

    /* A3: 右侧内容区 — padding 40px 太大 */
    .main_body_right {
        padding: 25px 20px !important;
        width: 100%;
    }

    /* A4: 标题 — padding-bottom 60px 占太多空间 */
    .main_body_right h2 {
        padding-bottom: 20px !important;
        font-size: 20px !important;
    }

    /* A9: 输入行 — 固定 height:60px 太高, 改为 flex 布局替代 float */
    .input_column {
        height: 48px !important;
        margin-bottom: 12px !important;
        display: flex !important;
        align-items: center;
        overflow: hidden;
    }

    /* A6: icon 区域 — float:left 改为 flex-shrink:0 */
    .input_column .icons {
        flex-shrink: 0;
        width: 40px;
        padding: 10px !important;
        float: none !important;
    }

    .input_column .icons img {
        width: 20px;
        height: 22px;
        object-fit: contain;
    }

    /* A5 + A10: 输入框 — 固定 width:210px + 行内 style="margin:12px" 导致无法自适应 */
    .input_column input.form-control {
        width: auto !important;
        float: none !important;
        margin: 0 !important;
        padding: 10px 6px !important;
        font-size: 14px !important;
        height: 100% !important;
        flex: 1;
        min-width: 0;
    }

    /* A7: 验证码图片区域 — 固定 width:110px float:left */
    .input_column .yzm {
        flex-shrink: 0;
        width: 90px !important;
        height: 36px !important;
        margin: 4px 4px 4px 0 !important;
        float: none !important;
    }

    .input_column .yzm a,
    .input_column .yzm img {
        display: block;
        width: 100%;
        height: 100%;
    }

    /* A8: 登录按钮 — margin-top:40px 太大, height:60px 太高 */
    .btn.btn-primary.btn-block,
    .main_body_right .btn {
        margin-top: 15px !important;
        height: 48px !important;
        font-size: 18px !important;
        line-height: 36px !important;
    }

    /* 表单验证错误提示位置调整 */
    #signupForm label.error {
        font-size: 12px !important;
        top: 14px !important;
        right: 8px !important;
    }

    /* 背景适配 */
    .container {
        background-size: cover !important;
        background-position: center !important;
    }
}


/* ============================================
   6. 手机端 — 仪表盘 / 卡片
   ============================================ */
@media (max-width: 767px) {

    /* 卡片行改为堆叠 */
    .row .col-sm-3,
    .row .col-sm-4,
    .row .col-sm-6 {
        width: 100%;
        padding: 0 10px;
        margin-bottom: 10px;
    }

    /* ibox 卡片间距 */
    .ibox {
        margin-bottom: 10px;
    }

    .ibox-title h5 {
        font-size: 13px;
    }

    .ibox-content {
        padding: 10px;
    }

    /* 统计数字 */
    .widget h2,
    .widget .font-bold {
        font-size: 20px;
    }

    /* 底部 footer */
    .footer {
        font-size: 11px;
        padding: 5px 10px;
    }
}


/* ============================================
   6b. 手机端 — Bootstrap Table 卡片视图优化
   ============================================
   Bootstrap Table 的 mobileResponsive:true 会在手机端
   自动将表格转为卡片视图 (.card-view)。
   这里优化卡片视图的视觉效果。
   ============================================ */
@media (max-width: 767px) {

    /* 卡片视图行 — 每条记录作为一张卡片 */
    .bootstrap-table .fixed-table-body .card-view {
        padding: 6px 12px !important;
    }

    /* 卡片视图标题列 (字段名) */
    .card-view .card-view-title {
        font-weight: 600 !important;
        color: #64748b !important;
        font-size: 12px !important;
        min-width: 80px;
        padding-right: 8px;
    }

    /* 卡片视图值列 */
    .card-view .card-view-value {
        font-size: 13px !important;
        color: #1e293b !important;
        word-break: break-all;
    }

    /* 卡片之间的分隔线 */
    .bootstrap-table .fixed-table-body tbody tr {
        border-bottom: 2px solid #e2e8f0 !important;
        margin-bottom: 8px;
    }

    /* 卡片最后一行不加分隔 */
    .bootstrap-table .fixed-table-body tbody tr:last-child {
        border-bottom: none !important;
    }

    /* 卡片内偶数行轻微背景区分 */
    .bootstrap-table .fixed-table-body tbody tr:nth-child(odd) {
        background-color: #f8fafc;
    }

    /* 卡片视图中的操作按钮 — 全宽显示 */
    .card-view .card-view-value .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .card-view .card-view-value .btn {
        flex: 1;
        min-width: 60px;
        text-align: center;
        min-height: 36px;
        font-size: 12px;
    }

    /* 卡片视图中的标签/徽章 */
    .card-view .card-view-value .label {
        display: inline-block;
        padding: 4px 10px;
        font-size: 12px;
    }

    /* 卡片视图 checkbox — 放大 */
    .card-view .card-view-value input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* 选中行高亮 */
    .bootstrap-table .fixed-table-body tbody tr.selected {
        background-color: rgba(25, 118, 210, 0.08) !important;
        border-left: 3px solid #1976d2;
    }

    /* 卡片视图头部隐藏 */
    .bootstrap-table .fixed-table-header {
        display: none;
    }

    /* 表格容器移除 min-width 限制 (卡片视图不需要横滚) */
    .bootstrap-table.bootstrap-table-card table {
        min-width: unset !important;
    }
}


/* ============================================
   7. 手机端 — Modal 对话框
   ============================================ */
@media (max-width: 767px) {

    .modal-dialog {
        width: calc(100vw - 20px);
        margin: 10px auto;
    }

    .modal-dialog.modal-lg {
        width: calc(100vw - 20px);
    }

    .modal-body {
        padding: 10px;
    }

    .modal-header .modal-title {
        font-size: 15px;
    }
}


/* ============================================
   8. 手机端 — 日期选择器
   ============================================ */
@media (max-width: 767px) {

    .daterangepicker {
        width: calc(100vw - 20px);
        left: 10px !important;
        right: 10px !important;
    }

    .daterangepicker .drp-calendar {
        max-width: 100%;
    }

    .daterangepicker .drp-buttons {
        text-align: center;
    }

    /* laydate 日期选择器 */
    .layui-laydate {
        max-width: calc(100vw - 20px);
    }
}


/* ============================================
   9. 手机端 — Select2 下拉
   ============================================ */
@media (max-width: 767px) {

    .select2-container {
        width: 100% !important;
    }

    .select2-dropdown {
        max-width: calc(100vw - 20px);
    }
}


/* ============================================
   10. 手机端 — TreeTable / TreeView
   ============================================ */
@media (max-width: 767px) {

    .treetable-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .treetable-table table {
        min-width: 500px;
    }
}


/* ============================================
   11. 平板端 (768px - 1024px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1024px) {

    /* 侧边栏默认 mini 模式 */
    body.fixed-sidebar .navbar-static-side {
        width: 70px;
        transition: width 0.2s ease;
    }

    body.fixed-sidebar #page-wrapper {
        margin-left: 70px;
    }

    /* mini 模式下隐藏文字 */
    .sidebar-collapse .nav > li > a .nav-label {
        display: none;
    }

    .sidebar-collapse .nav > li > a .fa.arrow {
        display: none;
    }

    .sidebar-collapse .logo-lg {
        display: none;
    }

    /* hover 展开 */
    body.fixed-sidebar .navbar-static-side:hover {
        width: 220px;
    }

    body.fixed-sidebar .navbar-static-side:hover .nav > li > a .nav-label {
        display: inline;
    }

    body.fixed-sidebar .navbar-static-side:hover .nav > li > a .fa.arrow {
        display: inline;
    }

    body.fixed-sidebar .navbar-static-side:hover .logo-lg {
        display: inline;
    }

    /* 搜索项 2 列排列 */
    .select-list ul li {
        width: 48%;
    }

    /* 通知预警适当缩小 */
    ul.welcome-message > li > a {
        font-size: 11px;
        padding: 10px 8px;
    }

    /* 数据表格 */
    .select-table table td,
    .select-table table th {
        font-size: 12px;
        padding: 6px 5px;
    }
}


/* ============================================
   12. 打印样式优化
   ============================================ */
@media print {

    .navbar-static-side,
    .navbar-static-top,
    .content-tabs,
    .footer,
    #toolbar,
    .search-collapse {
        display: none !important;
    }

    #page-wrapper {
        margin-left: 0;
    }

    .select-table table {
        width: 100%;
        border-collapse: collapse;
    }

    .select-table table td,
    .select-table table th {
        border: 1px solid #333;
        padding: 4px;
    }
}


/* ============================================
   13. 触摸设备优化 (Apple HIG: 最小 44px 触摸目标)
   ============================================ */
@media (hover: none) and (pointer: coarse) {

    /* 侧边栏菜单项 — 44px 触摸目标 */
    .nav > li > a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* 所有按钮 — 至少 44px 高 */
    .btn {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .btn-xs,
    .btn-sm {
        min-height: 36px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    /* 搜索输入框 — 44px 高 */
    .form-control,
    .select-list li input,
    .select-list li select {
        min-height: 44px;
    }

    /* 表格行点击区域 */
    .select-table table td a,
    .select-table table td button {
        min-height: 36px;
        min-width: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 分页器按钮 */
    .pagination > li > a,
    .pagination > li > span {
        min-height: 40px;
        min-width: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* 页签项 */
    .page-tabs-content > a.menuTab {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    /* checkbox / radio 放大 */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }

    /* 滚动条隐藏 (触摸设备用原生滚动) */
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}


/* ============================================
   14. 横屏手机适配
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {

    #content-main {
        height: calc(100vh - 90px);
    }

    .content-tabs {
        height: 30px;
    }

    .content-tabs .page-tabs-content > a {
        padding: 4px 8px;
        font-size: 11px;
    }

    .navbar-static-top {
        min-height: 40px;
    }

    ul.welcome-message > li > a {
        padding: 6px 5px;
        font-size: 10px;
    }
}


/* ============================================
   15. 安全区域适配 (iPhone 刘海屏等)
   ============================================ */
@supports (padding-top: env(safe-area-inset-top)) {

    @media (max-width: 767px) {

        body.fixed-sidebar .navbar-static-side {
            padding-top: env(safe-area-inset-top);
        }

        .navbar-static-top {
            padding-top: env(safe-area-inset-top);
        }

        .footer {
            padding-bottom: env(safe-area-inset-bottom);
        }

        #content-main {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}
