/* ============================================================
 * 小景助手 · 手机端 v4（≤768px）
 * 滴答清单风格：纯白扁平清单、细分隔线、极简顶栏、右下悬浮加号。
 * 本文件在 style.css 之后加载，只含手机端规则；桌面端零影响。
 * 配套脚本：js/mobile-nav.js（底栏）、js/mobile-fab.js（悬浮加号 + 底部弹层）、
 *           js/mobile-home.js（工作台 / 任务 / 案件 / 看板 / 日程重组）
 * ============================================================ */

/* 桌面兜底：手机端专属节点一律不显示 */
.mobile-tabbar, .mobile-fab, .m-sheet, .mhome, .m-tabs, .m-searchrow, .m-filters, .m-seg { display: none; }

@media (max-width: 768px) {
    :root { --topbar-height: 52px; }

    /* ---------- 基础（自 style.css PWA 补丁迁入） ---------- */
    .main-content { min-width: 0; }
    .dashboard-grid > *, .dashboard-grid-2col > *, .chart-grid > *,
    .stat-cards > *, .analytics-cards > *, .team-grid > * { min-width: 0; }
    .card-header { flex-wrap: wrap; row-gap: 8px; }
    .dash-schedule-actions { flex-wrap: wrap; }
    .users-table-wrap, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav-item { min-height: 44px; }
    .case-detail-tab { min-height: 40px; }
    .users-table td .btn, .table-actions .btn, .table-actions button { min-width: 36px; min-height: 36px; }
    input, select, textarea { font-size: 16px; }
    .modal { margin: 8px; max-width: calc(100% - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
    .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .notification-panel { max-width: 100vw; }
    .trial-row { flex-wrap: wrap; }
    .trial-row > div:nth-child(3) { flex: 0 0 100%; justify-content: flex-start !important; margin-top: 2px; }
    .trial-row > div:nth-child(3) .btn { min-height: 36px; }
    .trial-cand { flex-wrap: wrap; }
    .trial-cand .btn { min-height: 36px; }

    /* ---------- 顶栏：只留菜单、标题、搜索、通知 ---------- */
    .topbar { height: 52px; padding: 0 6px 0 6px; background: #fff; border-bottom: 1px solid #f0f1f3; box-shadow: none; }
    .topbar-left { gap: 2px; min-width: 0; }
    .menu-btn { width: 40px; height: 40px; border: none; background: none; color: #1f2328; font-size: 20px; border-radius: 10px; }
    .page-title { font-size: 17px; font-weight: 600; color: #1f2328; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-right { gap: 0; }
    .topbar-btn, .topbar-btn.notification-btn, #mobileSearchBtn {
        width: 40px; height: 40px; min-width: 40px; padding: 0 !important;
        border: none; background: none; color: #1f2328; font-size: 19px;
        justify-content: center; border-radius: 10px; box-shadow: none;
    }
    .topbar-btn:active { background: #f3f4f6; }
    #quickNoteBtn, #addCaseBtn, #dataUpdatedAt { display: none !important; }
    .notification-btn .badge { top: 4px; right: 4px; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; }
    .topbar-search:not(.cases-search) { box-shadow: none; border-bottom: 1px solid #f0f1f3; padding: 8px 12px; }
    .topbar-search:not(.cases-search) input { border-radius: 10px; background: #f3f4f6; border: none; height: 36px; }

    /* ---------- 页面容器：白底，清单页去掉左右内边距 ---------- */
    .page-container { background: #fff; padding: 0 0 calc(80px + env(safe-area-inset-bottom)); }
    .page { padding: 12px; }
    #page-dashboard, #page-tasks, #page-cases, #page-kanban, #page-schedule { padding: 0; }
    .card { border-radius: 12px; box-shadow: none; border: 1px solid #f0f1f3; }

    /* ---------- 底部标签栏（js/mobile-nav.js 注入） ---------- */
    .mobile-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 190;
        background: #fff; border-top: 1px solid #f0f1f3; box-shadow: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-tab {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px; min-height: 56px; padding: 6px 2px 4px; background: none; border: none; cursor: pointer;
        color: #8a8f98; font-size: 10px; line-height: 1.2; font-family: inherit; -webkit-tap-highlight-color: transparent;
    }
    .mobile-tab i { font-size: 21px; }
    .mobile-tab.active { color: var(--primary); font-weight: 600; }

    /* ---------- 悬浮加号 + 底部弹层（js/mobile-fab.js） ---------- */
    .mobile-fab {
        display: flex; position: fixed; right: 16px; bottom: calc(74px + env(safe-area-inset-bottom));
        width: 52px; height: 52px; border-radius: 50%; border: none; z-index: 150;
        background: var(--primary); color: #fff; font-size: 24px; align-items: center; justify-content: center;
        box-shadow: 0 6px 16px rgba(26, 86, 219, .32); cursor: pointer; -webkit-tap-highlight-color: transparent;
        transition: transform .15s;
    }
    .mobile-fab:active { transform: scale(.94); }
    .mobile-fab.hidden { display: none; }

    .m-sheet { display: block; position: fixed; inset: 0; z-index: 195; visibility: hidden; }
    .m-sheet.open { visibility: visible; }
    .m-sheet-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .35); opacity: 0; transition: opacity .18s; }
    .m-sheet.open .m-sheet-mask { opacity: 1; }
    .m-sheet-panel {
        position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
        border-radius: 16px 16px 0 0; padding: 6px 0 calc(12px + env(safe-area-inset-bottom));
        max-height: 80vh; overflow-y: auto; transform: translateY(100%); transition: transform .22s ease;
    }
    .m-sheet.open .m-sheet-panel { transform: translateY(0); }
    .m-sheet-panel::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 2px; background: #e5e7eb; margin: 4px auto 8px; }
    .m-sheet-head { display: flex; align-items: center; padding: 4px 16px 8px; font-size: 15px; font-weight: 600; color: #1f2328; }
    .m-sheet-head .m-sheet-close { margin-left: auto; width: 32px; height: 32px; border: none; background: none; color: #8a8f98; font-size: 16px; }
    .m-sheet-item {
        display: flex; align-items: center; gap: 14px; padding: 13px 20px; font-size: 15px; color: #1f2328;
        background: none; border: none; width: 100%; text-align: left; font-family: inherit; cursor: pointer;
    }
    .m-sheet-item:active { background: #f3f4f6; }
    .m-sheet-item i { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; background: #eef2ff; color: var(--primary); }
    .m-sheet-item small { margin-left: auto; font-size: 12px; color: #9ca3af; }

    /* 筛选弹层：原有 <select> 挪进 .m-filter-body 后按行排布（打开时整块被挪进 .m-sheet） */
    .m-filter-body { padding: 4px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
    .m-filter-body .filter-select, .m-filter-body .multi-filter, .m-filter-body .multi-filter-btn {
        width: 100%; min-height: 44px; border-radius: 10px; font-size: 15px; margin: 0;
    }
    .m-filter-body .multi-filter { position: relative; }
    .m-filter-body .multi-filter-panel { position: static; width: 100%; margin-top: 6px; max-height: 240px; overflow-y: auto; box-shadow: none; border: 1px solid #f0f1f3; }
    .m-filter-body .m-filters-extra { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
    .m-filter-body .m-filters-extra .btn { min-height: 40px; border-radius: 10px; }
    .m-filter-body .schedule-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0 0; margin: 0; font-size: 12px; }

    /* ---------- 通用：文字 tab 条 / 搜索行 / 分组头 / 清单行 ---------- */
    .m-tabs {
        display: flex; align-items: center; height: 44px; padding: 0 4px 0 12px;
        border-bottom: 1px solid #f0f1f3; overflow-x: auto; scrollbar-width: none; background: #fff;
        position: sticky; top: 0; z-index: 8;
    }
    .m-tabs::-webkit-scrollbar { display: none; }
    .m-tab {
        flex-shrink: 0; position: relative; padding: 0 10px; height: 44px; line-height: 44px;
        font-size: 14px; color: #6b7280; white-space: nowrap; background: none; border: none; font-family: inherit; cursor: pointer;
    }
    .m-tab small { font-size: 12px; margin-left: 2px; color: #9ca3af; }
    .m-tab.on { color: var(--primary); font-weight: 600; }
    .m-tab.on small { color: var(--primary); }
    .m-tab.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 1px; background: var(--primary); }
    .m-tab.warn { color: #d97706; }
    .m-tab.danger { color: #dc2626; }
    .m-tabs .m-sp { flex: 1; min-width: 8px; }
    .m-filt {
        flex-shrink: 0; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
        font-size: 17px; color: #1f2328; background: none; border: none; border-radius: 10px; position: relative;
    }
    .m-filt.on::after { content: ''; position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

    .m-searchrow { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; background: #fff; }
    .m-searchrow .topbar-search.cases-search {
        flex: 1; margin: 0 !important; width: auto; height: 36px; border-radius: 10px; background: #f3f4f6; border: none;
        display: flex; align-items: center; padding: 0 12px; gap: 8px; color: #9ca3af;
    }
    .m-searchrow .topbar-search.cases-search i { position: static; font-size: 14px; color: #9ca3af; }
    .m-searchrow .topbar-search.cases-search input { flex: 1; border: none; background: none; height: 36px; font-size: 15px; padding: 0; width: 100%; box-shadow: none; }

    .m-sec {
        display: flex; align-items: center; padding: 14px 16px 6px; font-size: 13px; font-weight: 700; color: #6b7280; letter-spacing: .3px;
        background: #fff;
    }
    .m-sec .m-n { margin-left: 6px; font-weight: 500; color: #9ca3af; }
    .m-sec .m-more { margin-left: auto; font-weight: 500; color: var(--primary); font-size: 12px; display: flex; align-items: center; gap: 2px; padding: 4px 0 4px 10px; }
    .m-sec .m-chev { margin-left: auto; color: #c4c8cf; font-size: 13px; transition: transform .15s; }
    .m-sec.danger { color: #dc2626; }
    .m-sec.warn { color: #d97706; }
    .m-sec.muted { color: #9ca3af; }
    .m-sec.sticky { position: sticky; top: 44px; z-index: 6; }
    .m-sec.clickable { cursor: pointer; }
    .m-sec.collapsed .m-chev { transform: rotate(-90deg); }

    .m-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px 0; cursor: pointer; }
    .m-row:active { background: #fafafa; }
    .m-bd { flex: 1; min-width: 0; padding-bottom: 12px; border-bottom: 1px solid #f0f1f3; }
    .m-row:last-child .m-bd, .m-row.last .m-bd { border-bottom: none; }
    .m-t { font-size: 15px; font-weight: 600; color: #1f2328; line-height: 1.35; word-break: break-word; }
    .m-t.norm { font-weight: 500; }
    .m-t.done { color: #9ca3af; text-decoration: line-through; font-weight: 500; }
    .m-t .m-gavel { color: #dc2626; margin-right: 4px; font-size: 13px; }
    .m-m { margin-top: 3px; font-size: 12px; color: #8a8f98; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; line-height: 1.5; }
    .m-m > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .m-m .red { color: #dc2626; font-weight: 600; }
    .m-m .org { color: #d97706; font-weight: 600; }
    .m-m .dot::before { content: '·'; color: #d1d5db; margin-right: 8px; }
    .m-rt { flex-shrink: 0; font-size: 13px; color: #8a8f98; padding-top: 2px; }
    .m-rt.red { color: #dc2626; font-weight: 700; }
    .m-rt.org { color: #d97706; font-weight: 700; }
    .m-bar { flex-shrink: 0; width: 3px; border-radius: 2px; align-self: stretch; margin-bottom: 12px; background: #d97706; }
    .m-bar.red { background: #dc2626; }
    .m-empty { padding: 22px 16px; text-align: center; color: #9ca3af; font-size: 13px; }
    .m-empty i { margin-right: 6px; }
    .m-more-row { text-align: center; font-size: 13px; color: var(--primary); padding: 10px; cursor: pointer; }

    /* 圆形勾选框：边框色 = 优先级（紧急红 / 高橙 / 中蓝 / 低灰） */
    .m-ck {
        flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #9ca3af; margin-top: 1px;
        display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; position: relative;
    }
    .m-ck::after { content: ''; position: absolute; inset: -10px; }   /* 放大触控热区 */
    .m-ck.p-紧急 { border-color: #dc2626; }
    .m-ck.p-高 { border-color: #f59e0b; }
    .m-ck.p-中 { border-color: var(--primary); }
    .m-ck.p-低 { border-color: #c4c8cf; }
    .m-ck.done { background: #c4c8cf; border-color: #c4c8cf; }

    /* 状态小 chip */
    .m-chip { flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; line-height: 16px; white-space: nowrap; background: #f3f4f6; color: #6b7280; }
    .m-chip.庭审阶段 { background: #eef2ff; color: var(--primary); }
    .m-chip.已立案 { background: #e0f2fe; color: #0369a1; }
    .m-chip.执行阶段 { background: #ecfdf5; color: #059669; }
    .m-chip.待接案 { background: #fff7ed; color: #d97706; }
    .m-chip.已结案 { background: #f3f4f6; color: #9ca3af; }

    /* ---------- 工作台（律师端） ---------- */
    .mhome { display: block; }
    .mhome-head { padding: 14px 16px 4px; }
    .mhome-date { font-size: 26px; font-weight: 800; color: #1f2328; letter-spacing: .3px; display: flex; align-items: baseline; gap: 8px; }
    .mhome-week { font-size: 14px; font-weight: 600; color: #6b7280; }
    .mhome-sum { margin-top: 2px; font-size: 13px; color: #8a8f98; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    .mhome-sum .mh-dot { color: #d1d5db; }
    .mhome-sum .mh-alert { color: #dc2626; font-weight: 700; }
    .mhome-dayhead { padding: 12px 16px 0; font-size: 12px; font-weight: 700; color: #6b7280; }
    .mhome-dayhead.today { color: var(--primary); }
    .mhome-tl { display: flex; padding: 0 16px; cursor: pointer; }
    .mhome-tl:active { background: #fafafa; }
    .mhome-tl-time { width: 46px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: #6b7280; padding-top: 12px; font-variant-numeric: tabular-nums; }
    .mhome-tl-rail { width: 18px; flex-shrink: 0; position: relative; }
    .mhome-tl-rail::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1.5px; margin-left: -.75px; background: #e5e7eb; }
    .mhome-tl-dot { position: absolute; left: 50%; top: 17px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--primary); }
    .mhome-tl-dot.trial { background: #dc2626; box-shadow: 0 0 0 3px #fee2e2; }
    .mhome-tl-bd { flex: 1; min-width: 0; padding: 12px 0 12px 8px; border-bottom: 1px solid #f0f1f3; }
    .mhome-tl.last .mhome-tl-bd { border-bottom: none; }
    .mhome-stats { display: flex; margin: 6px 16px 0; border-top: 1px solid #f0f1f3; padding: 12px 0 4px; }
    .mhome-stats > div { flex: 1; text-align: center; cursor: pointer; }
    .mhome-stats b { display: block; font-size: 20px; font-weight: 700; color: #1f2328; font-variant-numeric: tabular-nums; }
    .mhome-stats b.red { color: #dc2626; }
    .mhome-stats span { font-size: 11px; color: #8a8f98; }
    /* 桌面工作台的统计卡与双列网格在手机端整体隐藏，信息已由上面的清单覆盖 */
    #page-dashboard.mhome-on .stat-cards, #page-dashboard.mhome-on .dashboard-grid-2col { display: none; }

    /* ---------- 任务中心 ---------- */
    #page-tasks.m-on .cases-toolbar { display: none; }
    #page-tasks.m-on .task-req-banner { margin: 10px 12px 0; }
    #page-tasks.m-on .task-list-header { display: none !important; }
    #page-tasks .task-list.mtask-grouped { background: transparent; border: none; border-radius: 0; padding: 0; }
    #page-tasks .task-list.mtask-grouped > .task-item { display: none; }
    .mtask-group.collapsed .m-row { display: none; }
    #page-tasks .table-pager { padding: 12px 16px; }

    /* ---------- 案件列表 ---------- */
    #page-cases.m-on .cases-toolbar { display: none; }
    #page-cases .m-on .cases-table { display: none; }
    #page-cases .m-on .req-tip { margin: 10px 12px 0; }
    .mcase-row .m-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .mcase-head { display: flex; gap: 10px; align-items: flex-start; }
    .mcase-head .m-t { flex: 1; }
    #page-cases .table-pager { padding: 12px 16px; }

    /* ---------- 案件看板：分段切换 + 单列竖排 ---------- */
    .m-seg { display: flex; }
    #page-kanban.m-on .kanban-header { display: none; }
    .kanban-board.m-seg-on { display: block; overflow: visible; min-height: 0; padding: 0; gap: 0; }
    .kanban-board.m-seg-on .kanban-column { display: none; width: 100%; max-width: none; min-width: 0; background: none; border: none; border-radius: 0; padding: 0; }
    .kanban-board.m-seg-on .kanban-column.m-active { display: block; }
    .kanban-board.m-seg-on .column-header { display: none; }
    .kanban-board.m-seg-on .column-body { padding: 0; min-height: 0; max-height: none; overflow: visible; }
    .kanban-board.m-seg-on .kanban-card { border: none; border-radius: 0; box-shadow: none; margin: 0; padding: 12px 16px; border-bottom: 1px solid #f0f1f3; background: #fff; }
    .kanban-board.m-seg-on .kanban-card-header { margin-bottom: 4px; }
    .kanban-board.m-seg-on .kanban-card-title { font-size: 15px; font-weight: 600; color: #1f2328; }
    .kanban-board.m-seg-on .kanban-card-client { font-size: 12px; color: #8a8f98; }
    .kanban-board.m-seg-on .kanban-card-footer { border-top: none; padding-top: 4px; margin-top: 0; }
    .kanban-board.m-seg-on .empty-state { padding: 40px 16px; }

    /* ---------- 日程 ---------- */
    #page-schedule.m-on .schedule-header { flex-direction: row; align-items: center; justify-content: space-between; padding: 8px 12px 4px; margin: 0; gap: 8px; }
    #page-schedule.m-on .schedule-nav { gap: 4px; }
    #page-schedule.m-on .schedule-nav .btn { min-height: 34px; padding: 0 10px; border: none; background: none; color: #1f2328; box-shadow: none; }
    #page-schedule.m-on .schedule-title { font-size: 15px; font-weight: 700; margin: 0 4px; white-space: nowrap; }
    #page-schedule.m-on .schedule-actions { gap: 4px; }
    #page-schedule.m-on .schedule-actions > .btn { display: none; }
    #page-schedule.m-on .schedule-view-toggle { display: flex; background: #f3f4f6; border-radius: 9px; padding: 2px; gap: 0; }
    #page-schedule.m-on .schedule-view-toggle .filter-btn { border: none; background: none; padding: 5px 10px; font-size: 12px; border-radius: 7px; min-height: 0; color: #6b7280; }
    #page-schedule.m-on .schedule-view-toggle .filter-btn.active { background: #fff; color: #1f2328; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
    #page-schedule.m-on > .schedule-legend { display: none; }
    /* 月视图压扁：只显示日期数字和事件圆点 */
    #page-schedule.m-on .calendar-grid { border: none; border-radius: 0; border-bottom: 1px solid #f0f1f3; }
    #page-schedule.m-on .calendar-weekdays { background: none; border-bottom: none; }
    #page-schedule.m-on .calendar-weekday { padding: 6px 0 2px; font-size: 11px; color: #9ca3af; }
    #page-schedule.m-on .calendar-day { min-height: 48px; padding: 4px 0 2px; border: none; text-align: center; display: flex; flex-direction: column; align-items: center; }
    #page-schedule.m-on .calendar-day.other-month { background: none; }
    #page-schedule.m-on .calendar-day.today { background: none; }
    #page-schedule.m-on .day-number { font-size: 14px; margin: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
    #page-schedule.m-on .day-number i { display: none; }
    #page-schedule.m-on .calendar-day.has-conflict .day-number { color: #dc2626; }
    #page-schedule.m-on .day-events { flex-direction: row; justify-content: center; gap: 3px; margin-top: 3px; height: 5px; }
    #page-schedule.m-on .day-event-dot { width: 5px; height: 5px; padding: 0; border-radius: 50%; overflow: hidden; outline: none !important; }
    #page-schedule.m-on .day-event-dot:nth-child(n+4) { display: none; }
    #page-schedule.m-on .day-event-text, #page-schedule.m-on .day-event-time-label { display: none; }
    /* 周视图：去卡片化 */
    #page-schedule.m-on .week-view { border: none; border-radius: 0; box-shadow: none; }
    #page-schedule.m-on .week-event-item { border-radius: 0; box-shadow: none; background: #fff; }
    /* 列表模式（mobile-home.js 追加） */
    .msch-list { padding-top: 2px; }
    .msch-time { width: 46px; flex-shrink: 0; font-size: 13px; font-weight: 600; color: #374151; font-variant-numeric: tabular-nums; padding-top: 2px; }
    .msch-conflict { font-size: 10px; font-weight: 600; color: #b91c1c; background: #fee2e2; border-radius: 8px; padding: 1px 6px; white-space: nowrap; margin-left: 4px; }

    /* ---------- 客户工作台：结构不动，只统一视觉规范（沿用 v3） ---------- */
    .cdash-hero { border-radius: 14px; padding: 20px; }
    .cdash-hero-hi { font-size: 19px; }
    .cdash-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .cdash-stat { padding: 12px 14px; border-radius: 12px; gap: 10px; }
    .cdash-stat-icon { width: 38px; height: 38px; border-radius: 10px; font-size: 15px; }
    .cdash-case { border-radius: 12px; }
    .cdash { gap: 14px; }
}
