/* ========== Reset & Base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #212121;
  background-color: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ========== Header ========== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo {
  height: 36px;
  width: auto;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: #212121;
}

/* ========== Page Layout ========== */
.page-wrapper {
  padding-top: 64px;
  min-height: 100vh;
  background-color: #fff;
}

.layout-container {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
}

/* ========== Nav Panel ========== */
.nav-panel {
  position: sticky;
  top: 64px;
  align-self: flex-start;
  width: 260px;
  min-width: 260px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid #e0e0e0;
  padding: 16px 0;
}

.nav-title {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #757575;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  display: block;
}

.nav-item a {
  display: block;
  padding: 6px 16px 6px 32px;
  font-size: 13px;
  font-weight: 400;
  color: #424242;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
  word-wrap: break-word;
}

.nav-item a:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.nav-item a.active {
  color: #1976d2;
  font-weight: 600;
  border-left-color: #1976d2;
  background-color: rgba(25, 118, 210, 0.08);
}

/* ========== Nav Icon ========== */
.nav-icon {
  height: 13px;
  width: auto;
  margin-right: 6px;
  vertical-align: middle;
}

/* ========== Footer ========== */
.footer {
  display: flex;
  align-items: center;
  height: 40px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.footer-logo {
  height: 20px;
  width: auto;
}

/* ========== Body Panel ========== */
.body-panel {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 64px);
  padding: 16px 40px 32px;
  display: flex;
  flex-direction: column;
}

/* ========== TOC Panel ========== */
.toc-panel {
  position: sticky;
  top: 64px;
  align-self: flex-start;
  width: 280px;
  min-width: 280px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-left: 1px solid #e0e0e0;
  padding: 16px;
}

.toc-title {
  font-size: 12px;
  font-weight: 600;
  color: #757575;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.toc-list {
  display: flex;
  flex-direction: column;
}

.toc-item {
  display: block;
  padding: 4px 0;
  padding-left: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #424242;
  text-decoration: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: normal;
  word-wrap: break-word;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
  font-family: inherit;
}

.toc-item:hover {
  color: #1976d2;
}

.toc-item.active {
  color: #1976d2;
  font-weight: 600;
  border-left-color: #1976d2;
}

.toc-item.depth-1 {
  font-weight: 500;
  color: #212121;
  padding-left: 8px;
}

.toc-item.depth-2 {
  padding-left: 20px;
  color: #616161;
}

.toc-item.depth-3 {
  padding-left: 32px;
  color: #757575;
  font-size: 12px;
}

.toc-item.depth-1.active,
.toc-item.depth-2.active,
.toc-item.depth-3.active {
  color: #1976d2;
}

/* ========== Markdown Body ========== */
.markdown-body {
  max-width: 100%;
}

.markdown-body h1 {
  font-size: 24px;
  font-weight: 400;
  margin-top: 16px;
  margin-bottom: 16px;
  padding-top: 8px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 8px;
  line-height: 1.4;
}

.markdown-body h2 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 16px;
  padding-top: 8px;
  line-height: 1.4;
}

.markdown-body h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-top: 4px;
  line-height: 1.4;
}

.markdown-body p {
  margin-bottom: 8px;
  line-height: 1.7;
}

.markdown-body a {
  color: #1976d2;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body ul,
.markdown-body ol {
  padding: 4px 0;
  margin: 4px 0;
  padding-left: 24px;
}

.markdown-body li {
  padding: 4px 0;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin-bottom: 16px;
}

/* Inline code */
.markdown-body code {
  font-family: "Roboto", monospace;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #e3f2fd;
  font-size: 13px;
}

/* Code blocks */
.markdown-body pre {
  position: relative;
  width: fit-content;
  min-width: 50%;
  max-width: 100%;
  margin: 0 0 16px 0;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  background-color: #e3f2fd;
  overflow-x: auto;
}

.markdown-body pre code {
  display: block;
  padding: 16px;
  background: none;
  border-radius: 0;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: #9e9e9e;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  z-index: 1;
}

.copy-btn:hover {
  background-color: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

/* Images */
.markdown-body img {
  display: block;
  max-width: 88%;
  height: auto;
  border-radius: 8px;
  margin: 0 auto;
}

.img-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 16px 0;
  padding: 32px 16px;
  border-radius: 8px;
  background-color: #f5f5f5;
  border: 1px solid #e0e0e0;
}

/* Blockquote */
.markdown-body blockquote {
  width: fit-content;
  min-width: 50%;
  max-width: 100%;
  padding: 16px 16px 8px 16px;
  margin: 0 0 16px 0;
  border-radius: 4px;
  border-left: 4px solid #e0e0e0;
  background-color: #e3f2fd;
}

.markdown-body blockquote p {
  margin-bottom: 8px;
}

/* Details/Summary */
.markdown-body details {
  padding: 4px 0;
  margin-bottom: 16px;
}

.markdown-body details summary {
  font-weight: 500;
  font-size: 14px;
  color: #1976d2;
  cursor: pointer;
}

.markdown-body details summary:hover {
  text-decoration: underline;
}

.markdown-body details > p {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

/* Tables */
.markdown-body table {
  border-collapse: collapse;
  margin-top: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid #e0e0e0;
}

.markdown-body thead {
  background-color: #f5f5f5;
}

.markdown-body tr {
  border-bottom: 1px solid #e0e0e0;
}

.markdown-body tr:last-child {
  border-bottom: none;
}

.markdown-body th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border-right: 1px solid #e0e0e0;
}

.markdown-body td {
  padding: 8px 12px;
  border-right: 1px solid #e0e0e0;
}

.markdown-body td:last-child,
.markdown-body th:last-child {
  border-right: none;
}

/* ========== Mobile Menu Button ========== */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 80px;
  left: 16px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: #424242;
}

.mobile-menu-btn:hover {
  background-color: #f5f5f5;
}

/* ========== Mobile Drawer ========== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1200;
}

.drawer-overlay.open {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 260px;
  height: 100%;
  background-color: #fff;
  z-index: 1300;
  overflow-y: auto;
  transition: left 0.3s ease;
  padding: 16px 0;
}

.drawer.open {
  left: 0;
}

/* ========== Responsive ========== */
@media (max-width: 960px) {
  .nav-panel {
    display: none;
  }

  .toc-panel {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .body-panel {
    padding: 16px 20px 32px;
  }
}

@media (max-width: 600px) {
  .logo-text {
    font-size: 15px;
  }

  .body-panel {
    padding: 16px 12px 32px;
  }
}

/* ========== Scrollbar ========== */
.nav-panel::-webkit-scrollbar,
.toc-panel::-webkit-scrollbar,
.drawer::-webkit-scrollbar {
  width: 4px;
}

.nav-panel::-webkit-scrollbar-thumb,
.toc-panel::-webkit-scrollbar-thumb,
.drawer::-webkit-scrollbar-thumb {
  background-color: #bdbdbd;
  border-radius: 2px;
}

.nav-panel::-webkit-scrollbar-track,
.toc-panel::-webkit-scrollbar-track,
.drawer::-webkit-scrollbar-track {
  background: transparent;
}
