/* 四维创界 - 布局模板
 * 三种共享布局:工作室布局 / 后台布局 / 文档布局
 * 含 topnav / sidebar / nav-rail / drawer 等结构性组件
 */

/* ========== 顶部导航 Topnav(全站统一) ========== */
.topnav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-height);
  background: rgba(8, 17, 15, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
 }

.topnav-inner {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

/* 品牌区 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  flex-shrink: 0;
}
.brand:hover {
  color: var(--text-primary);
}
.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  object-fit: cover;
  display: block;
  transition: box-shadow var(--transition-base);
}
.brand:hover .brand-logo {
  box-shadow: var(--shadow-accent-glow);
}

/* 主导航链接 */
.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  margin-left: var(--space-8);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  position: relative;
  transition: color var(--transition-fast),
              background var(--transition-fast);
}
.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.nav-link-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
.nav-link-button:focus-visible {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
}
/* 联动:topnav 与 nav-rail 的 active 视觉语言一致
 * - 主色背景 + 主色文字
 * - ::before 左侧装饰条(与 nav-rail-btn.is-active::before 呼应)
 * - ::after 底部下划线(primary 渐变,视觉锚点) */
.nav-link.is-active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: var(--font-weight-semibold);
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--primary-500);
  box-shadow: 0 0 8px rgba(22, 199, 183, 0.5);
}
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--primary-500),
    transparent);
  border-radius: var(--radius-full);
  opacity: 0.9;
}

/* 顶栏右侧操作 */
.topnav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* 顶栏波浪(品牌签名动效,保留) */
.topbar-wave {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 24px;
  pointer-events: none;
  opacity: 0.38;
  z-index: 0;
}
.topbar-wave svg {
  width: 100%;
  height: 100%;
  display: block;
}
.topbar-wave .wave-path {
  fill: none;
  stroke: #18d8c8;
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: 0.54;
  filter: drop-shadow(0 0 4px rgba(24, 216, 200, 0.16));
  animation: topbar-cyan-breathe 3.8s ease-in-out infinite;
}
.topbar-wave .wave-path + .wave-path {
  opacity: 0.34;
  animation-delay: -1.9s;
}
@keyframes topbar-cyan-breathe {
  0%,
  100% {
    stroke: #16cfc0;
    opacity: 0.42;
    filter: drop-shadow(0 0 3px rgba(22, 207, 192, 0.14));
  }
  50% {
    stroke: #6ffff4;
    opacity: 0.88;
    filter: drop-shadow(0 0 10px rgba(111, 255, 244, 0.5));
  }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-wave .wave-path {
    animation: none;
    stroke: #18d8c8;
    opacity: 0.62;
    filter: none;
  }
}

/* ========== 后台布局(后台布局) - dashboard/admin 共享 ========== */
.layout-admin {
  display: flex;
  min-height: 100vh;
}

/* 侧栏 */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-header {
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-default);
}
.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}
.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-4) var(--space-3) var(--space-2);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}
.sidebar-link:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.sidebar-link.is-active {
  background: var(--primary-50);
  color: var(--primary-700);
}
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-default);
}

/* 主内容区 */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.admin-content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max-width);
  width: 100%;
}
.admin-content-header {
  margin-bottom: var(--space-6);
}
.admin-content-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.admin-content-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* 后台栅格 */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
}
@media (max-width: 1024px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== 工作室布局(Studio) - simple_generate/video_generate 共享 ========== */
.layout-studio {
  --bg-base: #0B1716;
  --bg-subtle: rgba(19, 45, 41, 0.82);
  --bg-elevated: rgba(22, 50, 45, 0.84);
  --border-default: rgba(201, 255, 247, 0.17);
  --border-strong: rgba(201, 255, 247, 0.29);
  --border-subtle: rgba(201, 255, 247, 0.1);
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(58, 173, 157, 0.12), transparent 32%),
    linear-gradient(145deg, #0d201d 0%, #0c1b19 44%, var(--bg-base) 100%);
}

/* 左侧圆形导航栏 Nav Rail */
.nav-rail {
  width: var(--nav-rail-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) 0;
  gap: var(--space-2);
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: var(--z-sticky);
}
.nav-rail-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  margin-bottom: var(--space-4);
}
.nav-rail-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.nav-rail-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.nav-rail-btn.is-active {
  background: var(--primary-50);
  color: var(--primary-600);
}
/* 联动:与 topnav nav-link.is-active 视觉语言一致
 * - 左侧 3px 主色装饰条(垂直锚点)
 * - 主色光晕呼应顶部圆点 */
.nav-rail-btn.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary-500);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px rgba(22, 199, 183, 0.44);
}
/* active 状态 hover 时光晕扩散 */
.nav-rail-btn.is-active:hover {
  background: var(--primary-100);
  color: var(--primary-700);
}
.nav-rail-spacer {
  flex: 1;
}

/* 工作区主内容 */
.studio-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.studio-topbar {
  height: var(--topbar-height);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  position: relative;
  gap: var(--space-4);
}
.studio-topbar-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}
.studio-topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* 工作区双列布局 */
.studio-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(360px, 1fr);
  gap: var(--space-6);
  padding: var(--space-6);
  align-items: start;
}
@media (max-width: 1280px) {
  .studio-workspace {
    grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
  }
}
@media (max-width: 1024px) {
  .studio-workspace {
    grid-template-columns: 1fr;
  }
}

.studio-edit-column {
  min-width: 0;
}
.studio-result-column {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-6));
}
@media (max-width: 1024px) {
  .studio-result-column {
    position: static;
  }
}

/* 工作区面板组 */
.studio-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  overflow: hidden;
}
.studio-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
}
.studio-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.studio-section-body {
  padding: var(--space-5);
}

/* ========== 文档布局(Doc) - disclaimer/privacy/terms 共享 ========== */
.layout-doc {
  position: relative;
  min-height: 100vh;
  background: var(--bg-base);
  overflow-x: hidden;
  counter-reset: doc-section;
}

/* 装饰背景层:product register 禁用,隐藏保留 DOM 节点 */
.doc-ambient {
  display: none;
}

/* 点阵 grid pattern,极低饱和度 */
.doc-ambient-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(201, 255, 247, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  mask-image: radial-gradient(ellipse at center top, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center top, black 0%, transparent 70%);
}

/* 三层 ambient glow(主色 + 青色辅色 + violet 变体,色温对比) */
.doc-ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.doc-ambient-glow--primary {
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 760px;
  height: 480px;
  background: radial-gradient(ellipse, rgba(22, 199, 183, 0.13), transparent 70%);
  animation-delay: 0s;
}
.doc-ambient-glow--accent {
  top: 100px;
  right: -120px;
  width: 440px;
  height: 440px;
  background: radial-gradient(ellipse, rgba(38, 198, 184, 0.1), transparent 70%);
  animation-delay: -9s;
}
.doc-ambient-glow--violet {
  top: 320px;
  left: -100px;
  width: 380px;
  height: 380px;
  background: radial-gradient(ellipse, rgba(139, 92, 246, 0.18), transparent 70%);
  animation-delay: -5s;
}

/* doc-ambient-drift / doc-shape-float 复用 base.css 的 ambient-drift-centered / shape-float */

/* 几何装饰图形(克制,不喧宾夺主) */
.doc-ambient-shape {
  position: absolute;
  display: block;
}
.doc-ambient-shape--ring {
  top: 220px;
  left: 8%;
  width: 120px;
  height: 120px;
  border: 1.5px solid rgba(22, 199, 183, 0.16);
  border-radius: 50%;
  animation-delay: 0s;
}
.doc-ambient-shape--blob {
  top: 380px;
  right: 10%;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, rgba(22, 199, 183, 0.18), rgba(255, 255, 255, 0.08));
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation-delay: -4s;
  filter: blur(0.5px);
}
.doc-ambient-shape--square {
  top: 560px;
  left: 14%;
  width: 14px;
  height: 14px;
  background: var(--primary-400);
  border-radius: 3px;
  transform: rotate(45deg);
  opacity: 0.6;
  animation-delay: -8s;
}

.doc-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

/* 返回链接:纯色 + 单层 box-shadow,hover 上浮传达交互态 */
.doc-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  text-decoration: none;
  margin-bottom: var(--space-6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-base) var(--ease-out),
              color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-base);
}
.doc-back-link:hover {
  transform: translateY(-1px);
  border-color: var(--primary-300);
  color: var(--primary-600);
  box-shadow: 0 4px 8px rgba(22, 199, 183, 0.08);
}
.doc-back-link:focus-visible {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(22, 199, 183, 0.22);
}

/* Panel:纯色 var(--bg-elevated) + 单层 box-shadow(blur ≤ 8px) */
.doc-panel {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: none;
  padding: 40px 48px;
  overflow: hidden;
  transition: box-shadow var(--transition-base) var(--ease-out);
}
/* hover: 单层阴影加深,传达交互态 */
.doc-panel:hover {
  box-shadow: none;
}

/* 顶部图标容器(纯色徽标) */
.doc-panel-icon {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-4);
  color: var(--primary-600);
  background: rgba(22, 199, 183, 0.1);
  border: 1px solid rgba(22, 199, 183, 0.18);
  border-radius: 14px;
  box-shadow: 0 2px 4px rgba(22, 199, 183, 0.07);
}

.doc-title {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-4);
}

/* 引言:padding + 纯色 background tint,移除 side-stripe */
.doc-intro {
  position: relative;
  z-index: 1;
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-8);
  padding: var(--space-5) var(--space-6);
  background: rgba(22, 199, 183, 0.055);
  border-radius: 8px;
}

/* 章节序号视觉化 */
.doc-section {
  position: relative;
  padding: var(--space-6) 0;
  border-top: 1px solid var(--border-subtle);
}
.doc-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.doc-section h2 {
  display: flex;
  align-items: center;
  position: relative;
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-4);
  counter-increment: doc-section;
}
/* 数字徽标(CSS counter 自动编号,结构性元素,纯色 + 单层阴影) */
.doc-section h2::before {
  content: counter(doc-section, decimal-leading-zero);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-right: var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  color: var(--primary-600);
  background: rgba(22, 199, 183, 0.1);
  border: 1px solid rgba(22, 199, 183, 0.2);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(22, 199, 183, 0.07);
}

/* 章节段落与列表排版优化 */
.doc-section p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: var(--space-3) 0;
}
.doc-section p:first-of-type {
  margin-top: 0;
}
.doc-section ul {
  margin: var(--space-3) 0;
  padding-left: var(--space-6);
  list-style: none;
}
.doc-section ul li {
  position: relative;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: var(--space-2) 0;
  padding-left: var(--space-4);
}
/* 自定义列表 marker(纯色点,移除光晕) */
.doc-section ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-500);
}

/* 结尾 muted 注释升级为信息块 */
.doc-muted {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  margin-top: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--border-subtle);
}

/* prefers-reduced-motion: 禁用所有装饰动画和 transform */
@media (prefers-reduced-motion: reduce) {
  .doc-ambient-glow,
  .doc-ambient-shape {
    animation: none;
  }
  .doc-back-link:hover {
    transform: none;
  }
}

/* 移动端响应式: 装饰图形隐藏,降低 padding */
@media (max-width: 640px) {
  .doc-ambient-shape--ring,
  .doc-ambient-shape--blob {
    display: none;
  }
  .doc-ambient-glow--violet {
    display: none;
  }
  .doc-page {
    padding: var(--space-6) var(--space-4);
  }
  .doc-panel {
    padding: var(--space-6) var(--space-5);
  }
  .doc-title {
    font-size: var(--text-2xl);
  }
  .doc-intro {
    padding: var(--space-4) var(--space-4);
  }
  .doc-section h2 {
    font-size: var(--text-lg);
  }
  .doc-section h2::before {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
  }
}

/* ========== 抽屉 Drawer(工作室左侧抽屉) ========== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  transform: translateX(-100%);
  transition: transform var(--transition-base) var(--ease-out);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
}
.drawer-header {
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
}
.drawer-body {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

/* ========== 响应式:移动端隐藏侧栏 ========== */
@media (max-width: 768px) {
  .topnav-inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }
  .nav-links {
    display: none;
  }
  .topnav-actions {
    margin-left: auto;
  }
  .topnav-actions .btn-sm {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: var(--z-modal);
  }
  .nav-rail {
    display: none;
  }
  .studio-workspace {
    padding: var(--space-4);
  }
}
