/* ==========================================================================
   mysql-safe - Professional Code Editor Theme (play.kysely.dev style)
   Zero emojis, zero gradients, authentic syntax highlighting.
   ========================================================================== */

:root {
  --bg-main: #141414;
  --bg-editor: #181818;
  --bg-surface: #1e1e1e;
  --bg-surface-elevated: #252526;
  --bg-surface-hover: #2d2d2d;
  --bg-code: #161616;
  
  --border-subtle: #2d2d2d;
  --border-strong: #3e3e3e;
  --border-accent: #007acc;

  --text-primary: #abb2bf;
  --text-bright: #ffffff;
  --text-secondary: #8b949e;
  --text-muted: #5c6370;
  --text-accent: #61afef;

  --accent-blue: #007acc;
  --accent-blue-hover: #1f8ad2;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Menlo, Monaco, monospace;

  --radius-sm: 3px;
  --radius-md: 4px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: #4f4f4f;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background: #181818;
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-bright);
  font-weight: 700;
  font-size: 0.95rem;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.75rem;
}

.version-tag {
  font-size: 0.72rem;
  padding: 2px 6px;
  background: #252526;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #252526;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.search-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.search-trigger kbd {
  background: #181818;
  border: 1px solid var(--border-strong);
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 120ms ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-bright);
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #252526;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.select-input {
  background: #252526;
  border: 1px solid var(--border-subtle);
  color: var(--text-bright);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.select-input:hover {
  border-color: var(--border-strong);
}

/* Documentation Layout */
.docs-layout {
  display: flex;
  min-height: calc(100vh - 48px);
}

.docs-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #181818;
  border-right: 1px solid var(--border-subtle);
  padding: 20px 12px;
  overflow-y: auto;
  position: sticky;
  top: 48px;
  height: calc(100vh - 48px);
}

.sidebar-group {
  margin-bottom: 20px;
}

.sidebar-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding: 0 8px;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.84rem;
}

.sidebar-item a:hover {
  color: var(--text-bright);
  background: var(--bg-surface-hover);
}

.sidebar-item a.active {
  color: #61afef;
  background: #252526;
  font-weight: 600;
}

.docs-main {
  flex: 1;
  max-width: 860px;
  padding: 36px 40px 80px;
  margin: 0 auto;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: #61afef;
}

.doc-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--text-bright);
}

.doc-lead {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.doc-section {
  margin-bottom: 36px;
}

.doc-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-bright);
}

.doc-section p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.doc-section ul, .doc-section ol {
  margin-bottom: 18px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.doc-section li {
  margin-bottom: 6px;
}

.callout {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 20px 0;
  background: #1e1e1e;
  border-left: 3px solid var(--accent-blue);
  font-size: 0.88rem;
}

.callout strong {
  color: var(--text-bright);
}

.code-container {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #1e1e1e;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.72rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-bright);
}

pre code {
  display: block;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  color: #abb2bf;
}

:not(pre) > code {
  background: #252526;
  border: 1px solid var(--border-subtle);
  color: #e5c07b;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.table-wrapper {
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.doc-table th {
  background: #1e1e1e;
  color: var(--text-bright);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

.doc-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.doc-table tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Playground Split Layout
   ========================================================================== */

.playground-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--bg-main);
}

.playground-split {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  flex: 1;
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-editor);
}

.pane:last-child {
  border-right: none;
  background: #141414;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #181818;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pane-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 2px;
  background: #252526;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Dual-Layer Code Editor Container */
.editor-container {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-editor);
}

.line-numbers {
  width: 42px;
  padding: 12px 6px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  color: #4b5263;
  background: #181818;
  user-select: none;
  border-right: 1px solid #232323;
  overflow: hidden;
}

.editor-surface {
  position: relative;
  flex: 1;
  height: 100%;
  overflow: hidden;
  background: var(--bg-editor);
}

/* Highlight Layer */
.editor-highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  tab-size: 2;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
  box-sizing: border-box;
}

.editor-highlight code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  background: transparent;
  padding: 0;
  border: none;
}

/* Transparent Overlay Textarea */
.code-textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 12px 14px;
  background: transparent;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  caret-color: #528bff !important;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  tab-size: 2;
  white-space: pre;
  overflow-y: auto;
  overflow-x: auto;
  z-index: 2;
  box-sizing: border-box;
}

.output-panel {
  flex: 1;
  background: #141414;
  padding: 14px;
  overflow-y: auto;
  font-family: var(--font-mono);
}

.sql-output-box {
  background: #1a1a1a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  color: #abb2bf;
  font-size: 13px;
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}

.params-output-box {
  background: #181818;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
  color: #d19a66;
}

/* ==========================================================================
   TypeScript & SQL Syntax Highlight Colors (Matching play.kysely.dev)
   ========================================================================== */

.syn-kw {
  color: #ff7b72 !important; /* Pink/Magenta: import, export, from, const, interface, type */
  font-weight: 600;
}

.syn-type {
  color: #79c0ff !important; /* Cyan/Blue: string, number, boolean, Schema, Generated */
}

.syn-str {
  color: #a5d6ff !important; /* Light blue/green for strings */
}

.syn-num {
  color: #79c0ff !important; /* Number constants */
}

.syn-bool {
  color: #ff7b72 !important; /* Boolean constants */
}

.syn-fn {
  color: #d2a8ff !important; /* Purple for method calls */
}

.syn-prop {
  color: #ffa657 !important; /* Orange/Yellow for property names */
}

.syn-comment {
  color: #8b949e !important; /* Muted gray for comments */
  font-style: italic;
}

.syn-sql-kw {
  color: #79c0ff !important; /* Blue for SQL verbs: SELECT, FROM, WHERE, JOIN */
  font-weight: 700;
}

.syn-sql-ident {
  color: #f0f6fc !important;
}

.syn-sql-param {
  color: #ffa657 !important;
  font-weight: 700;
}

.syn-sql-str {
  color: #a5d6ff !important;
}

.syn-sql-num {
  color: #79c0ff !important;
}

/* Pool Panel */
.pool-simulator-panel {
  border-top: 1px solid var(--border-subtle);
  background: #181818;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sim-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-bright);
}

.sim-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sim-metric-card {
  background: #1e1e1e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.metric-value {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-bright);
  margin-top: 1px;
}

.metric-value.active { color: #79c0ff; }
.metric-value.idle { color: #7ee787; }
.metric-value.queue { color: #ffa657; }

.pool-visual-meter {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 14px;
  background: #121212;
  border-radius: 2px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.conn-pill {
  flex: 1;
  height: 100%;
  border-radius: 1px;
  transition: background 150ms ease;
}

.conn-pill.active { background: #007acc; }
.conn-pill.idle { background: #238636; }
.conn-pill.empty { background: #252526; }

/* Search Modal */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.search-modal-backdrop.open { display: flex; }

.search-modal {
  width: 100%;
  max-width: 540px;
  background: #1e1e1e;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.search-input-box {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

.search-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.92rem;
  color: var(--text-bright);
}

.search-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  list-style: none;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.search-result-item:hover {
  background: var(--bg-surface-hover);
}

.result-section-name {
  font-size: 0.7rem;
  color: var(--accent-blue);
  font-weight: 600;
  text-transform: uppercase;
}

.result-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-bright);
}

.result-snippet {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

@media (max-width: 900px) {
  .playground-split { grid-template-columns: 1fr; }
  .docs-sidebar { display: none; }
  .docs-main { padding: 20px 16px; }
}
