/* ===== GLOBAL SIDEBAR NAVIGATION =====
   Single source of truth for sidebar on landing page + article pages.
*/

/* ── Base ─────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: 0;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  box-sizing: border-box;
}

.sidebar *, .sidebar *::before, .sidebar *::after {
  box-sizing: border-box;
}

/* ── Brand ────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: #0f172a;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.01em;
  border-bottom: 1px solid #e2e8f0;
}

/* ── Top (search + lang) ─────────────────────────── */
.sidebar-top {
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid #e2e8f0;
}

/* ── Nav (7 items — scrolls only if viewport is too short) ── */
.sidebar-nav {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.85rem;
  margin: 0;
  list-style: none;
  min-height: 0;
}

/* Thin subtle scrollbar if nav needs to scroll */
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent; }

/* ── Links (shared by nav + bottom) ──────────────── */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
  width: 100%;
  min-width: 0;
  text-align: left;
  text-decoration: none;
  overflow: hidden;
  flex-shrink: 0;
  line-height: 1.2;
}

.sidebar-link:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.sidebar-link.active {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #2563eb;
}

.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-count {
  margin-left: auto;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-link.active .sidebar-count {
  background: #2563eb;
  color: #fff;
}

/* ── Bottom (3 items — always pinned) ────────────── */
.sidebar-bottom {
  padding: 0.5rem 0.85rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-decoration: none;
  transition: all 0.15s;
}

.sidebar-extra:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* ── Shared controls ─────────────────────────────── */
.sidebar-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #94a3b8;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.sidebar-search-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.sidebar-search-btn kbd {
  margin-left: auto;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.62rem;
  font-family: inherit;
  color: #94a3b8;
}

.sidebar-lang {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 28px 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-lang:hover { border-color: #2563eb; }
.sidebar-lang:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* ── Layout push ─────────────────────────────────── */
body.has-sidebar {
  margin-left: 260px;
}

/* ── Overlay (mobile backdrop) ───────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 190;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ── Toggle (mobile hamburger) ───────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 300;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #0f172a;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.15s;
}
.sidebar-toggle:hover { border-color: #2563eb; color: #2563eb; }

/* ── MOBILE (<=768px) ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 250 !important;
    width: 280px !important;
    height: 100vh;
    height: 100dvh;
    bottom: auto;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }

  .sidebar-toggle {
    display: flex !important;
  }

  body.has-sidebar {
    margin-left: 0;
  }

  .sidebar-brand {
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    gap: 8px;
  }

  .sidebar-brand img {
    width: 24px;
    height: 24px;
  }

  .sidebar-top {
    padding: 0.45rem 0.75rem;
    gap: 5px;
  }

  .sidebar-search-btn {
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .sidebar-lang {
    padding: 7px 28px 7px 10px;
    font-size: 0.76rem;
  }

  .sidebar-nav {
    padding: 0.4rem 0.75rem;
    gap: 2px;
  }

  .sidebar-link {
    padding: 8px 10px;
    font-size: 0.82rem;
    gap: 9px;
  }

  .sidebar-link i {
    width: 16px;
    font-size: 0.82rem;
  }

  .sidebar-count {
    font-size: 0.6rem;
    padding: 1px 5px;
  }

  .sidebar-bottom {
    padding: 0.4rem 0.75rem;
    gap: 2px;
  }

  .sidebar-extra {
    padding: 7px 10px;
    font-size: 0.74rem;
    gap: 9px;
  }
}
