/* ============================================
   Layout Styles
   头部导航 & 页面布局
   ============================================ */

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: var(--z-sticky);
  background: var(--header-bg, rgba(10, 10, 26, 0.85));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  transition: all var(--transition-base);
}

.site-header.scrolled {
  background: var(--header-bg-scrolled, rgba(10, 10, 26, 0.95));
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--text-white);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.logo:hover {
  color: var(--text-white);
  transform: scale(1.02);
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  font-size: 20px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-name {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Theme Toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  margin-left: var(--space-2);
}

.theme-toggle:hover {
  color: var(--color-primary-light);
  background: var(--bg-glass-hover);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

/* Navigation */
.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.nav-link.active {
  color: var(--color-primary-light);
  background: rgba(99, 102, 241, 0.1);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

.nav-link svg {
  width: 18px;
  height: 18px;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

/* ---------- Main Layout ---------- */
.site-main {
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Layout with sidebar */
.layout-with-sidebar {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

.layout-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border-glass);
  background: var(--sidebar-bg, rgba(10, 10, 26, 0.5));
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  transition: transform var(--transition-base), background-color 0.3s ease;
}

.layout-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-10) var(--space-10);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border-glass);
  background: var(--bg-secondary);
  padding: var(--space-10) 0;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-text {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.footer-links {
  display: flex;
  gap: var(--space-4);
}

.footer-links a {
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text-primary);
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--mobile-menu-bg, rgba(10, 10, 26, 0.98));
    backdrop-filter: blur(16px);
    flex-direction: column;
    padding: var(--space-6);
    gap: var(--space-2);
    z-index: var(--z-overlay);
    animation: fadeInDown 0.3s ease;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    padding: var(--space-4);
    font-size: var(--text-base);
  }

  .layout-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: var(--z-overlay);
    transform: translateX(-100%);
    background: var(--bg-primary);
  }

  .layout-sidebar.open {
    transform: translateX(0);
  }

  .layout-content {
    padding: var(--space-6) var(--space-4);
  }

  .footer-inner {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}

/* ---------- Light Theme Layout Overrides ---------- */
[data-theme="light"] {
  --header-bg: rgba(248, 250, 252, 0.88);
  --header-bg-scrolled: rgba(248, 250, 252, 0.96);
  --sidebar-bg: rgba(241, 245, 249, 0.7);
  --mobile-menu-bg: rgba(248, 250, 252, 0.98);
}
