/* ========================================
   Teide Documentation - Design System
   Matches teidedb.com visual identity
   ======================================== */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  --primary: #4b6777;
  --primary-dark: #3a5261;
  --primary-pale: #dce8ee;
  --bg-cream: #f7f5f2;
  --bg-surface: #ffffff;
  --code-bg: #0e1b24;
  --code-fg: #e4e8eb;
  --text: #1c2d38;
  --text-gray: #6b7f8e;
  --text-light: #8fa3b0;
  --border: #d8dfe4;
  --border-light: #e8edf0;
  --accent-green: #4a9;
  --accent-orange: #e89b50;
  --accent-red: #d46;
  --sidebar-w: 260px;
  --header-h: 0px;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 100px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
  --font-heading: 'Oswald', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- 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-body);
  color: var(--text);
  background: var(--bg-cream);
  line-height: 1.65;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  z-index: 100;
  padding: 24px 0;
  transition: transform .3s ease;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 20px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--text);
}
.sidebar-logo svg, .sidebar-logo img { width: 32px; height: 22px; flex-shrink: 0; }
.sidebar-logo span {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.sidebar-logo .docs-badge {
  font-family: var(--font-body);
  font-size: .65rem;
  font-weight: 500;
  background: var(--primary-pale);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 0 24px;
  margin-bottom: 8px;
}
.sidebar-section-label {
  font-family: var(--font-heading);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-gray);
  margin-bottom: 6px;
  padding: 12px 0 4px;
}
.sidebar-link {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  transition: all .15s;
  line-height: 1.5;
}
.sidebar-link:hover {
  background: var(--bg-cream);
  color: var(--primary-dark);
}
.sidebar-link.active {
  background: var(--primary-pale);
  color: var(--primary-dark);
  font-weight: 500;
}

/* --- Mobile hamburger --- */
.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.hamburger svg { width: 20px; height: 20px; color: var(--text); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 90;
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.content, main.content {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}
main.content {
  margin-left: max(var(--sidebar-w), calc(50% - 410px));
  margin-right: auto;
}

/* --- Typography --- */
.section-label {
  font-family: var(--font-heading);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-gray);
  margin-bottom: 8px;
}
h1 {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 16px;
}
h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  margin: 48px 0 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
h2:first-of-type { border-top: none; margin-top: 32px; }
h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 12px;
}
h4 {
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 24px 0 8px;
}
p { margin-bottom: 16px; }
.lead {
  font-size: 1.1rem;
  color: var(--text-gray);
  line-height: 1.7;
  margin-bottom: 32px;
}
strong { font-weight: 600; }

/* --- Code --- */
code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--primary-pale);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 16px 0 24px;
  line-height: 1.55;
  font-size: .875rem;
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* Syntax highlighting inside code blocks */
.kw { color: #7eb8da; }      /* keywords: SELECT, FROM, WHERE */
.fn { color: #9cd4a0; }      /* functions: COUNT, SUM */
.str { color: #e8c077; }     /* strings */
.num { color: #d4a07e; }     /* numbers */
.cm { color: #5f7a87; }      /* comments */
.op { color: #a8bec9; }      /* operators */
.ty { color: #c9a7e0; }      /* types */

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: .9rem;
}
thead th {
  font-family: var(--font-heading);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-gray);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
tbody tr:hover { background: var(--bg-cream); }
td code {
  font-size: .82em;
  white-space: nowrap;
}

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  transition: box-shadow .2s, transform .2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin: 24px 0;
}
.card-num {
  font-family: var(--font-heading);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-gray);
  margin-bottom: 8px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.card p {
  font-size: .9rem;
  color: var(--text-gray);
  margin: 0;
  line-height: 1.55;
}

/* --- Notes / Callouts --- */
.note {
  background: var(--primary-pale);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: .9rem;
}
.note p { margin: 0; }
.note strong { color: var(--primary-dark); }
.warn {
  background: #fef4e8;
  border-left-color: var(--accent-orange);
}
.warn strong { color: #b07030; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-pale);
}

/* --- Hero (landing page) --- */
.hero {
  text-align: center;
  padding: 64px 0 48px;
}
.hero h1 {
  font-size: 3rem;
  margin-bottom: 16px;
}
.hero .lead {
  max-width: 560px;
  margin: 0 auto 32px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Output block (results) --- */
.output {
  background: #f0f2f4;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: -8px 0 24px;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* --- Lists --- */
ul, ol { margin: 8px 0 16px 24px; }
li { margin-bottom: 6px; }
li code { font-size: .83em; }

/* --- Prev / Next navigation --- */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all .15s;
  max-width: 50%;
  font-weight: 500;
  color: var(--text);
}
.page-nav a:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  color: var(--primary-dark);
}
.page-nav a.prev::before {
  content: 'Previous';
  font-family: var(--font-heading);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-gray);
}
.page-nav a.next::before {
  content: 'Next';
  font-family: var(--font-heading);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-gray);
}
.page-nav .nav-label { display: none; } /* hide when using ::before */
.page-nav .nav-title { font-weight: 500; color: var(--text); }
.page-nav .next { margin-left: auto; text-align: right; }

/* --- Syntax block label --- */
.syntax-label {
  font-family: var(--font-heading);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-gray);
  margin-bottom: 6px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }
  .main, main.content { margin-left: 0; }
  .content { padding: 72px 24px 60px; }
  .card-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.2rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
}

@media (max-width: 600px) {
  .content { padding: 64px 16px 48px; }
  pre { padding: 16px; font-size: .8rem; border-radius: var(--radius-sm); }
  table { font-size: .82rem; }
  thead th, tbody td { padding: 8px 10px; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: 100%; }
}

/* --- Scrollbar --- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-thumb {
  background: #2a3d4a;
  border-radius: 2px;
}

/* --- Utility --- */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-gray { color: var(--text-gray); }
.text-sm { font-size: .875rem; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
