/* mobile-responsive.css - F-ATM 移动端统一适配框架 */
/* 适用于：fx_backtest, stock_backtest, data_upload, FX_history, stock_history, knowledge 等 */

/* ======================================== */
/* 基础移动端优化（默认生效，但只在窄屏下产生主要影响） */
/* ======================================== */

/* 触摸优化：增大可点击区域 */
@media (max-width: 768px) {
  button, input[type="submit"], input[type="button"], a.btn, .btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 14px;
    padding: 10px 16px;
  }

  input, select, textarea {
    font-size: 16px !important; /* 防止 iOS 缩放 */
    padding: 8px 10px;
    min-height: 40px;
  }

  /* 禁止横向滚动 */
  body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ======================================== */
/* 统一侧边栏-主区域布局 → 移动端上下堆叠 */
/* ======================================== */

@media (max-width: 768px) {
  /* 容器从 grid 左右 → flex 上下 */
  .container {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh;
    overflow-y: auto !important;
  }

  /* 左侧/上方面板（原侧边栏） */
  .container > .panel,
  .container > .sidebar,
  .container > .left {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 50vh;
    border-right: none !important;
    border-bottom: 1px solid #30363d;
    padding: 12px;
    overflow-y: auto;
    flex-shrink: 0;
  }

  /* 右侧/下方主区域 */
  .container > .main,
  .container > .right,
  .container > .content {
    width: 100% !important;
    height: auto !important;
    min-height: 50vh;
    padding: 12px;
    overflow-y: visible;
  }
}

/* ======================================== */
/* 表单布局：水平 → 垂直 */
/* ======================================== */

@media (max-width: 768px) {
  .form-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    margin-bottom: 10px;
  }

  .form-row label {
    flex: none !important;
    width: 100% !important;
    font-size: 13px;
    margin-bottom: 2px;
  }

  .form-row input,
  .form-row select {
    flex: none !important;
    width: 100% !important;
    font-size: 16px;
    padding: 8px 10px;
  }

  /* 双列表单 → 单列 */
  .form-cols,
  .form-grid,
  .form-row-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ======================================== */
/* 统计卡片：多列 → 1-2列 */
/* ======================================== */

@media (max-width: 768px) {
  .stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  .stat-card {
    padding: 10px 8px;
  }

  .stat-card .label {
    font-size: 10px;
  }

  .stat-card .value {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .stats {
    grid-template-columns: 1fr !important;
  }
}

/* ======================================== */
/* 顶栏导航优化 */
/* ======================================== */

@media (max-width: 768px) {
  header {
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  header h1 {
    font-size: 14px !important;
  }

  header nav {
    gap: 8px !important;
  }

  header nav a {
    font-size: 12px !important;
    padding: 4px 8px !important;
  }
}

/* ======================================== */
/* 图表区域优化 */
/* ======================================== */

@media (max-width: 768px) {
  .chart-area {
    min-height: 300px;
  }

  .chart-box {
    min-height: 250px;
    padding: 8px;
  }

  .chart-wrap {
    min-height: 200px;
  }
}

/* ======================================== */
/* 表格优化：横向滚动 */
/* ======================================== */

@media (max-width: 768px) {
  .table-wrap,
  .table-responsive,
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    font-size: 12px;
    padding: 6px 8px;
    white-space: nowrap;
  }
}

/* ======================================== */
/* 按钮组/操作栏优化 */
/* ======================================== */

@media (max-width: 768px) {
  .btn-group,
  .actions,
  .toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .btn-group .btn,
  .actions .btn,
  .toolbar .btn {
    flex: 1 1 45%;
    min-width: 120px;
  }
}

@media (max-width: 480px) {
  .btn-group .btn,
  .actions .btn,
  .toolbar .btn {
    flex: 1 1 100%;
  }
}

/* ======================================== */
/* 知识库/文章页特殊优化 */
/* ======================================== */

@media (max-width: 768px) {
  .sidebar {
    position: static !important;
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid #30363d;
  }

  .toc-list a {
    font-size: 13px;
    padding: 6px 10px;
  }

  .content h2 {
    font-size: 18px;
  }

  .content h3 {
    font-size: 15px;
  }

  .content p {
    font-size: 14px;
    line-height: 1.6;
  }
}

/* ======================================== */
/* 通用字号调整 */
/* ======================================== */

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .section-title {
    font-size: 12px;
  }

  .hint, .note, .help {
    font-size: 11px;
  }

  /* 间距收紧 */
  .section {
    padding: 10px;
  }
}

/* ======================================== */
/* 弹窗/模态框优化 */
/* ======================================== */

@media (max-width: 768px) {
  .modal, .dialog, .popup {
    width: 90vw !important;
    max-width: 90vw !important;
    max-height: 80vh;
    overflow-y: auto;
  }

  .modal-content, .dialog-content {
    padding: 16px;
  }
}

/* ======================================== */
/* 滑块/范围输入优化（触摸） */
/* ======================================== */

@media (max-width: 768px) {
  input[type="range"] {
    min-height: 30px;
    margin: 8px 0;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}

/* ======================================== */
/* 欢迎页特殊优化（welcome.html） */
/* ======================================== */

@media (max-width: 768px) {
  .hero {
    padding: 40px 16px 30px !important;
  }

  .hero h1 {
    font-size: 2.2rem !important;
  }

  .hero .subtitle {
    font-size: 0.9rem !important;
    max-width: 100% !important;
    padding: 0 12px;
  }

  .feature-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 0 12px;
  }

  .feature-card {
    padding: 16px !important;
  }

  .nav-links {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .app-download {
    margin-top: 20px !important;
  }

  .app-download .qr-wrap {
    padding: 8px !important;
  }

  .app-download .qr-wrap img {
    width: 120px !important;
    height: 120px !important;
  }
}

/* ======================================== */
/* 复杂表单布局优化 */
/* ======================================== */

@media (max-width: 768px) {
  /* 三列表单 → 单列 */
  .form-cols-3,
  .form-grid-3,
  .triple-col {
    grid-template-columns: 1fr !important;
  }

  /* 参数面板内的特殊布局 */
  .param-group,
  .param-row,
  .config-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }

  .param-group label,
  .param-row label,
  .config-row label {
    width: 100% !important;
    flex: none !important;
  }

  /* 日期范围等特殊控件 */
  .date-range,
  .range-picker,
  .period-select {
    flex-direction: column !important;
    gap: 6px !important;
  }

  .date-range input,
  .range-picker input,
  .period-select select {
    width: 100% !important;
  }
}

/* ======================================== */
/* 图表与数据展示优化 */
/* ======================================== */

@media (max-width: 768px) {
  /* 热力表/矩阵 */
  .heatmap,
  .matrix,
  .grid-matrix {
    overflow-x: auto !important;
    display: block !important;
  }

  .heatmap table,
  .matrix table,
  .grid-matrix table {
    min-width: 600px;
  }

  /* 月度统计等横向卡片 */
  .monthly-stats,
  .period-stats,
  .summary-cards {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* 交易明细表格 */
  .trade-list,
  .trade-table {
    font-size: 11px;
  }

  .trade-list th,
  .trade-table th,
  .trade-list td,
  .trade-table td {
    padding: 4px 6px;
  }
}

@media (max-width: 480px) {
  .monthly-stats,
  .period-stats,
  .summary-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ======================================== */
/* 文件上传/数据管理页优化 */
/* ======================================== */

@media (max-width: 768px) {
  .upload-area,
  .drop-zone {
    padding: 20px 12px !important;
  }

  .upload-area .upload-icon,
  .drop-zone .upload-icon {
    font-size: 2rem !important;
  }

  .file-list,
  .data-list {
    max-height: 40vh;
  }

  .file-item,
  .data-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    padding: 10px !important;
  }

  .file-actions,
  .row-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ======================================== */
/* 登录/注册页优化 */
/* ======================================== */

@media (max-width: 768px) {
  .login-box,
  .register-box,
  .auth-container {
    width: 90vw !important;
    max-width: 90vw !important;
    padding: 24px 16px !important;
  }

  .login-box h2,
  .register-box h2 {
    font-size: 1.5rem !important;
  }

  .login-form .form-group,
  .register-form .form-group {
    margin-bottom: 14px;
  }

  .login-form input,
  .register-form input {
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
}

/* ======================================== */
/* 加载/进度指示器优化 */
/* ======================================== */

@media (max-width: 768px) {
  .loading-overlay,
  .progress-overlay {
    padding: 20px;
  }

  .spinner {
    width: 40px;
    height: 40px;
  }

  .progress-text {
    font-size: 13px;
  }
}

/* ======================================== */
/* 通知/提示优化 */
/* ======================================== */

@media (max-width: 768px) {
  .toast,
  .notification,
  .alert {
    left: 10px !important;
    right: 10px !important;
    max-width: none !important;
    font-size: 13px;
    padding: 10px 14px;
  }
}

/* ======================================== */
/* 底部/页脚优化 */
/* ======================================== */

@media (max-width: 768px) {
  footer,
  .footer {
    padding: 16px 12px;
    font-size: 11px;
  }
}
