/* ==========================================================================
   SQLite FTS5 Query Demo — Dark Theme Stylesheet
   ========================================================================== */

:root {
  --bg-canvas:    #0d1117;
  --bg-card:      #161b22;
  --bg-elevated:  #1c2129;
  --bg-inset:     #010409;
  --border:       #30363d;
  --border-light: #21262d;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted:   #484f58;
  --accent:       #58a6ff;
  --accent-hover: #79b8ff;
  --green:        #3fb950;
  --green-muted:  #238636;
  --red:          #f85149;
  --yellow:       #d29922;
  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
                  Helvetica, Arial, sans-serif;
  --font-mono:    "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
                  "Courier New", monospace;
  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.4);
  --transition:   150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: 0 16px 64px;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: #f0f6fc; line-height: 1.3; }
h2 { font-size: 1.25rem; font-weight: 600; color: #e6edf3; margin-bottom: 12px; }
h3 { font-size: 1rem; font-weight: 600; color: #e6edf3; margin-bottom: 8px; }
p  { color: var(--text-secondary); margin-bottom: 12px; }
a  { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

ul { list-style: none; padding-left: 0; }
li { color: var(--text-secondary); padding: 2px 0; }
li::before { content: "\2022"; color: var(--text-muted); display: inline-block; width: 1em; margin-left: 0.25em; }

code {
  font-family: var(--font-mono); font-size: 0.875em;
  background: rgba(110, 118, 129, 0.15);
  padding: 2px 6px; border-radius: var(--radius-sm); color: #e6edf3;
}
pre {
  font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.55;
  background: var(--bg-inset); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px; overflow-x: auto;
}
pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; color: inherit; }

/* Layout */
.header, #query-section, details, .node-section {
  max-width: 920px; margin-left: auto; margin-right: auto;
}

/* Header */
.header { padding: 40px 0 24px; margin-bottom: 24px; }
.header h1 { margin-bottom: 4px; }
.header .subtitle { color: var(--text-secondary); font-size: 0.9375rem; margin-bottom: 14px; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 100px; white-space: nowrap; user-select: none;
  background: rgba(63, 185, 80, 0.12); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.2);
}
.badge.blue { background: rgba(88, 166, 255, 0.12); color: var(--accent); border-color: rgba(88, 166, 255, 0.2); }

.download-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.875rem; font-weight: 500; color: var(--accent);
  padding: 6px 14px; border: 1px solid rgba(88, 166, 255, 0.3); border-radius: var(--radius-md);
  transition: all var(--transition);
}
.download-link:hover { background: rgba(88, 166, 255, 0.08); border-color: rgba(88, 166, 255, 0.5); text-decoration: none; }

/* Query Section */
#query-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  margin-bottom: 24px; box-shadow: var(--shadow-md); position: relative;
}
#query-section::before {
  content: ""; position: absolute; top: 0; left: 24px; right: 24px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(88, 166, 255, 0.3), transparent);
}
#query-section h2 { margin-bottom: 16px; }

/* Status */
#status {
  font-size: 0.8125rem; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-md);
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
}
#status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status.loading { background: rgba(210, 153, 34, 0.1); color: var(--yellow); border: 1px solid rgba(210, 153, 34, 0.25); }
.status.loading::before { background: var(--yellow); animation: pulse 1.4s ease-in-out infinite; }
.status.ready { background: rgba(63, 185, 80, 0.1); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.25); }
.status.ready::before { background: var(--green); }
.status.error { background: rgba(248, 81, 73, 0.1); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.25); }
.status.error::before { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Query Buttons */
.query-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.query-btn {
  display: inline-flex; align-items: center;
  padding: 6px 16px; font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500;
  color: var(--text-primary); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 100px;
  cursor: pointer; transition: all var(--transition); white-space: nowrap; user-select: none;
}
.query-btn:hover { background: #272d36; border-color: #3d444d; color: #f0f6fc; }
.query-btn:active { transform: scale(0.97); }
.query-btn.active { background: rgba(88, 166, 255, 0.12); border-color: rgba(88, 166, 255, 0.35); color: var(--accent); }

/* Custom SQL */
.custom-query { display: flex; gap: 8px; margin-bottom: 20px; }
.custom-query input {
  flex: 1; font-family: var(--font-mono); font-size: 0.8125rem;
  color: #e6edf3; background: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; outline: none; caret-color: var(--accent);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.custom-query input::placeholder { color: var(--text-muted); }
.custom-query input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15); }
.custom-query button {
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600;
  color: #fff; background: var(--green-muted);
  border: 1px solid rgba(63, 185, 80, 0.4); border-radius: var(--radius-md);
  padding: 10px 20px; cursor: pointer; transition: all var(--transition);
}
.custom-query button:hover { background: var(--green); border-color: var(--green); }

/* SQL Display */
.query-display { position: relative; margin-bottom: 20px; }
.query-display pre { padding: 16px 56px 16px 16px; white-space: pre-wrap; word-break: break-word; }
.query-actions { position: absolute; top: 8px; right: 8px; }
.action-btn {
  font-family: var(--font-sans); font-size: 0.75rem;
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 10px; cursor: pointer; transition: all var(--transition);
}
.action-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }

/* Results */
.result-meta { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 8px; }
#results { margin-bottom: 8px; }
#results .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
#results table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.8125rem; }
#results th {
  background: var(--bg-elevated); color: #e6edf3; font-weight: 600;
  font-family: var(--font-sans); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
#results td {
  padding: 8px 14px; border-bottom: 1px solid var(--border-light);
  color: var(--text-primary); vertical-align: top; max-width: 400px; overflow: hidden; text-overflow: ellipsis;
}
#results tr:last-child td { border-bottom: none; }
#results tr:hover td { background: rgba(88, 166, 255, 0.04); }

/* Details / Expandable */
details {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 8px; transition: background var(--transition);
}
details:hover { background: var(--bg-elevated); }
details summary {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; font-weight: 600; font-size: 0.9375rem; color: #e6edf3;
  cursor: pointer; user-select: none; list-style: none; transition: color var(--transition);
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: ""; display: inline-block; width: 0; height: 0;
  border-style: solid; border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent var(--text-muted);
  flex-shrink: 0; transition: transform var(--transition);
}
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { border-bottom: 1px solid var(--border); color: var(--accent); }
details .detail-content { padding: 18px; }
details .detail-content pre { margin-bottom: 12px; }
details .detail-content pre:last-child { margin-bottom: 0; }
details .detail-content p:last-child { margin-bottom: 0; }

/* Node Section */
.node-section { margin-bottom: 24px; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 640px) {
  body { padding: 0 12px 48px; font-size: 14px; }
  .header { padding: 32px 0 20px; }
  h1 { font-size: 1.375rem; }
  #query-section { padding: 18px; border-radius: var(--radius-md); }
  .query-btn { font-size: 0.75rem; padding: 5px 12px; }
  .custom-query { flex-direction: column; }
  .custom-query button { width: 100%; }
  #results th, #results td { padding: 6px 10px; font-size: 0.75rem; }
  details summary { padding: 12px 14px; font-size: 0.875rem; }
  details .detail-content { padding: 14px; }
  pre { font-size: 0.75rem; padding: 12px; }
}

::selection { background: rgba(88, 166, 255, 0.3); color: #f0f6fc; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
