/* site-ui.css: 全局左侧导航栏 + 搜索框 */

/* 桌面端：主内容区让出 sidebar 空间 */
@media (min-width: 1024px) {
  body.has-sidebar > header,
  body.has-sidebar > main,
  body.has-sidebar > footer {
    margin-left: 220px !important;
  }
  .site-sidebar {
    transform: translateX(0) !important;
  }
  .site-sidebar-overlay {
    display: none !important;
  }
}

.site-sidebar {
  position: fixed;
  top: 64px; /* header 高度 */
  left: 0;
  width: 220px;
  height: calc(100vh - 64px);
  border-right: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
  z-index: 50;
  overflow-y: auto;
  padding: 1rem 0.75rem 2rem;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-sizing: border-box;
}

body.sb-open .site-sidebar {
  transform: translateX(0);
}

body.sb-open {
  overflow: hidden;
}

.site-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 45;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.sb-open .site-sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

.site-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}

.site-sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.site-sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.site-sidebar-subtitle {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.site-sidebar-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.6);
  margin-bottom: 1rem;
}

.site-sidebar-search:focus-within {
  border-color: hsl(var(--primary));
  background: hsl(var(--background));
}

.site-sidebar-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.85rem;
  color: hsl(var(--foreground));
}

.site-sidebar-search input::placeholder {
  color: hsl(var(--muted-foreground));
}

.site-sidebar-section {
  margin-bottom: 1.25rem;
}

.site-sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  padding: 0 0.5rem 0.4rem;
}

.site-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.site-sidebar-nav a,
.site-sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.45rem;
  font-size: 0.88rem;
  color: hsl(var(--foreground) / 0.9);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.site-sidebar-nav a:hover,
.site-sidebar-nav button:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.site-sidebar-nav a.active,
.site-sidebar-nav button.active {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  font-weight: 600;
}

.site-sidebar-nav .sb-icon {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.site-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
}

/* header 搜索框 */
.site-search {
  position: relative;
  align-items: center;
  width: 220px;
}

.site-search input {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.7rem 0 2.1rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.6);
  color: hsl(var(--foreground));
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.site-search input:focus {
  border-color: hsl(var(--primary));
  background: hsl(var(--background));
}

.site-search input::placeholder {
  color: hsl(var(--muted-foreground));
}

.site-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.site-search-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: 360px;
  max-width: 90vw;
  max-height: 420px;
  overflow-y: auto;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.18);
  z-index: 60;
  display: none;
  padding: 0.4rem;
}

.site-search-dropdown a {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.45rem;
  text-decoration: none;
  color: hsl(var(--foreground));
  transition: background 0.12s ease;
}

.site-search-dropdown a:hover,
.site-search-dropdown a:focus {
  background: hsl(var(--muted));
}

.site-search-dropdown .res-title {
  font-size: 0.88rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-search-dropdown .res-type {
  flex-shrink: 0;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  white-space: nowrap;
  margin-top: 0.15rem;
}

.site-search-empty {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.site-search-more {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  border-top: 1px solid hsl(var(--border));
  margin-top: 0.25rem;
}

@media (max-width: 1023px) {
  .site-search {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .site-search-dropdown {
    width: 92vw;
    right: -2.5rem;
  }
}
