:root {
  --bg: #fbf5ef;
  --panel: #ffffff;
  --ink: #191a1e;
  --muted: #767680;
  --accent: #10b981;
  --accent-dark: #0ea371;
  --border: #ece3da;
  --code-bg: #1b1b1f;
  --highlight: #fff3cd;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  margin-right: 0;
  transition: margin-right 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* Hide scrollbars while keeping scroll functional — used on the sidebar. */
.no-scrollbar {
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* legacy Edge/IE */
}
.no-scrollbar::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 8px 24px rgba(20,20,25,0.03);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); }

.docs-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eafaf3;
  color: var(--accent-dark);
  border: 1px solid #c6ecd9;
}

.top-links { display: flex; gap: 20px; font-size: 13px; align-items: center; }
.top-links a { color: var(--ink); }
.dashboard-link {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 9px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(16,185,129,0.28);
  transition: background 0.15s ease, transform 0.15s ease;
}
.dashboard-link:hover { background: var(--accent-dark); text-decoration: none; transform: translateY(-1px); }

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  max-width: 1180px;
  margin: 0 auto;
  gap: 48px;
  padding: 32px 24px 140px;
}

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 106px);
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-group { margin-bottom: 24px; }
.sidebar-group:last-child { margin-bottom: 0; }

.sidebar-group h4 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 10px;
  padding: 0 10px;
}

.sidebar-group ul { list-style: none; margin: 0; padding: 0; }

.side-link {
  position: relative;
  display: block;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4b4b54;
  margin-bottom: 1px;
  transition: background 0.12s ease, color 0.12s ease;
}

.side-link:hover { background: rgba(16,185,129,0.08); color: var(--ink); text-decoration: none; }

.side-link.active {
  background: rgba(16,185,129,0.12);
  color: var(--accent-dark);
  font-weight: 700;
}

.side-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

/* ---- Content ---- */
.content { min-width: 0; max-width: 760px; }

.doc-section {
  padding: 30px 32px;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(20,20,25,0.03);
  scroll-margin-top: 96px;
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

.doc-section.nav-highlight {
  box-shadow: 0 0 0 3px var(--accent), 0 12px 32px rgba(16,185,129,0.14);
  border-color: var(--accent);
}

mark.ai-highlight {
  background: var(--highlight);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
  transition: background 1.2s ease;
}

mark.ai-highlight.ai-highlight-pulse {
  background: #ffe58a;
  box-shadow: 0 0 0 2px #ffd24d;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-dark);
  font-weight: 700;
  margin-bottom: 8px;
}

.doc-section h2 { margin: 0 0 16px; font-size: 23px; letter-spacing: -0.01em; }
.doc-section h4 { margin: 20px 0 8px; font-size: 15px; font-weight: 700; }

.doc-body p { margin: 0 0 13px; font-size: 14.5px; color: #35353d; }
.doc-body ul, .doc-body ol { padding-left: 20px; font-size: 14.5px; color: #35353d; }
.doc-body li { margin-bottom: 6px; }
.doc-body code {
  background: #f3ebe0;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
}

.doc-body pre {
  background: var(--code-bg);
  color: #e6f7ee;
  padding: 16px 18px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 13px;
  margin: 12px 0 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.doc-body pre code { background: none; padding: 0; color: inherit; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 13.5px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.doc-table th, .doc-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.doc-table tr:last-child td { border-bottom: none; }
.doc-table th { color: var(--muted); font-weight: 600; background: #faf5ef; }

.steps { padding-left: 20px; }
.steps li { margin-bottom: 14px; }

.callout {
  border-left: 3px solid var(--accent);
  background: #eafaf3;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0 16px;
  font-size: 13.5px;
}
.callout p { margin: 4px 0 0; }
.callout-warn { border-left-color: #d9822b; background: #fff3e6; }
.callout-info { border-left-color: var(--accent); background: #eafaf3; }

/* ---- Floating Ask AI ---- */
.ask-ai-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.ask-ai-btn:hover { background: #000; }

.ask-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* Full-height right-side drawer — more room than a small floating box, so
   clipped/cut-off content is far less likely, and it reads as a proper
   docs-site "Ask AI" panel rather than a chat bubble popover. */
.ask-ai-panel {
  --zw-header-crop: 46px; /* height of Zencia's own header we clip away — tune visually */
  --zw-footer-crop: 60px; /* height of their "Powered by" footer we clip away */
  --zw-top-buffer: 14px;  /* small breathing-room gap so text never touches the crop edge */

  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  min-width: 320px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 56px rgba(16,185,129,0.08), -8px 0 24px rgba(0,0,0,0.12);
  z-index: 41;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: horizontal;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.ask-ai-panel.open { transform: translateX(0); }
.ask-ai-panel.hidden { display: none; }

/* ---- Our own header — fully ours: icon, name, minimize, close ---- */
.ask-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(155deg, #182420 0%, #101915 100%);
  color: #fff;
  flex-shrink: 0;
}

.ask-panel-title { display: flex; align-items: center; gap: 10px; }

/* The real Zencia logo, softly breathing so it still feels alive. */
.ask-panel-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: breathe 3.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.ask-panel-name { font-size: 13.5px; font-weight: 700; line-height: 1.2; }
.ask-panel-sub { font-size: 11px; color: rgba(255,255,255,0.6); line-height: 1.2; }

.ask-panel-controls { display: flex; gap: 6px; }

.ask-panel-icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ask-panel-icon-btn:hover { background: rgba(255,255,255,0.24); }

/* ---- Crop window — hides Zencia's own header/footer bars inside the iframe.
   This is a positioning trick, not an official API: we render the iframe
   taller than the visible window and shift it up so their chrome falls
   outside the clip. --zw-header-crop / --zw-footer-crop may need retuning
   if Zencia changes their embed page's layout. ---- */
.ask-ai-crop {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  padding-top: var(--zw-top-buffer);
  background: var(--panel);
}

.ask-ai-body {
  position: absolute;
  top: calc(var(--zw-top-buffer) - 1 * var(--zw-header-crop));
  left: 0;
  right: 0;
  height: calc(100% + var(--zw-header-crop) + var(--zw-footer-crop));
  display: flex;
}
.ask-ai-body iframe { border: none; width: 100%; height: 100%; }

/* Soft fade at the very top of the crop so the clip line reads as an
   intentional edge rather than a hard cut mid-text. */
.ask-ai-crop::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--zw-top-buffer);
  background: var(--panel);
  z-index: 1;
  pointer-events: none;
}

.ask-ai-empty {
  margin: auto;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  padding: 0 24px;
}

/* Our own "connecting" state — shown while WE load the iframe, which is
   the one loading moment we actually have real, honest visibility into.
   Sits above the (already-loading) iframe until its `load` event fires. */
.ask-ai-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.ask-ai-loading-overlay.hidden { display: none; }
.ask-ai-loading-overlay .ask-panel-logo { animation-duration: 1s; }

/* ---- Toast: brief on-page confirmation when the AI navigates you somewhere ---- */
.nav-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-toast.hidden { display: none; }
.nav-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ask-ai-mini-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 100%;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.ask-ai-mini-hint {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

/* ---- Mini (minimized) state — detaches from the full-height drawer
   position and becomes a small floating pill bottom-right instead. ---- */
.ask-ai-panel.mini {
  top: auto !important;
  bottom: 88px !important;
  right: 24px !important;
  width: 240px !important;
  height: 52px !important;
  min-width: 0;
  border-left: 1px solid var(--border);
  border-radius: 14px;
  resize: none;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
}
.ask-ai-panel.mini .ask-panel-header { display: none; }
.ask-ai-panel.mini .ask-ai-crop { display: none; }
.ask-ai-panel.mini .ask-ai-mini-bar { display: flex; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .ask-ai-panel { width: 100vw; max-width: 100vw; }
}
