/* ══════════════════════════════════════════════════════════════════════
   移动端响应式样式 — 投标智能助手
   基于 DESIGN.md §7 设计规范
   策略：桌面端不变，移动端叠加覆盖
   ══════════════════════════════════════════════════════════════════════ */

/* ─── CSS 变量（继承 style.css，仅补充移动端专属变量） ─── */
:root {
  --touch-min: 44px;
  --tab-bar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── 断点：平板 (768-1023px) ─── */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar {
    width: 64px !important;
  }
  .sidebar-header span,
  .sidebar .nav-text,
  .sidebar-footer span,
  .sidebar-footer a {
    display: none !important;
  }
  .sidebar-header {
    justify-content: center;
    padding: 16px 8px !important;
  }
  .sidebar-nav a {
    justify-content: center;
    padding: 12px 8px !important;
  }
  .sidebar-nav a .icon {
    margin: 0;
  }
  .main-content-area,
  .main-content,
  body > .content-area,
  .content-area,
  .dashboard-container,
  .container,
  .pm-wrap,
  .quote-wrap,
  .page-wrap,
  .tuning-layout,
  .skill-layout {
    margin-left: 64px !important;
  }
}

/* ─── 断点：手机 (<768px) ─── */
@media (max-width: 767px) {
  /* --- 侧边栏隐藏 --- */
  .sidebar {
    display: none !important;
  }

  /* --- body 防横向溢出 --- */
  body {
    overflow-x: hidden !important;
  }

  /* --- 主内容区全宽，底部留出 Tab Bar 空间 --- */
  .main-content-area,
  .main-content,
  body > .content-area,
  .content-area,
  .dashboard-container,
  .container,
  .pm-wrap,
  .quote-wrap,
  .page-wrap,
  .tuning-layout,
  .skill-layout {
    margin-left: 0 !important;
    padding: 12px 12px calc(var(--tab-bar-h) + var(--safe-bottom) + 16px) !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* --- Topbar 精简 --- */
  .topbar {
    padding: 0 12px !important;
    height: 48px !important;
  }
  .topbar-logo {
    font-size: 14px !important;
  }
  .topbar-info {
    display: none !important;
  }
  .topbar-user {
    gap: 6px !important;
  }
  .logout-btn span,
  .logout-btn .btn-text {
    display: none !important;
  }
  .logout-btn {
    padding: 6px 10px !important;
  }

  /* --- 模块卡片网格 → 2 列 --- */
  .modules-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .module-card {
    padding: 16px !important;
  }
  .module-card h3 {
    font-size: 13px !important;
  }
  .module-card p {
    font-size: 11px !important;
    line-height: 1.4 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Welcome 卡片 --- */
  .welcome-card {
    padding: 20px !important;
    border-radius: 12px !important;
  }
  .welcome-card h2 {
    font-size: 16px !important;
  }
  .welcome-card p {
    font-size: 12px !important;
  }

  /* --- 表格 → 卡片列表 --- */
  table.responsive-table,
  table {
    display: block;
    width: 100%;
  }
  table thead {
    display: none;
  }
  table tbody,
  table tr {
    display: block;
    width: 100%;
  }
  table tr {
    margin-bottom: 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border: none !important;
    font-size: 13px;
    gap: 8px;
  }
  table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    flex-shrink: 0;
    max-width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* 无 data-label 的 td 保留原样 */
  table td:not([data-label]) {
    display: table-cell;
  }
  table td:not([data-label])::before {
    content: none;
  }

  /* 操作按钮列在移动端独立一行 */
  table tr td:last-child {
    border-top: 1px solid var(--border, #e2e8f0) !important;
    margin-top: 6px;
    padding-top: 8px;
    justify-content: flex-end;
  }

  /* --- 表单适配 --- */
  input, select, textarea, button {
    font-size: 16px !important; /* 防止 iOS 缩放 */
  }
  .form-row,
  .filter-bar,
  .toolbar {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .form-row > *,
  .filter-bar > *,
  .toolbar > * {
    width: 100% !important;
  }
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  select {
    min-height: var(--touch-min);
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }
  button {
    min-height: var(--touch-min);
    padding: 10px 16px !important;
    border-radius: 8px !important;
  }

  /* --- 模态框全屏 --- */
  .modal-content,
  .modal-dialog {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
  }

  /* --- 分页器精简 --- */
  .pagination {
    gap: 4px !important;
  }
  .pagination button,
  .pagination a {
    padding: 6px 10px !important;
    font-size: 12px !important;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
  }

  /* --- 页面标题 --- */
  h1, .page-title {
    font-size: 18px !important;
    margin-bottom: 12px !important;
  }
  h2 {
    font-size: 16px !important;
  }
  h3 {
    font-size: 14px !important;
  }

  /* --- 统计卡片 --- */
  .stats-grid,
  .summary-cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .stat-card {
    padding: 12px !important;
  }
  .stat-card .stat-value {
    font-size: 20px !important;
  }
  .stat-card .stat-label {
    font-size: 11px !important;
  }

  /* --- 代码/日志块 --- */
  pre, code, .log-content, .code-block {
    font-size: 11px !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
  }

  /* --- 方案报价：左右分栏 → 上下堆叠 --- */
  .quote-split {
    flex-direction: column !important;
    gap: 12px !important;
  }
  .quote-chat-col {
    width: 100% !important;
    height: auto !important;
    max-height: 400px !important;
    position: static !important;
  }
  .quote-cards-col {
    width: 100% !important;
  }

  /* --- 场景报价表单：3列 → 单列 --- */
  .scene-form {
    grid-template-columns: 1fr !important;
  }

  /* --- 系统调优：双栏 → 单栏 --- */
  .tuning-layout {
    grid-template-columns: 1fr !important;
  }

  /* --- 双列对比：统一 1 列 --- */
  .compare-grid {
    grid-template-columns: 1fr !important;
  }

  /* --- 产品卡片网格：2列 --- */
  .prod-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .prod-card {
    padding: 12px !important;
  }

  /* --- Tab 栏横向滚动 --- */
  .tab-bar,
  .skill-tabs,
  .tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    flex: none !important;
    white-space: nowrap;
    font-size: 13px !important;
    padding: 8px 14px !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   底部 Tab Bar（<768px 显示）
   ══════════════════════════════════════════════════════════════════════ */

.mobile-tab-bar {
  display: none;
}
@media (max-width: 767px) {
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-h);
    padding-bottom: var(--safe-bottom);
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
  }
  .mobile-tab-bar .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    min-width: 48px;
    min-height: var(--touch-min);
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex: 1;
  }
  .mobile-tab-bar .tab-item svg {
    width: 22px;
    height: 22px;
  }
  .mobile-tab-bar .tab-item.active {
    color: #4F46E5;
  }
  .mobile-tab-bar .tab-item:active {
    opacity: 0.7;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   通用辅助类
   ══════════════════════════════════════════════════════════════════════ */

/* 桌面端显示，移动端隐藏 */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

/* 移动端显示，桌面端隐藏 */
@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
}

/* 滚动区域（移动端长列表） */
@media (max-width: 767px) {
  .scrollable-list {
    max-height: calc(100vh - var(--tab-bar-h) - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
