/* ── RESET & BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* sidebar */
  --sb-bg:        #1e1e2e;
  --sb-border:    #2d2d3f;
  --sb-text:      #a0a0c0;
  --sb-text-dim:  #555570;
  --sb-hover:     #2a2a3e;
  --sb-active:    #0d47a1;
  --sb-active-bg: #1a2a4a;
  --sb-width:     250px;

  /* header */
  --hdr-bg:       #16162a;
  --hdr-border:   #2d2d3f;
  --hdr-h:        54px;

  /* content */
  --ct-bg:        #f5f6fa;
  --ct-text:      #1a1a2e;
  --ct-text-mute: #6b7280;
  --ct-border:    #e0e4f0;

  /* accent */
  --accent:       #4FC3F7;
  --accent-dark:  #0288D1;
  --accent-glow:  rgba(79,195,247,.15);

  /* tag colours */
  --tag-bg:       #e8f4fd;
  --tag-text:     #0277bd;

  /* code */
  --code-bg:      #1a1a2e;
  --code-text:    #cdd6f4;

  /* transitions */
  --tr: .18s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ct-text);
  background: var(--ct-bg);
  overflow-x: hidden;
}

/* ── LAYOUT ────────────────────────────────────────────────────────────── */
body {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--tr);
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sb-width)));
}

.sidebar-header {
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-logo {
  height: 28px;
  width: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--sb-text-dim);
  padding: 14px 16px 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── FILE TREE ─────────────────────────────────────────────────────────── */
.file-tree {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
}

.file-tree::-webkit-scrollbar { width: 4px; }
.file-tree::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 2px; }

.tree-folder {
  user-select: none;
}

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  cursor: pointer;
  color: var(--sb-text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--tr), color var(--tr);
  border-left: 2px solid transparent;
}

.tree-folder-header:hover {
  background: var(--sb-hover);
  color: #fff;
}

.tree-folder-header.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--sb-active-bg);
}

.folder-arrow {
  font-size: 10px;
  color: var(--sb-text-dim);
  transition: transform var(--tr);
  width: 10px;
  flex-shrink: 0;
}

.tree-folder.open > .tree-folder-header .folder-arrow {
  transform: rotate(90deg);
}

.folder-icon {
  font-size: 14px;
}

.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  font-size: 10px;
  color: var(--sb-text-dim);
  background: var(--sb-hover);
  border-radius: 10px;
  padding: 1px 6px;
  flex-shrink: 0;
}

.tree-children {
  display: none;
  overflow: hidden;
}

.tree-folder.open > .tree-children {
  display: block;
  animation: slideDown .15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 16px 5px 34px;
  cursor: pointer;
  color: var(--sb-text);
  font-size: 12.5px;
  transition: background var(--tr), color var(--tr);
  border-left: 2px solid transparent;
  font-family: "Courier New", Courier, monospace;
}

.tree-item:hover {
  background: var(--sb-hover);
  color: #cdd6f4;
}

.tree-item.active {
  color: var(--accent);
  background: var(--sb-active-bg);
  border-left-color: var(--accent);
}

.tree-item-icon {
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.7;
}

.tree-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--sb-text-dim);
  font-family: "Courier New", Courier, monospace;
}

/* ── MAIN WRAPPER ──────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sb-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--tr);
}

.main-wrapper.sidebar-collapsed {
  margin-left: 0;
}

/* ── TOP HEADER ────────────────────────────────────────────────────────── */
.top-header {
  height: var(--hdr-h);
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--hdr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 90;
  flex-shrink: 0;
}

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

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border-radius: 4px;
  transition: background var(--tr);
}

.sidebar-toggle:hover { background: rgba(255,255,255,.08); }

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--sb-text);
  border-radius: 1px;
  transition: background var(--tr);
}

.sidebar-toggle:hover span { background: #fff; }

.header-title-block {
  display: flex;
  flex-direction: column;
}

.header-site-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
}

.header-tagline {
  font-size: 11px;
  color: var(--sb-text-dim);
  font-family: "Courier New", Courier, monospace;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
}

/* ── SEARCH ────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--sb-text-dim);
  pointer-events: none;
}

.search-input {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--sb-border);
  border-radius: 6px;
  color: #e0e0f0;
  font-size: 13px;
  padding: 7px 32px 7px 32px;
  width: 240px;
  outline: none;
  transition: border-color var(--tr), background var(--tr), width var(--tr);
  font-family: inherit;
}

.search-input::placeholder { color: var(--sb-text-dim); }

.search-input:focus {
  border-color: var(--accent);
  background: rgba(79,195,247,.06);
  width: 300px;
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--sb-text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  display: none;
  line-height: 1;
}

.search-clear.visible { display: block; }
.search-clear:hover { color: #fff; }

/* ── BREADCRUMB ────────────────────────────────────────────────────────── */
.breadcrumb {
  background: #fff;
  border-bottom: 1px solid var(--ct-border);
  padding: 8px 24px;
  font-size: 12px;
  color: var(--ct-text-mute);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  font-family: "Courier New", Courier, monospace;
}

.breadcrumb:empty { display: none; }

.bc-sep { color: #c0c4d0; }

.bc-link {
  cursor: pointer;
  color: var(--accent-dark);
  text-decoration: none;
  transition: color var(--tr);
}

.bc-link:hover { color: var(--accent); }

.bc-current { color: var(--ct-text); font-weight: 500; }

/* ── CONTENT AREA ──────────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 28px 32px;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HOME DASHBOARD ────────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  border-radius: 12px;
  padding: 36px 40px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.home-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(79,195,247,.15) 0%, transparent 70%);
  border-radius: 50%;
}

.home-hero-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 10px;
}

.home-hero-title {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.25;
}

.home-hero-title span {
  color: var(--accent);
}

.home-hero-desc {
  font-size: 14px;
  color: #9090b0;
  max-width: 560px;
  line-height: 1.65;
}

.home-hero-stats {
  display: flex;
  gap: 28px;
  margin-top: 22px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-family: "Courier New", Courier, monospace;
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: #666688;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Category cards */
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ct-text-mute);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ct-border);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 34px;
}

.category-card {
  background: #fff;
  border: 1px solid var(--ct-border);
  border-radius: 8px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 3px;
  width: 100%;
  background: var(--accent-dark);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--tr);
}

.category-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(79,195,247,.12);
  transform: translateY(-2px);
}

.category-card:hover::before { transform: scaleX(1); }

.card-icon { font-size: 22px; margin-bottom: 8px; }

.card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ct-text);
  margin-bottom: 3px;
}

.card-count {
  font-size: 11px;
  color: var(--ct-text-mute);
  font-family: "Courier New", Courier, monospace;
}

/* Recent blogs on home */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.recent-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--ct-border);
  cursor: pointer;
  transition: background var(--tr);
  border-radius: 4px;
  padding-left: 8px;
  padding-right: 8px;
}

.recent-item:hover { background: rgba(79,195,247,.05); }

.recent-item:last-child { border-bottom: none; }

.recent-cat-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent-dark);
  background: var(--tag-bg);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  margin-top: 2px;
  flex-shrink: 0;
  font-family: "Courier New", Courier, monospace;
  text-transform: uppercase;
}

.recent-text { flex: 1; min-width: 0; }

.recent-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ct-text);
  line-height: 1.4;
  margin-bottom: 2px;
}

.recent-desc {
  font-size: 12px;
  color: var(--ct-text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── BLOG LIST ─────────────────────────────────────────────────────────── */
.blog-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.blog-list-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ct-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.blog-list-title .cat-icon { font-size: 20px; }

.blog-count-badge {
  font-size: 11px;
  color: var(--ct-text-mute);
  background: var(--ct-border);
  border-radius: 10px;
  padding: 2px 8px;
  font-family: "Courier New", Courier, monospace;
}

.blog-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.blog-card {
  background: #fff;
  border: 1px solid var(--ct-border);
  border-radius: 8px;
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
  margin-bottom: 10px;
  position: relative;
}

.blog-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(79,195,247,.10);
  transform: translateX(3px);
}

.blog-card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ct-text);
  margin-bottom: 6px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.blog-card-title::before {
  content: '›';
  color: var(--accent-dark);
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1.35;
}

.blog-card-desc {
  font-size: 12.5px;
  color: var(--ct-text-mute);
  line-height: 1.6;
  margin-bottom: 10px;
  padding-left: 16px;
}

.blog-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 10.5px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 500;
  letter-spacing: .03em;
}

.read-more-hint {
  font-size: 11.5px;
  color: var(--accent-dark);
  font-family: "Courier New", Courier, monospace;
  opacity: 0;
  transition: opacity var(--tr);
  white-space: nowrap;
}

.blog-card:hover .read-more-hint { opacity: 1; }

/* ── BLOG CONTENT ──────────────────────────────────────────────────────── */
.blog-article {
  max-width: 820px;
}

.blog-article-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ct-border);
}

.article-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent-dark);
  background: var(--tag-bg);
  border-radius: 4px;
  padding: 3px 9px;
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 10px;
}

.article-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ct-text);
  line-height: 1.3;
  margin-bottom: 10px;
}

.article-desc {
  font-size: 14px;
  color: var(--ct-text-mute);
  line-height: 1.65;
  margin-bottom: 14px;
}

.article-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--ct-border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--ct-text-mute);
  cursor: pointer;
  transition: border-color var(--tr), color var(--tr), background var(--tr);
  font-family: inherit;
  margin-bottom: 22px;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-glow);
}

/* Article body typography */
.article-body {
  font-size: 14.5px;
  line-height: 1.75;
  color: #2a2a3e;
}

.article-body h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ct-text);
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ct-border);
}

.article-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ct-text);
  margin: 20px 0 8px;
}

.article-body p {
  margin-bottom: 14px;
}

.article-body ul, .article-body ol {
  padding-left: 22px;
  margin-bottom: 14px;
}

.article-body li { margin-bottom: 5px; }

.article-body code {
  background: #e8eaf8;
  color: #1a237e;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
}

.article-body pre {
  background: var(--code-bg);
  border: 1px solid #2d2d4e;
  border-radius: 8px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 14px 0 18px;
  position: relative;
}

.article-body pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px; right: 12px;
  font-size: 10px;
  color: #555570;
  font-family: "Courier New", Courier, monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.article-body pre code {
  background: none;
  color: var(--code-text);
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  line-height: 1.7;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 18px;
  font-size: 13px;
}

.article-body th {
  background: #f0f2ff;
  color: var(--ct-text);
  font-weight: 600;
  text-align: left;
  padding: 8px 14px;
  border: 1px solid var(--ct-border);
}

.article-body td {
  padding: 7px 14px;
  border: 1px solid var(--ct-border);
  color: #3a3a5e;
}

.article-body tr:hover td { background: #f8f9ff; }

.article-body strong { font-weight: 600; color: var(--ct-text); }

/* ── SEARCH RESULTS ────────────────────────────────────────────────────── */
.search-header {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ct-border);
}

.search-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ct-text);
}

.search-header-title span {
  color: var(--accent-dark);
  font-family: "Courier New", Courier, monospace;
}

.search-no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--ct-text-mute);
}

.search-no-results .no-results-icon { font-size: 40px; margin-bottom: 12px; }
.search-no-results p { font-size: 14px; }

mark.hl {
  background: #fff176;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── EMPTY STATE ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--ct-text-mute);
}

.empty-state-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state p { font-size: 14px; }

/* ── SCROLLBAR ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c4d8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a4c0; }

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sb-width))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .search-input { width: 160px; }
  .search-input:focus { width: 200px; }
  .content-area { padding: 20px 16px; }
  .home-hero { padding: 24px 20px; }
  .home-hero-title { font-size: 20px; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
