/* ================================================================
   金石量化 - 全局响应式样式 (Responsive)
   汉堡菜单、侧边栏抽屉、表格卡片化、触摸优化
   始终作为最后一个样式表加载（可覆盖前面所有规则）
   ================================================================ */

/* =================================================================
   HAMBURGER MENU — 全站统一导航响应式
   ================================================================= */

/* 汉堡按钮 — 默认隐藏（桌面端） */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .2s;
  z-index: 110;
}
.hamburger:hover {
  background: var(--primary-light);
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .25s;
}

/* 移动端导航遮罩 */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 200;
  opacity: 0;
  transition: opacity .3s;
}
.mobile-nav-overlay.open {
  display: block;
  opacity: 1;
}

/* 移动端导航抽屉 */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  max-width: 80vw;
  height: 100vh;
  background: var(--card-bg);
  z-index: 201;
  box-shadow: var(--shadow-xl);
  transition: right .3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mobile-nav-drawer.open {
  right: 0;
}
.mobile-nav-drawer .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-dark);
}
.mobile-nav-drawer .drawer-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.mobile-nav-drawer .drawer-close:hover {
  background: #fee2e2;
  color: var(--danger);
}
.mobile-nav-drawer .drawer-links {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}
.mobile-nav-drawer .drawer-link {
  display: block;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.mobile-nav-drawer .drawer-link:hover {
  background: var(--bg);
  text-decoration: none;
}
.mobile-nav-drawer .drawer-link.active {
  color: var(--c-brand);
  font-weight: 600;
}

/* 桌面端：隐藏汉堡、显示常规导航链接 */
@media (min-width: 1025px) {
  .nav-links-desktop { display: flex; align-items: center; gap: 4px; }
}

/* 平板/手机：显示汉堡、隐藏常规导航 */
@media (max-width: 1024px) {
  .hamburger {
    display: flex;
  }
  .nav-links-desktop {
    display: none !important;
  }
}

/* =================================================================
   SIDEBAR DRAWER — 文档页侧边栏响应式
   ================================================================= */

/* 侧边栏切换按钮（平板/手机端可见） */
.sidebar-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--c-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  position: fixed;
  top: 56px;
  left: 6px;
  padding: 8px 12px;
  font-size: 13px;
  z-index: 90;
  box-shadow: var(--shadow-md);
  transition: background .2s;
}
.sidebar-toggle:hover {
  background: var(--c-brand-dark);
}

/* 侧边栏遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 150;
  opacity: 0;
  transition: opacity .25s;
}
.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* 平板/手机端侧边栏抽屉 */
@media (max-width: 1024px) {
  .sidebar-toggle {
    display: flex;
  }
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -280px !important;
    width: 280px !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 151 !important;
    transition: left .3s ease !important;
    box-shadow: var(--shadow-xl) !important;
  }
  .sidebar.open {
    left: 0 !important;
  }
  .resize-bar {
    display: none !important;
  }
  .content-area {
    padding: 0 20px 80px !important;
  }
  .docs-wrap {
    margin-top: 100px;
  }
}

/* =================================================================
   TABLE-TO-CARD — 表格在手机上变成卡片
   ================================================================= */

@media (max-width: 640px) {
  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table th,
  .responsive-table td,
  .responsive-table tr {
    display: block;
  }
  .responsive-table thead tr {
    display: none;
  }
  .responsive-table tr {
    margin-bottom: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 0;
  }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    text-align: right;
  }
  .responsive-table td:last-child {
    border-bottom: none;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
    text-align: left;
    flex-shrink: 0;
    margin-right: 12px;
  }
  .responsive-table .action-cell {
    justify-content: flex-end;
  }
}

/* =================================================================
   GLOBAL RESPONSIVE BREAKPOINTS
   ================================================================= */

/* ---- 平板 (≤1024px) ---- */
@media (max-width: 1024px) {
  .container {
    padding: 0 16px;
  }
  .hero {
    padding: 120px 0 60px;
  }
  .hero h1 {
    font-size: 34px;
  }
  .hero-desc {
    font-size: 15px;
    line-height: 1.7;
  }
  .section {
    padding: 60px 0;
  }
  .section-title {
    font-size: 28px;
  }
}

/* ---- 平板竖屏 (≤768px) ---- */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 28px;
  }
  .hero .hero-sub {
    font-size: 15px;
  }
  .hero-stats {
    gap: 24px;
    flex-wrap: wrap;
  }
  .hero-stat .num {
    font-size: 28px;
  }
  .hero-actions {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .hero-actions .btn-hero,
  .hero-actions a {
    width: 100%;
    max-width: 320px;
    text-align: center;
  }

  /* Features grid: 4→2, 3→2 */
  .features-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px;
  }
  .ai-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Pricing */
  .pricing-grid {
    grid-template-columns: 1fr !important;
    max-width: 360px;
  }

  /* Forms */
  .form-wrap {
    padding: 24px 20px;
  }
  .login-box {
    margin: 40px auto;
    padding: 28px 20px;
  }

  /* Section */
  .section-title {
    font-size: 24px;
  }

  /* Highlights */
  .highlights {
    grid-template-columns: 1fr !important;
  }

  /* Flow */
  .flow {
    flex-direction: column;
    gap: 0;
  }
  .flow-arrow {
    transform: rotate(90deg);
    margin: 8px 0;
  }

  /* Dashboard stats */
  .stats-bar {
    grid-template-columns: 1fr !important;
  }

  /* Dashboard header */
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Table toolbar */
  .table-toolbar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .table-toolbar input {
    width: 100% !important;
  }

  /* Cards */
  .dash-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ---- 手机 (≤640px) ---- */
@media (max-width: 640px) {
  .hero {
    padding: 100px 0 48px;
  }
  .hero h1 {
    font-size: 24px;
  }
  .hero-badge {
    font-size: 12px;
    padding: 4px 14px;
  }
  .hero-desc {
    font-size: 14px;
  }
  .hero-cta {
    font-size: 15px;
  }
  .hero-stats {
    flex-direction: column;
    gap: 16px;
  }

  /* Features: 2→1 */
  .features-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .ai-grid {
    grid-template-columns: 1fr !important;
  }

  /* Section */
  .section {
    padding: 48px 0;
  }
  .section-title {
    font-size: 22px;
  }
  .section-sub {
    font-size: 14px;
    margin-bottom: 36px;
  }

  /* Nav */
  .nav {
    padding: 0 12px;
    height: 52px;
  }
  .nav-brand {
    font-size: 16px;
    gap: 8px;
  }
  .nav-brand .logo-icon {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  /* Pricing */
  .pricing-card {
    padding: 28px 20px;
  }
  .pricing-card .plan-price {
    font-size: 34px;
  }

  /* Form */
  .form-wrap {
    padding: 20px 16px;
    border-radius: var(--radius-sm);
  }
  .login-wrap {
    padding: 24px 18px;
  }
  .login-section {
    padding: 80px 0 40px;
  }

  /* Modal */
  .modal-box {
    padding: 24px 20px;
    width: 95%;
  }
  .modal-content {
    max-width: 95vw;
  }

  /* Footer */
  .footer {
    padding: 28px 16px;
    font-size: 12px;
  }

  /* Feature cards */
  .feature-card {
    padding: 24px 18px;
  }
  .flow-step {
    width: 100%;
    max-width: 280px;
  }

  /* Dashboard */
  .dash-container {
    padding: 0 12px;
  }
  .dash-header h1 {
    font-size: 22px;
  }
  .dash-card {
    padding: 20px 16px;
  }

  /* Content area */
  .content-area {
    padding: 0 16px 80px !important;
  }
  .content-area h1 {
    font-size: 1.5rem;
  }
  .content-area h2 {
    font-size: 1.25rem;
  }
}

/* ---- 超小屏 (≤400px) ---- */
@media (max-width: 400px) {
  .hero h1 {
    font-size: 22px;
  }
  .hero-actions .btn-hero {
    font-size: 14px;
    padding: 12px 24px;
  }
  .section-title {
    font-size: 20px;
  }
}

/* =================================================================
   TOUCH OPTIMIZATION
   ================================================================= */

/* 确保所有可交互元素有足够触摸区域 */
@media (pointer: coarse) {
  /* 链接、按钮最小触摸区域 44×44px */
  .nav-link,
  .drawer-link,
  .btn,
  .btn-sm,
  .btn-hero,
  .btn-select,
  .btn-submit,
  .btn-login,
  .btn-logout,
  .btn-close,
  .btn-copy,
  .btn-eye,
  .modal-close,
  button[class*="btn"] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* 侧边栏目录项保持块级，独占一行 */
  .doc-item,
  .tree-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* 表单输入控件 */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  input[type="search"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px !important;  /* 防止 iOS 缩放 */
  }

  /* 复选框/单选框 */
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
  }

  /* 表格操作按钮间距 */
  .action-cell {
    gap: 8px;
  }

  /* 卡片间距增大方便手指滑动 */
  .dash-card {
    margin-bottom: 4px;
  }
}
