/* ===================================================
   Survi.vn Docs — Telegram-style Documentation Theme
   =================================================== */
/* --- Header --- */
.doc-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid #e8e8e8;
}

.doc-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #222;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.doc-header .subtitle {
  font-size: 1rem;
  color: #777;
  line-height: 1.5;
}

.doc-header .meta {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.8125rem;
  color: #999;
}

.doc-header .meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- Table of Contents --- */
.toc {
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 0 24px;
  margin-bottom: 36px;
}

.toc h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #555;
  margin-bottom: 12px;
}

.toc ol {
  list-style: none;
}

.toc ol li {
  margin-bottom: 4px;
}

.toc ol li a {
  font-size: 0.9375rem;
  color: #0088cc;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  transition: color 0.15s;
}


.toc ol li a:hover {
  color: #006699;
  text-decoration: underline;
}

/* --- Section --- */
.doc-section {
  margin-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.doc-section:last-child {
  border-bottom: none;
}

/* --- Section Header (collapsible trigger) --- */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 0 -16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s ease;
  border-radius: 8px;
  background: #fafafa;
  border: 1px solid #f4f4f5;
}

.section-header:hover {
  background: #f4f4f5;
  border-color: #e4e4e7;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #222;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
}

.section-header .section-number {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0088cc;
  min-width: 28px;
}

.section-header .chevron {
  width: 20px;
  height: 20px;
  transition: transform 0.25s ease;
  color: #999;
  flex-shrink: 0;
}

.doc-section.collapsed .section-header .chevron {
  transform: rotate(-90deg);
}

/* --- Section Body (collapsible content) --- */
.section-body {
  overflow: hidden;
  transition: height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
  opacity: 1;
  padding: 16px 0 20px 0;
}

.doc-section.collapsed .section-body {
  height: 0 !important;
  opacity: 0;
  padding: 0;
  border: none;
}

/* --- Typography inside sections --- */
.section-body p {
  margin-bottom: 12px;
  color: #333;
  font-size: 1.125rem;
  line-height: 1.8;
}

.section-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #222;
  margin: 24px 0 8px;
}

.section-body h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0088cc;
  margin: 16px 0 6px;
}

/* --- Links --- */
a {
  color: #0088cc;
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: #006699;
  text-decoration: underline;
}

/* --- Code Blocks --- */
pre {
  background: #f8f9fa;
  border: 1px solid #e4e6e8;
  border-radius: 8px;
  padding: 30px 0 0 0;
  margin: 12px 0 16px;
  font-size: 0.9375rem;
  line-height: 1.7;
  tab-size: 2;
  position: relative;
}

pre::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow: 16px 0 0 #ffbd2e, 32px 0 0 #27c93f;
}

pre code {
  display: block;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code',
    Menlo, Consolas, 'Liberation Mono', monospace;
  background: #ffffff;
  padding: 12px 16px;
  border: none;
  border-top: 1px solid #e4e6e8;
  font-size: 13px;
  overflow-x: auto;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.doc-section pre code,
.doc-section pre code.hljs,
.prose-premium .section-body pre code,
.prose-premium .section-body pre code.hljs {
  padding: 12px 16px !important;
}

/* --- Inline Code --- */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.875rem;
  background: #f0f2f4;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e4e6e8;
  word-break: break-word;
}

/* --- Callout / Note / Tip / Warning --- */
.callout {
  border-left: 3px solid #0088cc;
  background: #f0f8ff;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: #333;
}

.callout.warning {
  border-left-color: #e6a817;
  background: #fffdf0;
}

.callout.danger {
  border-left-color: #d93025;
  background: #fff5f5;
}

.callout.tip {
  border-left-color: #34a853;
  background: #f0faf4;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.callout.warning strong {
  color: #b8860b;
}

.callout.danger strong {
  color: #d93025;
}

.callout.tip strong {
  color: #1e7e34;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: #555;
  padding: 10px 12px;
  border-bottom: 2px solid #ddd;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  color: #333;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* --- Lists --- */
.section-body ul,
.section-body ol {
  margin: 8px 0 16px 20px;
  font-size: 1.125rem;
  color: #333;
}

.section-body li {
  margin-bottom: 4px;
  line-height: 1.65;
}

/* --- File Tree --- */
.file-tree {
  background: #f8f9fa;
  border: 1px solid #e4e6e8;
  border-radius: 6px;
  padding: 16px 20px;
  margin: 12px 0 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.8;
  color: #2d3748;
  white-space: pre;
}

.file-tree .dir {
  color: #0088cc;
  font-weight: 600;
}

.file-tree .comment {
  color: #999;
  font-style: italic;
}

/* --- Step Indicator --- */
.step-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0088cc;
  background: #e8f4fd;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* --- Divider --- */
.section-body hr {
  border: none;
  border-top: 1px solid #e8e8e8;
  margin: 24px 0;
}

/* --- Expand/Collapse All Button --- */
.controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 16px;
}

.controls button {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #0088cc;
  background: none;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.controls button:hover {
  background: #f0f8ff;
  border-color: #0088cc;
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 40px;
  height: 40px;
  background: #0088cc;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.15s;
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --- Footer --- */
.doc-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e8e8e8;
  font-size: 0.8125rem;
  color: #999;
  text-align: center;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .page-wrapper {
    padding: 24px 16px 60px;
  }

  .doc-header h1 {
    font-size: 1.625rem;
  }

  .section-header h2 {
    font-size: 1.125rem;
  }

  pre {
    padding: 12px 14px;
    font-size: 0.75rem;
  }

  .toc {
    padding: 16px 18px;
  }

  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
  }
}

/* --- Syntax Highlighting (minimal) --- */
.token-keyword {
  color: #d73a49;
}

.token-string {
  color: #22863a;
}

.token-comment {
  color: #6a737d;
  font-style: italic;
}

.token-type {
  color: #6f42c1;
}

.token-function {
  color: #005cc5;
}

.token-property {
  color: #e36209;
}

/* ===================================================
   Dark Mode Overrides (.dark)
   =================================================== */
.dark .doc-header {
  border-bottom-color: #334155;
}

.dark .doc-header h1 {
  color: #f8fafc;
}

.dark .doc-header .subtitle {
  color: #94a3b8;
}

.dark .doc-header .meta {
  color: #64748b;
}

.dark .toc {
  background: #0f172a;
  border-color: #334155;
}

.dark .toc h2 {
  color: #cbd5e1;
}

.dark .toc ol li a {
  color: #38bdf8;
}

.dark .toc ol li a::before {
  color: #64748b;
}

.dark .toc ol li a:hover {
  color: #7dd3fc;
}

.dark .doc-section {
  border-bottom-color: #27272a;
}

.dark .section-header {
  background: #18181b;
  border-color: #27272a;
}

.dark .section-header:hover {
  background: #27272a;
  border-color: #3f3f46;
}

.dark .section-header h2 {
  color: #f1f5f9;
}

.dark .section-header .section-number {
  color: #38bdf8;
}

.dark .section-header .chevron {
  color: #64748b;
}

.dark .section-body p {
  color: #cbd5e1;
}

.dark .section-body h3 {
  color: #f8fafc;
}

.dark .section-body h4 {
  color: #38bdf8;
}

.dark .section-body ul,
.dark .section-body ol {
  color: #cbd5e1;
}

.dark a {
  color: #38bdf8;
}

.dark a:hover {
  color: #7dd3fc;
}

.dark pre {
  background: #1e293b;
  border-color: #334155;
}

.dark pre code {
  background: #0f172a;
  border-top-color: #334155;
}

.dark code {
  background: #1e293b;
  border-color: #334155;
}

.dark .callout {
  background: #082f49;
  border-left-color: #0284c7;
  color: #e0f2fe;
}

.dark .callout strong {
  color: #bae6fd;
}

.dark .callout.warning {
  background: #422006;
  border-left-color: #ca8a04;
  color: #fef08a;
}

.dark .callout.warning strong {
  color: #fde047;
}

.dark .callout.danger {
  background: #450a0a;
  border-left-color: #dc2626;
  color: #fecaca;
}

.dark .callout.danger strong {
  color: #fca5a5;
}

.dark .callout.tip {
  background: #052e16;
  border-left-color: #16a34a;
  color: #bbf7d0;
}

.dark .callout.tip strong {
  color: #86efac;
}

.dark table {
  color: #cbd5e1;
}

.dark thead th {
  color: #f8fafc;
  border-bottom-color: #334155;
}

.dark tbody td {
  color: #cbd5e1;
  border-bottom-color: #1e293b;
}

.dark .file-tree {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

.dark .file-tree .dir {
  color: #38bdf8;
}

.dark .file-tree .comment {
  color: #64748b;
}

.dark .step-label {
  background: #0c4a6e;
  color: #38bdf8;
}

.dark .section-body hr {
  border-top-color: #334155;
}

.dark .controls button {
  color: #38bdf8;
  border-color: #334155;
}

.dark .controls button:hover {
  background: #0f172a;
  border-color: #7dd3fc;
}

.dark .back-to-top {
  background: #0ea5e9;
}

.dark .doc-footer {
  border-top-color: #334155;
  color: #64748b;
}

.dark .token-keyword {
  color: #ff7b72;
}

.dark .token-string {
  color: #a5d6ff;
}

.dark .token-comment {
  color: #8b949e;
}

.dark .token-type {
  color: #d2a8ff;
}

.dark .token-function {
  color: #79c0ff;
}

.dark .token-property {
  color: #ffa657;
}

.dark .doc-section pre code,
.dark .doc-section pre code.hljs,
.dark .prose-premium .section-body pre code,
.dark .prose-premium .section-body pre code.hljs {}