/* ============================================================
   base.css — Shared foundation for all pages
   Variables · Reset · Logo · Header (standalone) · Search
   Topbar · Tabs · Sidebar · Nav · Footer
   Scroll-to-top · Theme toggle · Light theme · Responsive
   ============================================================ */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --accent: #00add8;
  --accent2: #79d4fd;
  --danger: #f85149;
  --warn: #d29922;
  --success: #3fb950;
  --tag-bg: #1f2a3a;
  --radius: 8px;
  --sidebar-w: 200px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

/* ---- Logo (shared) ---- */
.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.logo .logo-text { color: var(--accent); }
.logo .logo-text span { color: var(--text); }
.logo a { color: inherit; text-decoration: none; }
.logo a:hover { text-decoration: none; }

/* ---- Search ---- */
.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px 10px calc(var(--sidebar-w) + 12px);
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .logo {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  max-width: calc(var(--sidebar-w) - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface2); }

/* ---- Header tab buttons ---- */
.header-tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.tab-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.tab-btn:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.tab-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.tab-btn .tab-icon { font-size: 1rem; }
.tab-btn .tab-sub {
  display: block;
  font-size: 0.62rem;
  font-weight: 400;
  opacity: 0.7;
  margin-top: -2px;
}
.tab-btn.active .tab-sub { opacity: 0.8; }

/* ---- Page body (sidebar + content) ---- */
.page-body {
  display: flex;
  align-items: flex-start;
}

/* ---- Sidebar (index.html — categories) ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-close {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-close:hover { background: var(--surface2); color: var(--text); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ---- Main wrapper ---- */
.main-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Nav links ---- */
.nav-link {
  padding: 4px 12px;
  font-size: 0.76rem;
  color: var(--text2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.12s;
  white-space: nowrap;
  cursor: pointer;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: #484f58;
  text-decoration: none;
}
.nav-link.active {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
}

/* Sidebar nav overrides */
.sidebar-nav .nav-link {
  display: block;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  white-space: normal;
}
.sidebar-nav .nav-link:hover {
  border-color: transparent;
}
.sidebar-nav .nav-link.active {
  background: rgba(0, 173, 216, 0.1);
  color: var(--accent);
  border: none;
}

/* ---- Main content ---- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* ---- Section title (base) ---- */
.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  scroll-margin-top: 110px;
}
.section-title .icon { font-size: 1.1rem; }
.main-wrapper .section-title { scroll-margin-top: 70px; }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text2);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
}

/* ---- Scroll to top ---- */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.scroll-top.visible { display: flex; }

/* ---- Theme toggle ---- */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface2: #eef1f5;
  --border: #d0d7de;
  --text: #1f2328;
  --text2: #656d76;
  --accent: #00add8;
  --accent2: #0550ae;
  --danger: #cf222e;
  --warn: #9a6700;
  --success: #1a7f37;
  --tag-bg: #e8edf2;
}
[data-theme="light"] .sidebar-nav .nav-link:hover { border-color: transparent; }
[data-theme="light"] .sidebar-nav .nav-link.active { background: rgba(0, 173, 216, 0.08); }

/* ---- Responsive: hide tab-sub on medium screens ---- */
@media (max-width: 1100px) {
  .topbar .tab-sub { display: none; }
}

/* ---- Responsive: mobile ---- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    max-height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
  }
  .sidebar-title { font-size: 0.9rem; }
  .sidebar-close { display: flex; }
  .page-body { display: block; }
  .hamburger { display: flex; }
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar .hamburger { order: 0; }
  .topbar .logo {
    position: static;
    transform: none;
    max-width: none;
    overflow: visible;
    order: 1;
  }
  .topbar .search-box { order: 2; max-width: none; }
  .topbar .theme-toggle { order: 3; margin-left: auto; }
  .topbar .header-tabs {
    order: 4;
    width: 100%;
    overflow-x: auto;
    flex-shrink: 0;
  }
  .topbar .tab-sub { display: none; }
  .topbar .tab-btn { padding: 6px 10px; font-size: 0.8rem; }
  .main-wrapper .section-title { scroll-margin-top: 110px; }
}
