/**
 * DigitConnection Studio - 统一公共样式
 * 深色主题 · 开发者控制台风格
 */

/* ========== 设计变量 ========== */
:root {
  --studio-surface: #0d1117;
  --studio-surface-alt: #161b22;
  --studio-surface-card: #21262d;
  --studio-border: #30363d;
  --studio-accent: #58a6ff;
  --studio-accent-green: #3fb950;
  --studio-text: #f0f6fc;
  --studio-text-muted: #8b949e;
  --studio-radius: 0.75rem;
  --studio-radius-sm: 0.5rem;
  --studio-transition: 150ms ease;
}

/* ========== 基础 ========== */
body {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background-color: var(--studio-surface);
  color: var(--studio-text);
  -webkit-overflow-scrolling: touch;
}

/* ========== 统一导航栏 ========== */
.studio-sidebar {
  width: 13rem;
  background-color: var(--studio-surface-alt);
  border-right: 1px solid var(--studio-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* ========== 移动端：抽屉式侧栏 ========== */
@media (max-width: 767px) {
  .studio-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(18rem, 85vw);
    transform: translateX(-100%);
    box-shadow: none;
    border-right: 1px solid var(--studio-border);
  }

  body.drawer-open .studio-sidebar {
    transform: translateX(0);
    box-shadow: 0.25rem 0 1.5rem rgba(0, 0, 0, 0.5);
  }

  body.drawer-open {
    overflow: hidden;
  }

  .studio-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    cursor: pointer;
  }

  body.drawer-open .studio-drawer-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .studio-mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--studio-surface-alt);
    border-bottom: 1px solid var(--studio-border);
    flex-shrink: 0;
    min-height: 3rem;
  }

  .studio-mobile-header .studio-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--studio-border);
    border-radius: 0.5rem;
    background: var(--studio-surface-card);
    color: var(--studio-text);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .studio-mobile-header .studio-menu-btn:hover,
  .studio-mobile-header .studio-menu-btn:focus {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--studio-accent);
  }

  .studio-mobile-header .studio-menu-btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .studio-mobile-header .studio-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--studio-text);
  }
}

@media (min-width: 768px) {
  .studio-mobile-header {
    display: none;
  }

  .studio-drawer-overlay {
    display: none !important;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0 0.5rem 0.5rem 0;
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  color: var(--studio-text-muted);
  transition: background var(--studio-transition), color var(--studio-transition);
}

.nav-item:hover {
  color: #e6edf3;
}

@media (max-width: 767px) {
  .nav-item {
    min-height: 2.75rem;
    padding: 0.75rem 1rem;
  }
}

.nav-item.active {
  border-left-color: var(--studio-accent);
  background: rgba(88, 166, 255, 0.1);
  color: var(--studio-text);
}

/* ========== 统一卡片样式 ========== */
.studio-card {
  border-radius: var(--studio-radius);
  border: 1px solid var(--studio-border);
  background-color: var(--studio-surface-card);
  transition: border-color var(--studio-transition), background-color var(--studio-transition);
}

.studio-card:hover {
  border-color: rgba(88, 166, 255, 0.5);
  background-color: rgba(88, 166, 255, 0.06);
}

.studio-card-link {
  display: block;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: inherit;
}

.studio-card-link:hover {
  color: inherit;
}

/* 主内容区：移动端为固定顶栏留出空间 */
@media (max-width: 767px) {
  .studio-layout {
    padding-top: 3rem;
  }
}

/* 页面头部 */
.studio-page-header {
  border-bottom: 1px solid var(--studio-border);
  padding: 1rem 1rem 1.25rem;
  background: rgba(22, 27, 34, 0.5);
}

@media (min-width: 768px) {
  .studio-page-header {
    padding: 1.5rem 2rem;
  }
}

.studio-page-header h1 {
  font-size: 1.25rem;
  font-weight: 500;
}

.studio-page-header p {
  font-size: 0.875rem;
  color: var(--studio-text-muted);
  margin-top: 0.25rem;
}

.studio-page-header--hero {
  padding: 2.5rem 2rem;
}

@media (min-width: 640px) {
  .studio-page-header--hero { padding: 3rem 2rem; }
  .studio-page-header--hero h1 { font-size: 1.875rem; }
}

/* 内容区 */
.studio-content {
  padding: 1rem;
}

@media (min-width: 640px) {
  .studio-content { padding: 1.5rem 2rem; }
}

@media (min-width: 768px) {
  .studio-content { padding: 2rem; }
}

/* 卡片网格 */
.studio-grid {
  display: grid;
  gap: 1.25rem;
}

.studio-grid-1 { grid-template-columns: 1fr; }
.studio-grid-2 { grid-template-columns: repeat(2, 1fr); }
.studio-grid-3 { grid-template-columns: repeat(3, 1fr); }
.studio-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (min-width: 640px) {
  .studio-grid-sm-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .studio-grid-lg-3 { grid-template-columns: repeat(3, 1fr); }
  .studio-grid-lg-4 { grid-template-columns: repeat(4, 1fr); }
}

/* 按钮 / 标签 */
.studio-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: var(--studio-radius-sm);
  font-size: 0.875rem;
  transition: all var(--studio-transition);
}

.studio-btn-primary {
  background: rgba(88, 166, 255, 0.2);
  color: var(--studio-accent);
}

.studio-btn-primary:hover {
  background: rgba(88, 166, 255, 0.3);
}

.studio-btn-ghost {
  border: 1px solid var(--studio-border);
  color: var(--studio-text-muted);
}

.studio-btn-ghost:hover {
  border-color: rgba(88, 166, 255, 0.5);
  color: var(--studio-accent);
}

/* 状态标签 */
.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--studio-radius-sm);
  font-size: 0.875rem;
}

.studio-badge-green {
  background: rgba(63, 185, 80, 0.2);
  color: var(--studio-accent-green);
}

/* 表格行悬停 */
.studio-table-row:hover {
  background: rgba(88, 166, 255, 0.06);
}

/* 兼容：卡片悬停（统一卡片样式） */
.card-entry:hover,
.module-card:hover,
.tool-card:hover,
.doc-card:hover {
  border-color: rgba(88, 166, 255, 0.5);
  background-color: rgba(88, 166, 255, 0.06);
}

/* ========== Docs Typography（深色主题） ========== */
.docs-prose {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: #e6edf3;
}

.docs-prose h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: #58a6ff;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--studio-border);
}

.docs-prose h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #8b949e;
  margin: 2rem 0 0.75rem;
}

.docs-prose h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #c9d1d9;
  margin: 1.5rem 0 0.5rem;
}

.docs-prose p {
  margin: 0.75rem 0;
}

.docs-prose ul, .docs-prose ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.docs-prose li {
  margin: 0.375rem 0;
}

.docs-prose li::marker {
  color: var(--studio-text-muted);
}

.docs-prose blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--studio-accent);
  background: rgba(88, 166, 255, 0.08);
  color: var(--studio-text-muted);
}

.docs-prose pre {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--studio-surface-alt);
  border: 1px solid var(--studio-border);
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

.docs-prose code {
  background: rgba(88, 166, 255, 0.15);
  color: #79c0ff;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.docs-prose pre code {
  background: none;
  padding: 0;
  color: #e6edf3;
}

.docs-prose table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
}

.docs-prose th, .docs-prose td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--studio-border);
  text-align: left;
}

.docs-prose th {
  background: var(--studio-surface-alt);
  color: var(--studio-text-muted);
  font-weight: 500;
}

.docs-prose tr:hover td {
  background: rgba(88, 166, 255, 0.04);
}

.docs-prose a {
  color: var(--studio-accent);
  text-decoration: none;
}

.docs-prose a:hover {
  text-decoration: underline;
}

.docs-prose hr {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--studio-border);
}
