/* ============================================================
   AnyNet Web 设计系统 —— 令牌层 + 组件类
   与客户端（macOS/iOS）同源：slate 灰阶 + teal-600 单一重音，浅色极简。
   页面里 Tailwind 工具类负责布局，本文件负责组件质感。
   ============================================================ */

:root {
  /* 色板 */
  --bg: #f8fafc;             /* slate-50  页面底 */
  --surface: #ffffff;        /* 卡片/侧边栏 */
  --surface-hover: #f5f7fb;  /* slate-100 悬停 */
  --text-1: #0f172a;         /* slate-900 主文字 */
  --text-2: #475569;         /* slate-600 次文字 */
  --text-3: #64748b;         /* slate-500 弱文字 */
  --border: #e2e8f0;         /* slate-200 细边框 */
  --border-strong: #cbd5e1;  /* slate-300 输入框边框 */
  --accent: #0d9488;         /* teal-600 唯一主色 */
  --accent-hover: #0f766e;   /* teal-700 */
  --accent-soft: rgba(13, 148, 136, .08);
  --accent-ring: rgba(13, 148, 136, .18);
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  /* 圆角：三档，不许再出现第四个值 */
  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 12px;
  /* 阴影：低存在感的染色阴影 */
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, .10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(13, 148, 136, .18); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-s);
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, filter .15s;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { filter: brightness(.94); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.72rem; border-radius: var(--radius-s); }

/* ---------- 输入框 ---------- */
.input {
  width: 100%;
  background: var(--surface);
  color: var(--text-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: #94a3b8; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}

/* ---------- 表格横向滚动容器（窄屏保持表格 min-width，容器横滚） ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#toast-root > * {
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录页 ---------- */
/* 平色底 + 白卡片；不要渐变光晕 */
.login-wrap { background: var(--bg); }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-pop);
}

/* ---------- Markdown 文档渲染 ---------- */
/* 容器可横向滚动：内部宽表格/代码在手机上不撑破页面（普通文本不会触发滚动） */
.md { font-size: 0.875rem; line-height: 1.75; color: var(--text-2); word-break: break-word; overflow-x: auto; max-width: 100%; }
.md h1 { font-size: 1.4rem; font-weight: 700; color: var(--text-1); margin: 0 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.md h2 { font-size: 1.15rem; font-weight: 700; color: var(--text-1); margin: 1.6rem 0 0.6rem; padding-bottom: 0.35rem; border-bottom: 1px solid #f1f5f9; }
.md h3 { font-size: 1rem; font-weight: 600; color: #1e293b; margin: 1.2rem 0 0.5rem; }
.md h4 { font-size: 0.9rem; font-weight: 600; color: #1e293b; margin: 1rem 0 0.4rem; }
.md p { margin: 0.5rem 0; }
.md ul, .md ol { margin: 0.5rem 0; padding-left: 1.4rem; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md li { margin: 0.25rem 0; }
.md a { color: var(--accent); text-decoration: underline; }
.md strong { font-weight: 600; color: var(--text-1); }
.md code {
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 0.3rem;
  padding: 0.1rem 0.35rem; font-size: 0.8em; color: #be123c;
}
.md pre {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius);
  padding: 0.9rem 1rem; overflow-x: auto; margin: 0.75rem 0;
}
.md pre code { background: transparent; border: none; color: inherit; padding: 0; font-size: 0.78rem; }
.md blockquote {
  border-left: 3px solid #5eead4; background: #f0fdfa;
  border-radius: 0 0.4rem 0.4rem 0; padding: 0.5rem 0.9rem; margin: 0.75rem 0; color: var(--accent-hover);
}
.md table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.82rem; }
.md th, .md td { border: 1px solid var(--border); padding: 0.45rem 0.7rem; text-align: left; }
.md th { background: var(--bg); font-weight: 600; color: var(--text-1); }
.md tr:nth-child(even) td { background: #fafbfc; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.md input[type="checkbox"] { margin-right: 0.4rem; }

/* ---------- 侧边栏折叠（收起为图标窄条） ---------- */
#sidebar.collapsed { width: 4rem; }
#sidebar.collapsed .nav-label,
#sidebar.collapsed #site-title-nav,
#sidebar.collapsed #portal-title,
#sidebar.collapsed .admin-badge,
#sidebar.collapsed .nav-group-toggle span:first-child,
#sidebar.collapsed .nav-group-arrow { display: none; }
/* 品牌行：只剩 logo 居中（折叠按钮已挪到底部） */
#sidebar.collapsed .brand-row { justify-content: center; padding-left: 0; padding-right: 0; }
#sidebar.collapsed .nav-item,
#sidebar.collapsed .pnav { justify-content: center; padding-left: 0; padding-right: 0; }
#sidebar.collapsed .nav-group-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
#sidebar.collapsed .nav-group-toggle span:first-child { display: none; }
#sidebar.collapsed .nav-group-items { display: block !important; }
#sidebar.collapsed .nav-group { padding: 0.35rem 0; }
#sidebar.collapsed .nav-group-toggle { padding: 0.35rem 0; }
/* 折叠时组标题只显示小圆点占位（居中） */
#sidebar.collapsed .nav-group-toggle::before { content: ''; display: block; width: 4px; height: 4px; border-radius: 9999px; background: var(--border-strong); }
/* 折叠时底部链接/按钮只留图标居中 */
#sidebar.collapsed #sidebar-footer a,
#sidebar.collapsed #sidebar-footer button { justify-content: center; padding-left: 0; padding-right: 0; }
/* 折叠时隐藏 portal 底部法律链接（窄条放不下） */
#sidebar.collapsed #portal-legal { display: none; }

/* ---------- 菜单组收起 ---------- */
.nav-group-items.collapsed { display: none; }
.nav-group-toggle { user-select: none; }

/* ============================================================
   移动端（H5）修补 —— 手机浏览器通用问题
   ============================================================ */

/* iOS Safari 聚焦自动缩放：字号 <16px 的 input/select/textarea 聚焦时会放大页面。
   移动端把所有表单控件字号抬到 16px 以上即可消除（这是 iOS 的硬性阈值）。 */
@media (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* 点击目标最小化（触屏友好）与去除点击高亮闪烁 */
@media (max-width: 767px) {
  .btn, button, a { -webkit-tap-highlight-color: transparent; }
  .btn { min-height: 36px; }
}

/* 内容区窄屏留白收紧：px-6/px-8 在手机上过宽 */
@media (max-width: 767px) {
  #page-content { padding: 1rem !important; }
}

/* 卡片内边距在窄屏略收（Tailwind 运行时生成类，需 !important 保证覆盖） */
@media (max-width: 767px) {
  .p-6 { padding: 1.1rem !important; }
  .px-6 { padding-left: 1.1rem !important; padding-right: 1.1rem !important; }
  .px-8 { padding-left: 1.1rem !important; padding-right: 1.1rem !important; }
  .p-5 { padding: 1rem !important; }
  .px-5 { padding-left: 1rem !important; padding-right: 1rem !important; }
}

/* 媒体元素防御：任何图片/画布/矢量图/视频都不许撑破容器（只设上限，不影响已有宽高） */
img, canvas, svg, video { max-width: 100%; }

/* ECharts 容器宽度自适应：防止图表溢出视口 */
.echart, [id$="-chart"], #st-daily, #st-hourly, #ops-chart, #node-traffic-chart, #traffic-daily-chart {
  max-width: 100%;
}

/* 避免 iOS 橡皮筋滚动导致背景透出时布局抖动 */
html { -webkit-text-size-adjust: 100%; }

/* 手机登录卡片：避免顶部地址栏挤压 */
@media (max-width: 767px) {
  .login-card { padding: 1.6rem; }
  #view-login, #view-app { min-height: 100dvh; }
}

