/* AI-Stream — Wiki de estudo IA + Stack Microsoft */
/* Tema: dark (padrão) / light toggle */

:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --border: #30363d;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --info: #58a6ff;
  --code-bg: #1a1f2b;
  --callout-insight: #1f3a5f;
  --callout-warning: #3d2e00;
  --callout-connection: #1a3a2a;
  --callout-microsoft: #1a1a3a;
  --callout-deep: #2a1a3a;
  --callout-challenge: #3a1a1a;
  --sidebar-width: 280px;
  --header-height: 60px;
  --max-content: 860px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --text: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --border: #d0d7de;
  --code-bg: #f0f3f6;
  --callout-insight: #ddf4ff;
  --callout-warning: #fff8c5;
  --callout-connection: #dafbe1;
  --callout-microsoft: #e8e8ff;
  --callout-deep: #f0e8ff;
  --callout-challenge: #ffe8e8;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
}

.site-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-header .logo span { color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle, .menu-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.theme-toggle:hover, .menu-toggle:hover { background: var(--border); }

.menu-toggle { display: none; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar-section { padding: 0 1rem; margin-bottom: 1.5rem; }
.sidebar-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.sidebar-nav a:hover { background: var(--bg-tertiary); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--bg-tertiary); color: var(--accent); font-weight: 600; }
.sidebar-nav a.done::before { content: '✓ '; color: var(--success); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 2rem;
  min-height: calc(100vh - var(--header-height));
}

.content-wrapper {
  max-width: var(--max-content);
  margin: 0 auto;
}

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.75rem; line-height: 1.3; }
h2 { font-size: 1.35rem; font-weight: 600; margin-top: 2rem; margin-bottom: 0.5rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.4rem; }
p { margin-bottom: 1rem; }
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: 0.3rem; }
strong { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.875em; background: var(--code-bg); padding: 0.15em 0.4em; border-radius: 4px; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; overflow-x: auto; margin-bottom: 1rem; position: relative; }
pre code { background: none; padding: 0; font-size: 0.85rem; line-height: 1.5; }
blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--text-secondary); margin-bottom: 1rem; }

/* Topic header */
.topic-header { margin-bottom: 2rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.breadcrumb a { color: var(--text-secondary); }
.meta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }

/* Copy ID button */
.copy-id {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.copy-id:hover { background: var(--border); color: var(--text); }
.copy-id.copied { background: var(--success); color: white; border-color: var(--success); }

/* Copy code button */
.code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}
pre:hover .code-copy { opacity: 1; }
.code-copy.copied { background: var(--success); color: white; }

/* TL;DR */
.tldr {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.tldr h2 { margin-top: 0; border: none; padding: 0; font-size: 1rem; color: var(--accent); }

/* Callouts */
.callout {
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}
.callout-title { font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }
.callout-insight { background: var(--callout-insight); border-color: var(--info); }
.callout-warning { background: var(--callout-warning); border-color: var(--warning); }
.callout-connection { background: var(--callout-connection); border-color: var(--success); }
.callout-microsoft { background: var(--callout-microsoft); border-color: #7c7cff; }
.callout-deep { background: var(--callout-deep); border-color: #b07cff; }
.callout-challenge { background: var(--callout-challenge); border-color: var(--danger); }

/* Connections */
.connections ul { list-style: none; padding: 0; }
.connections li { padding: 0.3rem 0; }

/* Sources */
.sources ol { font-size: 0.9rem; }
.sources li { margin-bottom: 0.4rem; }

/* Mark as read */
.mark-read {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.mark-read:hover { background: var(--success); color: white; border-color: var(--success); }
.mark-read.read { background: var(--success); color: white; border-color: var(--success); }

/* Footer nav */
.topic-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.topic-footer .next {
  background: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.2s;
}
.topic-footer .next:hover { background: var(--accent-hover); text-decoration: none; }

/* Home / Index cards */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.module-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}

.module-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card h3 { margin-top: 0; font-size: 1rem; }
.module-card .module-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.module-card .progress-bar { height: 4px; background: var(--bg-tertiary); border-radius: 2px; margin-top: 0.75rem; overflow: hidden; }
.module-card .progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-done { background: var(--success); color: white; }
.badge-progress { background: var(--warning); color: #1a1a1a; }
.badge-pending { background: var(--bg-tertiary); color: var(--text-muted); }

/* Search */
.search-container { margin-bottom: 2rem; }
.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }
.search-results { margin-top: 1rem; }
.search-result { padding: 0.75rem; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.5rem; }
.search-result h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.search-result p { font-size: 0.85rem; color: var(--text-secondary); margin: 0; }

/* Mermaid */
.mermaid { margin: 1.5rem 0; text-align: center; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .module-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  .meta { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

/* Print */
@media print {
  .site-header, .sidebar, .theme-toggle, .menu-toggle, .copy-id, .code-copy, .mark-read, .search-container { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
  body { background: white; color: black; font-size: 12pt; }
  a { color: black; text-decoration: underline; }
  a::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #666; }
  pre { border: 1px solid #ccc; }
  .callout { border-left: 3px solid #999; background: #f5f5f5; }
  .module-card { break-inside: avoid; }
}
