/* ============================================================
 * base.css — 基础样式 + 重置 + 响应式断点 + 工具类
 * ============================================================ */

/* ---- Reset ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* 滚动条常驻占位：页面内容高度变化（选图/生成结果出现）时滚动条出现/消失
     不再引起全页横向跳动（顶部导航图标、侧栏内容都会跟着错动） */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  padding-left: var(--sidebar-width);
  transition: padding-left var(--transition);
}
body.sidebar-collapsed { padding-left: 18px; }

a {
  color: var(--c-accent);
  text-decoration: none;
}
a:hover { color: var(--c-accent-hover); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol { list-style: none; }

/* ---- 滚动条美化 ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-muted); }

/* ---- 可访问性 ---- */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ---- 分栏布局系统（纯电脑端，左右比例分栏） ---- */
.split-layout {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
}
.split-sidebar {
  flex: 0 0 38%;
  min-width: 360px;
  max-width: 520px;
}
.split-main {
  flex: 1;
  min-width: 0;
}

/* ---- 内容容器（纯电脑端，宽度自适应铺满） ---- */
#content {
  width: 100%;
  margin: 0 auto;
  padding: var(--content-padding);
  /* 顶部 = 固定导航栏高度 + 内容内边距，给标题留呼吸空间 */
  padding-top: calc(var(--nav-height) + var(--content-padding));
  padding-bottom: var(--content-padding-bottom);
  min-height: calc(100vh - var(--nav-height) - var(--space-16));
}

/* ---- 页面标题 ---- */
.page-header { margin-bottom: var(--space-4); }
.page-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin-bottom: var(--space-1);
}
.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

/* ---- 工具类 ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--c-text-muted); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-error { color: var(--c-error); }
.font-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }

/* ---- 加载动画 ---- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--c-border-strong);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  text-align: center;
  padding: var(--space-8) 0;
}

/* ---- 空状态 ---- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--c-text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}
.empty-state-text {
  font-size: var(--fs-sm);
}

/* ---- 响应式断点 ---- */
/* 手机 (<768px): 侧边栏隐藏，汉堡唤出 */
/* 平板 (768-1024px): 放宽内边距 */
@media (min-width: 768px) {
  :root { --content-padding: var(--space-6); }
}

/* 桌面 (>1024px): 更宽内边距 */
@media (min-width: 1024px) {
  :root { --content-padding: var(--space-8); }
}

/* ---- 打印样式（报告） ---- */
@media print {
  .top-nav, .sidebar, .sidebar-overlay, .print-hide { display: none !important; }
  body { padding-left: 0 !important; }
  #content { max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
  .card, .report { box-shadow: none; border: 1px solid #ddd; }
}

/* ---- 动画 ---- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn var(--transition) ease; }
.slide-up { animation: slideUp var(--transition) ease; }
