/* ══════════════════════════════════════════════════════════════
   移动端响应式适配样式 — 企业微信 & 手机浏览器优化
   ══════════════════════════════════════════════════════════════ */

/* ── 安全区域适配（刘海屏/底部手势条） ── */
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-nav-height: 56px;
}

/* ── 移动端底部导航栏 ── */
@media (max-width: 768px) {
  /* 底部导航栏样式 */
  #mobileBottomNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    padding-bottom: var(--safe-area-bottom);
    background: #fff;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 45;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
  }
  html.dark #mobileBottomNav {
    background: rgba(13, 15, 20, 0.95);
    border-top-color: rgba(255, 255, 255, 0.06);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    gap: 2px;
    color: #64748b;
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .mobile-nav-item.active {
    color: #2563eb;
  }
  .mobile-nav-item i,
  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
  }
  .mobile-nav-item .nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }

  /* 主内容区底部留出导航栏空间 */
  #mainContent {
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 12px) !important;
  }

  /* 隐藏桌面端侧边栏 */
  #sidebar {
    display: none !important;
  }
  #sidebar.mobile-open {
    display: flex !important;
  }

  /* 顶部栏适配 */
  header {
    height: 52px !important;
    padding: 0 12px !important;
  }
  header #toggle-sidebar {
    display: none !important;
  }

  /* 页面内容间距 */
  #mainContent {
    padding: 12px !important;
  }

  /* ── 卡片组件 ── */
  .card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  /* ── 模态框全屏 ── */
  .modal-container {
    max-width: 100vw !important;
    max-height: 100vh !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding-top: var(--safe-area-top) !important;
    padding-bottom: calc(var(--safe-area-bottom) + 12px) !important;
  }

  /* ── 按钮触摸优化 ── */
  .btn {
    min-height: 40px;
    padding-left: 16px;
    padding-right: 16px;
    font-size: 14px;
  }
  .btn-icon {
    width: 40px;
    height: 40px;
  }

  /* ── 输入框优化 ── */
  .input, select, input[type="text"], input[type="password"], input[type="date"], input[type="email"], textarea {
    min-height: 40px;
    font-size: 16px !important; /* 防止iOS自动缩放 */
  }

  /* ── 表格响应式 ── */
  .table-modern {
    display: block;
  }
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  /* ── Grid布局移动端适配 ── */
  .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4,
  .grid.grid-cols-1.lg\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .grid.grid-cols-1.lg\:grid-cols-3,
  .grid.grid-cols-1.md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* ── 隐藏非关键桌面元素 ── */
  .hidden-mobile {
    display: none !important;
  }

  /* ── 文字截断 ── */
  .mobile-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  /* ── 项目卡片列表（移动端替代表格） ── */
  .mobile-project-card {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  html.dark .mobile-project-card {
    background: #13151b;
    border-color: rgba(255, 255, 255, 0.06);
  }
  .mobile-project-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  }

  /* ── 搜索/筛选栏横向滚动 ── */
  .mobile-filter-scroll {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-filter-scroll::-webkit-scrollbar {
    display: none;
  }
  .mobile-filter-scroll > * {
    flex-shrink: 0;
  }

  /* ── 日历移动端 ── */
  .mobile-calendar-cell {
    min-height: 52px !important;
    padding: 4px !important;
  }
  .mobile-calendar-cell .text-base {
    font-size: 13px !important;
  }

  /* ── 通知红点位置 ── */
  .mobile-nav-item {
    position: relative;
  }

  /* ── 下拉面板适配 ── */
  #headerNotifDropdown {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 8px) !important;
    width: auto !important;
    max-height: 60vh !important;
    border-radius: 16px !important;
  }

  /* ── 面包屑隐藏 ── */
  #headerBreadcrumb {
    font-size: 14px !important;
    font-weight: 600 !important;
  }

  /* ── 搜索框 ── */
  #globalSearch {
    width: 0 !important;
    padding: 0 !important;
    border: none !important;
    opacity: 0;
    pointer-events: none;
  }
  #globalSearch.mobile-search-active {
    width: 100% !important;
    padding: 8px 12px !important;
    opacity: 1;
    pointer-events: auto;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-radius: 0 !important;
    height: 52px;
    background: #fff;
  }

  /* ── 统计卡片紧凑 ── */
  .mobile-stat-card {
    padding: 12px !important;
  }
  .mobile-stat-card h2,
  .mobile-stat-card .text-2xl,
  .mobile-stat-card .text-\[32px\] {
    font-size: 22px !important;
  }
  .mobile-stat-card h3 {
    font-size: 11px !important;
  }

  /* ── 消息列表单栏 ── */
  .mobile-msg-detail-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #fff;
    overflow-y: auto;
    padding: 16px;
    padding-top: calc(var(--safe-area-top) + 52px);
    padding-bottom: calc(var(--safe-area-bottom) + 16px);
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }
  html.dark .mobile-msg-detail-panel {
    background: #0a0b0f;
  }
  .mobile-msg-detail-panel.active {
    transform: translateX(0);
  }

  /* ── 设置页tab ── */
  .mobile-settings-tabs {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: 12px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-settings-tabs::-webkit-scrollbar {
    display: none;
  }
  .mobile-settings-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
    transition: all 0.2s;
  }
  .mobile-settings-tab.active {
    background: #fff;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  /* ── 项目详情模态框全屏 ── */
  #projectDetailOverlay > div {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    -webkit-overflow-scrolling: touch;
  }

  /* ── 页脚隐藏 ── */
  footer {
    display: none !important;
  }
}

/* ── 超小屏幕（<480px）额外优化 ── */
@media (max-width: 480px) {
  .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4,
  .grid.grid-cols-1.lg\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .card {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  #mainContent {
    padding: 10px !important;
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 10px) !important;
  }

  header {
    height: 48px !important;
  }
}

/* ── 进度条滚动条隐藏 ── */
#stageProgressBar::-webkit-scrollbar {
  display: none;
}
#stageProgressBar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
