/* forexstar P15 Wave 1 — Responsive CSS Framework (T15-W1-01 寇豆码)
   Wave 3 增补: 触屏目标强化 (Apple HIG ≥44px)
   3 端断点: desktop ≥1024 / tablet 768-1023 / mobile <768
   视觉基准: V5 #2c3e50 (深海军蓝) + #f5c842 (金) + iOS neumorphic
   依赖: <link rel="stylesheet" href="css/responsive.css?v=p15-wave3">
   不依赖: Bootstrap / Tailwind (ARCH D4 决策 - 纯 CSS 媒体查询) */

/* ===== CSS 变量定义 (V5 视觉基准继承) ===== */
:root {
  /* V5 智远汇管家基准色 (P14 已恢复) */
  --fs-color-primary: #2c3e50;          /* 深海军蓝 sidebar 底色 */
  --fs-color-gold: #f5c842;             /* 金色强调 */
  --fs-color-text: #ecf0f1;             /* 主文字 */
  --fs-color-text-muted: #95a5a6;       /* 次要文字 */
  --fs-color-bg: #1a2332;               /* 主背景 */
  --fs-color-card: #243447;             /* 卡片背景 */
  --fs-color-border: rgba(236, 240, 241, 0.08);

  /* 布局尺寸 */
  --fs-sidebar-width: 220px;            /* desktop sidebar 宽度 */
  --fs-sidebar-collapsed-width: 60px;   /* tablet 折叠宽度 */
  --fs-sidebar-drawer-width: 280px;     /* mobile 抽屉宽度 (80% 屏宽) */
  --fs-hamburger-size: 44px;            /* 触屏最小目标 (Apple HIG) */
  --fs-search-height: 44px;             /* search 框最小高度 */
  --fs-input-min-font: 16px;            /* 移动端 input 防 iOS 放大 */

  /* 动画 */
  --fs-transition-fast: 150ms ease;
  --fs-transition-normal: 250ms ease;
  --fs-transition-slow: 350ms ease;

  /* 阴影 (iOS neumorphic) */
  --fs-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --fs-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --fs-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== 全局基础 (所有断点) ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;  /* iOS 触摸高亮禁用 */
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--fs-color-bg);
  color: var(--fs-color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* P15 防双击放大 (US-15 移动体验) */
  touch-action: manipulation;
}

/* ===== fs-app 主布局: desktop ≥1024px (常驻 sidebar 220px) ===== */
.fs-app {
  display: grid;
  grid-template-columns: var(--fs-sidebar-width) 1fr;
  grid-template-areas: "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns var(--fs-transition-slow);
}

.fs-sidebar {
  grid-area: sidebar;
  background: var(--fs-color-primary);
  color: var(--fs-color-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--fs-transition-slow);
  box-shadow: var(--fs-shadow-md);
  z-index: 50;
}

.fs-main {
  grid-area: main;
  padding: 16px 24px;
  min-width: 0;  /* 防止 grid 内容溢出触发横向滚动 */
  max-width: 100%;
}

/* desktop 下 hamburger 隐藏 */
.fs-hamburger {
  display: none;
}

/* ===== 触屏目标 ≥ 44px (Apple HIG, 全端) ===== */
button,
a,
.fs-card,
.fs-nav-item,
.fs-search-input,
.fs-hamburger,
.fs-sidebar-toggle {
  min-width: var(--fs-hamburger-size);
  min-height: var(--fs-hamburger-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;  /* 避免 300ms click 延迟 */
}

/* input 默认字号 (desktop 已 ≥ 16px) */
input,
textarea,
select {
  font-size: 16px;  /* 强制 ≥16px 覆盖浏览器默认 (US-15) */
}

/* ===== fs-sidebar 折叠状态 (P15 new · 220px ↔ 60px) ===== */
body.fs-sidebar--collapsed .fs-app {
  grid-template-columns: var(--fs-sidebar-collapsed-width) 1fr;
}

body.fs-sidebar--collapsed .fs-sidebar {
  width: var(--fs-sidebar-collapsed-width);
}

body.fs-sidebar--collapsed .fs-nav-label,
body.fs-sidebar--collapsed .fs-sidebar__brand-text {
  display: none;
}

/* ============================================================== */
/*  Tablet 768-1023px: sidebar 折叠 60px (默认)                       */
/* ============================================================== */
@media (max-width: 1023px) and (min-width: 768px) {
  .fs-app {
    grid-template-columns: var(--fs-sidebar-collapsed-width) 1fr;
  }

  .fs-sidebar {
    width: var(--fs-sidebar-collapsed-width);
  }

  .fs-nav-label,
  .fs-sidebar__brand-text {
    display: none;
  }

  /* tablet 显示 hamburger (允许用户主动展开 220px 抽屉) */
  .fs-hamburger {
    display: inline-flex;
  }

  .fs-main {
    padding: 12px 16px;
  }
}

/* ============================================================== */
/*  Mobile <768px: 抽屉模式 80% 屏宽                                   */
/* ============================================================== */
@media (max-width: 767px) {
  .fs-app {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }

  .fs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--fs-sidebar-drawer-width);
    max-width: 80vw;
    transform: translateX(-100%);
    z-index: 100;
    transition: transform var(--fs-transition-slow);
    box-shadow: var(--fs-shadow-lg);
  }

  body.fs-mobile-nav--open .fs-sidebar {
    transform: translateX(0);
  }

  .fs-main {
    padding: 12px;
    padding-bottom: 64px;  /* 给 bottom-nav 留位 */
  }

  /* mobile 显示 hamburger (顶左角固定) */
  .fs-hamburger {
    display: inline-flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
  }

  /* search 框在 mobile 撑满 + ≥16px 字号 */
  .fs-search-input {
    width: 100%;
    font-size: var(--fs-input-min-font);
    height: var(--fs-search-height);
  }

  /* 抽屉外的遮罩 */
  .fs-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--fs-transition-normal), visibility var(--fs-transition-normal);
  }

  body.fs-mobile-nav--open .fs-drawer-overlay {
    opacity: 1;
    visibility: visible;
  }
}

/* ============================================================== */
/*  Very small mobile ≤480px: 紧凑布局                                 */
/* ============================================================== */
@media (max-width: 480px) {
  .fs-main {
    padding: 8px;
    padding-bottom: 64px;
  }

  .fs-hamburger {
    top: 8px;
    left: 8px;
  }
}

/* ===== 滚动条样式 (V5 iOS neumorphic) ===== */
.fs-sidebar::-webkit-scrollbar {
  width: 6px;
}

.fs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.fs-sidebar::-webkit-scrollbar-thumb {
  background: var(--fs-color-border);
  border-radius: 3px;
}

.fs-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--fs-color-gold);
}

/* ===== 焦点可访问性 (键盘导航) ===== */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--fs-color-gold);
  outline-offset: 2px;
}

/* ===== 禁止横向滚动 (P15 US-15 验收 2: 0 横向滚动条) ===== */
html, body {
  overflow-x: hidden;
}

.fs-app, .fs-main, .fs-sidebar {
  max-width: 100%;
}

/* P15 Wave 3 增补 (T15-W3-01) — 触屏目标 ≥ 44px 全面强化
   寇豆码 · D3 8/4
   验收: 1. button/a/.card/.bottom-nav/label min ≥ 44px
         2. form input font-size ≥ 16px (防 iOS Safari 自动放大)
         3. user-scalable=no 在 index.html meta viewport 已设
   不破: P14 已修复的 3 bug / P15.1 sidebar 折叠 / P15.2 hamburger */

/* ===== 1. 触屏目标扩展 (覆盖 Wave 1 选择器列表) ===== */
.fs-bottom-nav__item,
.fs-modal__btn,
.fs-modal__close,
.fs-dropdown__item,
.fs-tag,
.fs-chip,
.fs-tab,
label.fs-form-label,
[role="button"],
[role="tab"],
[role="menuitem"] {
  min-width: var(--fs-hamburger-size);
  min-height: var(--fs-hamburger-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* bottom-nav 3 入口 (mobile 关键 · 整条带 ≥ 60px) */
.fs-bottom-nav__item {
  flex: 1 1 0;
  min-height: 56px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--fs-color-text-muted);
  transition: color var(--fs-transition-fast), background var(--fs-transition-fast);
}

.fs-bottom-nav__item:active,
.fs-bottom-nav__item:focus-visible {
  color: var(--fs-color-gold);
  background: rgba(245, 200, 66, 0.1);
  outline: none;
}

/* ===== 2. form input font-size 强制 16px (防 iOS Safari 自动放大) ===== */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select,
.fs-form-input,
.fs-form-textarea,
.fs-form-select {
  font-size: var(--fs-input-min-font);  /* 16px */
  line-height: 1.4;
  min-height: var(--fs-search-height);  /* 44px */
  padding: 8px 12px;
  border: 1px solid var(--fs-color-border);
  border-radius: 6px;
  background: var(--fs-color-card);
  color: var(--fs-color-text);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

/* select 自定义箭头 (覆盖 -webkit-appearance: none) */
select.fs-form-select,
.fs-form-select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='%23f5c842'%3e%3cpath d='M6 8L0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 8px;
  padding-right: 32px;
}

/* ===== 3. iOS 移动端 16px 防放大 + 触摸滚动优化 ===== */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari only */
  input,
  textarea,
  select {
    font-size: max(16px, 1rem);
  }
}

/* ===== 4. mobile 增强 (≤767px · bottom-nav 显隐 + 抽屉优化) ===== */
@media (max-width: 767px) {
  .fs-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--fs-color-primary);
    border-top: 1px solid var(--fs-color-border);
    z-index: 80;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
  }

  /* mobile 卡片最小触摸高度 */
  .fs-card {
    min-height: var(--fs-hamburger-size);
    padding: 12px 16px;
    margin-bottom: 8px;
  }

  /* 横向滑动表格容器 (P15 移动体验) */
  .fs-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* desktop ≥1024 隐藏 bottom-nav (与 mobile 互斥) */
@media (min-width: 1024px) {
  .fs-bottom-nav {
    display: none;
  }
}

/* ===== 5. 触摸反馈 (active 状态 · 替代 hover) ===== */
button:active:not(:disabled),
a:active,
.fs-card:active,
.fs-bottom-nav__item:active {
  transform: scale(0.97);
  transition: transform 80ms ease;
}

/* ===== 6. 可访问性 — 焦点环 (键盘导航 + 触屏 a11y) ===== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--fs-color-gold);
  outline-offset: 2px;
  z-index: 1;
}

/* ===== 7. 暗色模式 / 高对比度辅助 (P15 体验兜底) ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
