/**
 * Wiki Navigation Styles
 * Collapsible sidebar with independent scroll
 */

/* ===== Navigation Container ===== */
.wiki-navigation {
  position: fixed;
  top: 80px; /* Height of header + padding */
  left: 0;
  width: 260px;
  height: calc(100vh - 80px);
  background: #18181b;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
  z-index: 90;
}

/* Custom Scrollbar */
.wiki-navigation::-webkit-scrollbar {
  width: 6px;
}

.wiki-navigation::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.wiki-navigation::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.wiki-navigation::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Main Content Offset */
.wiki-main-content {
  margin-left: 260px;
  padding: 20px 40px;
  max-width: calc(100% - 260px);
  min-height: 100vh;
}

/* ===== Navigation Header ===== */
.nav-header {
  padding: 0 16px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 0;
}

.nav-logo img {
  height: 32px;
  width: auto;
}

.nav-home {
  display: flex;
  align-items: center;
  padding: 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #e4e4e7;
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav-home:hover {
  color: #7c3aed;
}

/* ===== Search Box ===== */
.wiki-search {
  padding: 0 16px 16px 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.wiki-search .search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: #71717a;
  pointer-events: none;
  z-index: 1;
  margin-top: -8px;
}

.wiki-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #e4e4e7;
  font-size: 14px;
  transition: all 0.2s ease;
}

.wiki-search input::placeholder {
  color: #71717a;
}

.wiki-search input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.wiki-search input:focus + .search-icon,
.wiki-search:focus-within .search-icon {
  color: #7c3aed;
}

/* ===== Category Section ===== */
.nav-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-section:last-child {
  border-bottom: none;
}

/* Category Button */
.nav-category {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: #e4e4e7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: inherit;
}

.nav-category:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #d4d4d8;
}

.nav-category:focus {
  outline: 2px solid #7c3aed;
  outline-offset: -2px;
}

/* Expand Icon */
.expand-icon {
  display: inline-block;
  width: 16px;
  font-size: 10px;
  color: #71717a;
  transition: transform 0.2s ease;
  margin-right: 8px;
  flex-shrink: 0;
}

.nav-category[aria-expanded="true"] .expand-icon {
  transform: rotate(90deg);
}

/* Articles Container */
.nav-articles {
  display: none;
  flex-direction: column;
  margin-top: 4px;
}

.nav-articles.expanded {
  display: flex;
}

/* Individual Article Link */
.nav-article {
  display: block;
  padding: 8px 16px 8px 40px; /* Indented */
  font-size: 14px;
  color: #a1a1aa;
  text-decoration: none;
  line-height: 1.5;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-article:hover {
  color: #d4d4d8;
  background: rgba(255, 255, 255, 0.05);
}

.nav-article:focus {
  outline: 2px solid #7c3aed;
  outline-offset: -2px;
}

/* Active Article */
.nav-article.active {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.1);
  border-left-color: #7c3aed;
  font-weight: 600;
}

/* ===== Mobile Styles ===== */
@media (max-width: 767px) {
  .wiki-navigation {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100vh;
    transition: left 0.3s ease;
    z-index: 1000;
    padding-top: 80px; /* Space for close button */
  }

  .wiki-navigation.open {
    left: 0;
  }

  .wiki-main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 20px;
  }

  /* Mobile Toggle Button */
  .nav-toggle {
    position: fixed;
    top: 80px;
    left: 16px;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #7c3aed;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }

  .nav-toggle:hover {
    background: #6d28d9;
    transform: scale(1.05);
  }

  .nav-toggle:active {
    transform: scale(0.95);
  }

  /* Overlay when menu open */
  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .nav-overlay.visible {
    opacity: 1;
    pointer-events: all;
  }

  /* Close button in mobile menu */
  .nav-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #e4e4e7;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .nav-close:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}

@media (min-width: 768px) {
  .nav-toggle {
    display: none;
  }

  .nav-overlay {
    display: none;
  }

  .nav-close {
    display: none;
  }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
  .wiki-navigation {
    width: 240px;
  }

  .wiki-main-content {
    margin-left: 240px;
    max-width: calc(100% - 240px);
  }

  .nav-category {
    font-size: 13px;
    padding: 10px 12px;
  }

  .nav-article {
    font-size: 13px;
    padding: 7px 12px 7px 32px;
  }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  .wiki-navigation,
  .nav-category,
  .nav-article,
  .expand-icon,
  .nav-overlay,
  .nav-toggle {
    transition: none;
  }
}

/* Focus visible for keyboard navigation */
.nav-category:focus-visible,
.nav-article:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
  .wiki-navigation,
  .nav-toggle,
  .nav-overlay {
    display: none;
  }

  .wiki-main-content {
    margin-left: 0;
    max-width: 100%;
  }
}
