/* ============================================
   斯特普销售系统 - 移动端全面适配样式表
   适用：手机竖屏（<576px）和小屏手机
   注：此文件在 base.html 最后加载，自动生效
   ============================================ */

/* ── 超小屏：<576px ── */
@media (max-width: 575.98px) {
  /* ─── 全局间距压缩 ─── */
  .page-content { padding: 12px 10px 90px !important; }
  .content-card { padding: 12px !important; border-radius: 10px; margin-bottom: 10px; }
  .content-card .card-title { font-size: 14px; margin-bottom: 12px; }
  .content-card .card-title .btn { font-size: 11px; padding: 4px 8px; }

  /* ─── 移动端全屏模态框 ─── */
  .modal-dialog { margin: 0 !important; }
  .modal-dialog.modal-fullscreen-mobile {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
  }
  .modal-dialog.modal-fullscreen-mobile .modal-content {
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    border: none;
  }
  .modal-dialog.modal-fullscreen-mobile .modal-header {
    padding: 14px 16px;
    border-radius: 0;
  }
  .modal-dialog:not(.modal-fullscreen-mobile) {
    margin: 10px !important;
  }
  .modal-header { padding: 12px 14px; }
  .modal-header .modal-title { font-size: 15px; }
  .modal-body { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; }
  .modal-footer .btn { min-height: 38px; font-size: 13px; }

  /* ─── 按钮增强触摸区 ─── */
  .btn { min-height: 40px; font-size: 14px; border-radius: 8px; padding: 8px 14px; }
  .btn-sm { min-height: 34px; font-size: 12px; padding: 4px 10px; }
  .btn-xs { min-height: 28px; font-size: 11px; padding: 2px 8px; }

  /* ─── 表单控件增强 ─── */
  .form-control, .form-select {
    min-height: 42px;
    font-size: 16px !important; /* 防止iOS自动缩放 */
    border-radius: 8px;
    padding: 8px 12px;
  }
  .form-control-sm, .form-select-sm {
    min-height: 36px;
    font-size: 14px !important;
  }
  .form-label { font-size: 13px; margin-bottom: 4px; font-weight: 500; }
  .input-group-text { font-size: 14px; padding: 8px 10px; }
  .form-text { font-size: 11px; }

  /* ─── 表格全面优化 ─── */
  /* 禁止单元格内换行预览 */
  .table th, .table td {
    padding: 8px 6px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }
  .table-sm th, .table-sm td {
    padding: 5px 4px !important;
    font-size: 11px !important;
  }
  /* 表格容器滚动优化 */
  .table-responsive, .table-fit-wrapper {
    max-height: 60vh !important;
    border-radius: 8px;
    margin-bottom: 0;
  }
  .table-responsive::-webkit-scrollbar,
  .table-fit-wrapper::-webkit-scrollbar {
    height: 3px;
    width: 3px;
  }
  .table-responsive::-webkit-scrollbar-thumb,
  .table-fit-wrapper::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
  }

  /* 固定列在手机上缩小宽度 */
  .sticky-l0 { min-width: 26px !important; width: 26px !important; }
  .sticky-l1 { min-width: 36px !important; width: 36px !important; }
  .sticky-l2 { min-width: 60px !important; width: 60px !important; }
  .sticky-l3 { min-width: 80px !important; width: 80px !important; }
  .sticky-l4 { min-width: 85px !important; width: 85px !important; }
  .sticky-l5 { min-width: 50px !important; width: 50px !important; }
  .sticky-end { min-width: 70px !important; width: 70px !important; }

  /* ─── 筛选/搜索栏 ─── */
  .row.g-2.mb-3 > [class*="col-"],
  .row.g-3.mb-3 > [class*="col-"] {
    padding-left: 4px;
    padding-right: 4px;
  }
  .row.g-2.mb-3 .btn,
  .row.g-3.mb-3 .btn {
    width: 100%;
    min-height: 38px;
    font-size: 13px;
  }
  .row.g-2.mb-3 .form-control,
  .row.g-3.mb-3 .form-control,
  .row.g-2.mb-3 .form-select,
  .row.g-3.mb-3 .form-select {
    min-height: 38px;
    font-size: 14px;
  }

  /* ─── 工具栏按钮组 ─── */
  .card-title .d-flex.gap-2 {
    gap: 4px !important;
  }
  .card-title .d-flex.gap-2 .btn {
    font-size: 11px;
    padding: 4px 7px;
    min-height: 32px;
    white-space: nowrap;
  }
  .card-title .d-flex.gap-2 .btn i {
    font-size: 12px;
    margin-right: 2px;
  }

  /* ─── 分页导航 ─── */
  .pagination { flex-wrap: wrap; justify-content: center; gap: 2px; }
  .pagination .page-link {
    min-width: 34px;
    height: 34px;
    padding: 4px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .pagination .page-item .page-link { border-radius: 6px !important; margin: 0 1px; }

  /* ─── Bootstrap 标签页 ─── */
  .nav-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-item { flex-shrink: 0; }
  .nav-tabs .nav-link {
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }

  /* ─── 统计卡片 ─── */
  .stat-card { padding: 12px 8px; border-radius: 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-label { font-size: 11px; }
  .stat-card .stat-icon { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }

  /* ─── 下拉菜单 ─── */
  .dropdown-menu { font-size: 13px; min-width: 160px; }
  .dropdown-item { padding: 10px 14px; }

  /* ─── Toast 通知 ─── */
  .toast-container { top: 10px !important; right: 10px !important; left: 10px !important; width: auto !important; }
  .toast { max-width: 100% !important; font-size: 13px; }

  /* ─── 图表容器 ─── */
  .chart-container { position: relative; width: 100%; }
  .chart-container canvas { max-width: 100% !important; height: auto !important; }

  /* ─── 表格中的状态徽标 ─── */
  .status-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }

  /* ─── 消息列表 ─── */
  .msg-item { padding: 10px 12px !important; }
  .msg-item strong { font-size: 13px !important; }
  .msg-item .text-muted.small { font-size: 11px !important; }

  /* ─── 链接卡片 ─── */
  .route-card { padding: 10px 12px !important; }
  .route-card .fs-6 { font-size: 14px !important; }
  .route-card small { font-size: 11px !important; }

  /* ─── 复选框/单选 ─── */
  .form-check-input { width: 18px; height: 18px; margin-top: 3px; }
  .form-check-label { font-size: 13px; padding-left: 4px; }
  .form-switch .form-check-input { width: 40px; height: 22px; }
  .form-check-inline { margin-right: 8px; }

  /* ─── 侧边栏遮罩 ─── */
  .sidebar.show::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }

  /* ─── 移动端全宽按钮组 ─── */
  .btn-group-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .btn-group-mobile .btn {
    flex: 1 1 auto;
    min-width: 60px;
  }

  /* ─── 列表卡片（替代表格） ─── */
  .list-card-item {
    background: white;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  .list-card-item .field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
  }
  .list-card-item .field-row:last-child { border-bottom: none; }
  .list-card-item .field-label {
    font-size: 12px;
    color: #64748b;
    flex-shrink: 0;
  }
  .list-card-item .field-value {
    font-size: 13px;
    color: #1e293b;
    text-align: right;
    font-weight: 500;
    margin-left: 8px;
  }

  /* ─── 消息角标大小 ─── */
  .badge-dot { width: 6px; height: 6px; }

  /* ─── 安全区域适配（iPhone刘海屏/全面屏） ─── */
  .mobile-nav {
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px)) !important;
  }
  .page-content {
    padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom, 0px))) !important;
  }

  /* ─── 顶栏紧凑 ─── */
  .top-header { padding: 0 10px !important; height: 52px !important; }
  .top-header .header-left { gap: 8px; }
  .top-header .header-left h6 { font-size: 14px !important; }
  .top-header .header-right { gap: 8px; }
  .top-header .sidebar-toggle { font-size: 20px !important; }

  /* ─── 标签（导航内） ─── */
  .form-tab {
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
  .form-tabs { gap: 4px !important; margin-bottom: 10px !important; }
  .form-card-selector .form-card {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* ─── 日期/时间选择器 ─── */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    min-height: 42px;
    font-size: 16px !important;
  }

  /* ─── 选择字段卡片 ─── */
  .modal .d-flex.flex-wrap.gap-2 .border.rounded.p-2 {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* ─── 图像/头像 ─── */
  .avatar-lg { width: 72px !important; height: 72px !important; }
  .avatar-md { width: 48px !important; height: 48px !important; }
  .avatar-sm { width: 32px !important; height: 32px !important; }
}

/* ── 特别小屏手机：<400px ── */
@media (max-width: 400px) {
  .stat-card .stat-value { font-size: 18px; }
  .stat-card .stat-label { font-size: 10px; }
  .stat-card .stat-icon { width: 28px; height: 28px; font-size: 14px; }
  .page-content { padding: 10px 8px 80px !important; }
  .content-card { padding: 10px !important; }
  .table th, .table td { padding: 6px 4px !important; font-size: 11px !important; }
  .btn { min-height: 36px; font-size: 13px; }
  .mobile-nav .nav-link i { font-size: 20px; }
  .mobile-nav .nav-link span { font-size: 9px; }
}

/* ── 平板：576px ~ 768px ── */
@media (min-width: 576px) and (max-width: 767.98px) {
  .page-content { padding: 16px 16px 80px !important; }
  .content-card { padding: 16px !important; }
  .stat-card .stat-value { font-size: 24px; }
  .modal-dialog { margin: 20px auto !important; }
}
