/* ============================================================
   LawFirm OS · 多屏自适应 v3（响应式层）
   加载顺序：app.css → v3.css → video.css → responsive.css
   仅在窄屏 / 超宽屏覆盖默认布局；桌面端视觉保持原样。
   断点：≥1600 大屏 / ≤1200 中小桌面 / ≤960 平板 / ≤768 手机 / ≤480 小屏手机
   ============================================================ */

/* ---------- 全局防溢出（所有屏幕） ---------- */
html, body, #app { max-width: 100%; overflow-x: hidden; }
body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, video, canvas, svg, iframe { max-width: 100%; }
.shell, .main, .content, .portal-shell, .portal-main { min-width: 0; }
.content, .portal-main { overflow-x: hidden; }
/* 表格始终允许横向滚动，避免列宽撑破卡片 */
.table-wrap, .card-body { overflow-x: auto; }
.table-wrap .el-table, .card-body > .el-table { min-width: 620px; }
.el-table .cell { word-break: break-word; }

/* 移动端专用控件：桌面隐藏，窄屏由媒体查询开启 */
.mob-menu-btn, .side-close { display: none; }
.mob-menu-btn {
  width: 36px; height: 36px; flex: none; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 19px; line-height: 1; cursor: pointer;
  color: var(--navy); background: #eef3f9; border: 1px solid #dce6f0; user-select: none;
}
.mob-menu-btn:active { background: #dce8f5; }
.side-close {
  position: absolute; right: 12px; top: 26px; width: 28px; height: 28px;
  align-items: center; justify-content: center; border-radius: 8px; cursor: pointer;
  color: rgba(255,255,255,.8); background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16); font-size: 13px; z-index: 4;
}

/* ---------- ≥1600 大屏 ---------- */
@media (min-width: 1600px) {
  .sidebar { width: 280px; }
  .content { padding: 24px 32px 48px; }
  .cp-modules { grid-template-columns: repeat(6, 1fr); }
  .portal-main { max-width: 1320px; }
}

/* ---------- ≤1200 中小桌面 ---------- */
@media (max-width: 1200px) {
  .content { padding: 16px 18px 36px; }
  .cp-grid, .cp-main-grid { grid-template-columns: minmax(0, 1fr) 280px; }
  .cp-grid2, .v3-split, .v3-contract-edit { grid-template-columns: 1fr 1fr; }
  .vr-stage { grid-template-columns: 1.45fr 1fr; }
  .topbar { padding: 0 18px; }
}

/* ---------- ≤960 平板（侧栏自动收为图标条） ---------- */
@media (max-width: 960px) {
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .form-grid, .grid-2, .grid-3, .cp-grid, .cp-grid2, .cp-main-grid,
  .v3-split, .v3-contract-edit, .chat-layout, .vr-stage, .vr-cards,
  .ws-top, .vc-tests, .req-grid, .map-grid { grid-template-columns: 1fr !important; }
  .cp-kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .cp-modules { grid-template-columns: repeat(3, 1fr) !important; }
  .role-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .vc-grid, .uv-diag-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .chat-layout { height: auto; }
  .chat-side { height: 240px; }
  .chat-main { height: 440px; }
  .portal-top { padding: 0 14px; }
  .portal-main { padding: 18px 16px 44px; }
  .filter-bar { gap: 8px; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .kv { grid-template-columns: 92px 1fr; }
  .nt-grid { grid-template-columns: 1fr !important; }
}

/* ---------- ≤768 手机：侧边栏改抽屉 + 顶部汉堡 ---------- */
@media (max-width: 768px) {
  /* 移动端汉堡按钮 / 遮罩 */
  .mob-menu-btn { display: flex !important; }
  .side-mask { display: block !important; }
  .side-mask {
    position: fixed; inset: 0; z-index: 2090;
    background: rgba(6, 18, 33, .52); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .24s ease;
  }
  .side-mask.show { opacity: 1; pointer-events: auto; }

  /* 侧栏脱离文档流，默认滑出屏幕；drawer-open 时滑入 */
  .shell > .sidebar,
  .shell > .sidebar.mini {
    position: fixed !important; top: 0; left: 0; bottom: 0; z-index: 2100;
    width: 280px !important; max-width: 84vw; height: 100vh; height: 100dvh;
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1), width .2s;
    box-shadow: 8px 0 34px rgba(4, 14, 28, .34);
  }
  .shell > .sidebar.drawer-open,
  .shell > .sidebar.mini.drawer-open { transform: translateX(0); }

  /* 抽屉内强制恢复完整文字菜单（覆盖 mini / 960 断点隐藏规则） */
  .shell > .sidebar .brand-block { padding: 0 18px !important; justify-content: flex-start !important; }
  .shell > .sidebar .brand-txt,
  .shell > .sidebar .mg-label,
  .shell > .sidebar .mg-count,
  .shell > .sidebar .mg-arrow,
  .shell > .sidebar .mg-bar,
  .shell > .sidebar .menu-item .ml,
  .shell > .sidebar .menu-item .mb,
  .shell > .sidebar .sidebar-foot { display: block !important; }
  .shell > .sidebar .mg-icon { display: none !important; }
  .shell > .sidebar .menu-group {
    justify-content: flex-start !important; padding: 13px 12px 9px !important; margin: 0 2px !important;
  }
  .shell > .sidebar .menu-item { justify-content: flex-start !important; padding: 10px 11px !important; }
  .shell > .sidebar .menu-item .mi { width: 30px !important; height: 30px !important; font-size: 15px !important; }
  .shell > .sidebar .side-collapse { display: none !important; }
  .shell > .sidebar .menu-scroll { padding-bottom: 28px; }
  .side-close { display: flex !important; }

  /* 顶栏 */
  .topbar { height: 56px; padding: 0 12px; gap: 10px; }
  .topbar-title { font-size: 15px; }
  .topbar-crumb, .top-actions > .muted { display: none !important; }
  .top-actions { gap: 8px; }
  .user-chip .un, .user-chip .ur { display: none !important; }
  .user-chip { padding: 3px; }
  .avatar { width: 30px; height: 30px; }
  .content { padding: 12px 12px 36px; }
  .page-head h1 { font-size: 18px; }
  .page-desc { font-size: 11.5px; }
  .page-actions .el-button { margin-bottom: 4px; }

  /* 栅格：一律单列 / 双列紧凑 */
  .grid-2, .grid-3, .grid-4, .stat-grid, .form-grid,
  .v3-split, .v3-contract-edit, .cp-grid, .cp-grid2, .cp-main-grid,
  .chat-layout, .vr-stage, .vr-cards, .req-grid, .map-grid,
  .role-grid, .ws-top, .vc-tests, .vc-grid, .uv-diag-grid { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .nt-grid { grid-template-columns: 1fr !important; }
  .cp-kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .cp-modules { grid-template-columns: repeat(2, 1fr) !important; }
  .cp-trend-row { grid-template-columns: repeat(3, 1fr) !important; }
  .cp-case-kv { grid-template-columns: 84px 1fr !important; }
  .stat-card { padding: 12px 13px; }
  .stat-value { font-size: 21px; }
  .card-head, .card-body { padding-left: 13px; padding-right: 13px; }
  .card { margin-bottom: 12px; }
  .kv { grid-template-columns: 84px 1fr; font-size: 12px; }

  /* 表格 / 表单 / 弹层 */
  .table-wrap .el-table, .card-body > .el-table { min-width: 620px; }
  .el-dialog {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
  }
  .el-dialog__body { max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); overflow-y: auto; padding: 14px; }
  .el-drawer { width: 100% !important; max-width: 100% !important; }
  .el-message-box { width: calc(100vw - 32px) !important; max-width: calc(100vw - 32px) !important; }
  .el-form-item__label { font-size: 12.5px; }
  .el-select, .el-date-editor, .el-cascader, .el-input-number { width: 100% !important; }
  .el-input__inner, .el-textarea__inner { font-size: 16px; } /* iOS 聚焦不缩放 */
  .el-tabs__nav { flex-wrap: nowrap; overflow-x: auto; }
  .pager { justify-content: center; }
  .filter-bar > * { max-width: 100%; }
  .oa-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .chart-bars, .chart-x { gap: 6px; }

  /* 登录页：品牌区隐藏，表单全宽，页脚回到文档流
     注意：此处必须用 block 布局 —— 列向 flex 父容器 + flex 面板居中会让
     width:100% 的表单盒宽度塌缩并偏移出屏幕（真机 Chrome/微信内核均复现） */
  .login-wrap { display: flex; flex-direction: column; height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .login-brand { display: none; }
  .login-panel { display: block; flex: 1; padding: 26px 18px 18px; min-height: 0; }
  .login-box { display: block; width: 100%; max-width: 420px; margin: 0 auto; }
  .login-box h2 { font-size: 22px; }
  .login-tabs div { font-size: 13px; padding: 10px 0; }
  .login-btn { height: 46px; font-size: 15px; }
  .demo-box { margin-top: 16px; }
  .login-foot { position: static !important; order: 3; padding: 14px 18px 22px !important; text-align: center; }
  .login-tech-row { flex-wrap: wrap; gap: 4px 8px; justify-content: center; white-space: normal; }
  .login-icp-line { white-space: normal; }
  .login-legal { margin-top: 16px; }

  /* 当事人门户 */
  .portal-top { height: auto; min-height: 54px; padding: 9px 12px; flex-wrap: wrap; gap: 8px; }
  .portal-top .pt-name { font-size: 13px; }
  .portal-top .pt-tag { display: none; }
  .portal-nav {
    width: 100%; margin-left: 0 !important; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap;
    padding-bottom: 3px; scrollbar-width: none;
  }
  .portal-nav::-webkit-scrollbar { display: none; }
  .portal-nav div { flex: none; padding: 7px 11px; font-size: 12.5px; }
  .portal-main { padding: 14px 12px 40px; }
  .portal-hero { padding: 18px; border-radius: 10px; }
  .portal-hero h1 { font-size: 18px; }
  .portal-hero p { font-size: 12px; }
  .portal-hero .ph-stats { gap: 16px 22px; flex-wrap: wrap; margin-top: 16px; }
  .portal-hero .ph-stats b { font-size: 18px; }
  .case-card { padding: 14px; }
  .cc-head { flex-wrap: wrap; }
  .cc-right { margin-left: 0; text-align: left; width: 100%; }
  .upload-zone { padding: 16px; }

  /* 聊天 / 视频 */
  .chat-layout { height: auto; }
  .chat-side { height: 210px; }
  .chat-main { height: 420px; }
  .cm-msgs { padding: 12px; }
  .chat-bubble { max-width: 88%; }
  .vr-box { aspect-ratio: 16 / 9; }
  .vr-ctrl { gap: 6px; }
  .rc-head { flex-wrap: wrap; }
  .ws-memo-head { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .ws-memo-head .muted { margin-left: 0; flex: 1 1 100%; line-height: 1.6; }
  .ws-memo-head .el-button { margin-left: 0 !important; }
  .ws-cal-grid, .ws-cal-week { gap: 2px; }
}

/* ---------- ≤480 小屏手机 ---------- */
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .client-way-tabs > div { font-size: 11.5px; padding: 9px 2px; }
  .stat-grid { grid-template-columns: 1fr !important; }
  .cp-kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .cp-modules { grid-template-columns: 1fr !important; }
  .content { padding: 10px 10px 32px; }
  .page-head { margin-bottom: 12px; }
  .brand-txt b { font-size: 13px; }
  .topbar-title { font-size: 14px; }
  .el-dialog { width: calc(100vw - 16px) !important; max-width: calc(100vw - 16px) !important; margin: 8px auto !important; }
  .login-panel { padding: 20px 14px 14px; }
  .demo-chip { font-size: 11px; }
  .portal-hero::after { display: none; }
}

/* ---------- ≤360 超窄屏 ---------- */
@media (max-width: 360px) {
  .grid-4, .stat-grid { grid-template-columns: 1fr !important; }
  .cp-kpis { grid-template-columns: 1fr !important; }
}

/* ---------- 横屏矮屏（手机横屏） ---------- */
@media (max-height: 480px) and (max-width: 900px) {
  .topbar { height: 46px; }
  .sidebar .brand-block { height: 58px; }
  .login-panel { padding-top: 14px; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .side-mask, .mob-menu-btn, .topbar, .portal-nav { display: none !important; }
  .shell, .main, .content { display: block !important; height: auto !important; overflow: visible !important; }
  .content { padding: 0; }
}

/* ============================================================
   多屏自适应 v4（触屏深度适配）
   ============================================================ */

/* 触屏设备：加大可点区域 + 顺滑滚动 */
@media (pointer: coarse) {
  .menu-item { padding: 12px 11px; }
  .menu-item .mi { width: 32px; height: 32px; }
  .mob-menu-btn { width: 40px; height: 40px; font-size: 21px; }
  .icon-btn { width: 40px; height: 40px; font-size: 19px; }
  .portal-nav div { padding: 9px 13px; }
  .table-wrap, .card-body { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
}

/* ≤768 手机：表格紧凑化 / 弹层防溢出 / 控件触控优化 */
@media (max-width: 768px) {
  .el-table { font-size: 11.5px; }
  .el-table .el-table__cell { padding: 6px 4px; }
  .el-table th.el-table__cell { font-size: 11px; }
  .table-wrap .el-table, .card-body > .el-table { min-width: 540px; }
  .el-button { min-height: 34px; }
  .el-button--small { min-height: 30px; }
  .page-actions .el-button + .el-button { margin-left: 6px; }
  .el-popper.el-picker-panel, .el-popper.el-date-picker, .el-popper.el-date-range-picker { max-width: calc(100vw - 16px) !important; overflow-x: auto; }
  .el-picker-panel__body-wrapper { max-width: calc(100vw - 20px); overflow-x: auto; }
  .el-date-table { max-width: calc(100vw - 32px); }
  .el-message { width: calc(100vw - 32px) !important; max-width: calc(100vw - 32px) !important; }
  .el-select-dropdown { max-width: calc(100vw - 20px) !important; }
  .el-dropdown-menu { max-height: 60vh; overflow-y: auto; }
  .el-descriptions { font-size: 12px; }
  .el-descriptions__label { min-width: 76px; }
  .el-drawer__header { padding: 14px 16px; font-size: 14.5px; }
  .drawer-body { padding: 14px 16px 40px; }
  .side-mask { z-index: 2090; }
  .shell > .sidebar { z-index: 2100; }
  /* 顶栏消息/用户弹出层挂载到 body 时防溢出 */
  .el-dropdown__popper, .el-tooltip__popper { max-width: calc(100vw - 16px); }
  /* 卡片内横向滚动表格底部留白，避免贴边难拖 */
  .table-wrap { padding-bottom: 6px; }
  .flow-node { min-width: 58px; }
  .flow-node .fn-label { font-size: 9.5px; }
  .lb-logo { border-radius: 10px; }
}

/* ≤480 小屏：进一步紧凑 */
@media (max-width: 480px) {
  .el-table { font-size: 11px; }
  .el-table .cell { line-height: 1.45; }
  .table-wrap .el-table, .card-body > .el-table { min-width: 500px; }
  .stat-value { font-size: 19px; }
  .card-head h3 { font-size: 13.5px; }
  .topbar { height: 52px; }
  .content { padding: 10px 10px 30px; }
}

/* 材料清单下发：材料项行，桌面横排，移动端逐项换行 */
.req-item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.req-item-row .it-name { flex: 1.3 1 0; min-width: 0; }
.req-item-row .it-note { flex: 1 1 0; min-width: 0; }
@media (max-width: 768px) {
  .req-item-row { flex-wrap: wrap; }
  .req-item-row .it-name, .req-item-row .it-note { flex: 1 1 100%; width: 100%; }
}
