/* Docs toolbar styles */

.docs-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  /* 6px vertical + 36px buttons = 48px bar (--toolbar-height), matching
     pika's topbar density. */
  padding: 0.375rem 0.5rem;
  margin-left: calc(-1 * var(--body-px));
  margin-right: calc(-1 * var(--body-px));
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  transition: opacity 0.2s ease;
}

@media (min-width: 769px) {
  body.docs-page .docs-toolbar {
    margin-left: 0;
    margin-right: 0;
    padding-left: 1rem;
    transition: margin-left 0.3s ease;
  }

  /* Collapsed: the bar stretches to the viewport's left edge (like the
     notch docs) by cancelling main's centering margin. */
  html.sidebar-collapsed body.docs-page .docs-toolbar {
    margin-left: calc(-1 * max(0px, (100vw - 1100px) / 2));
  }
}


/* "Home" centered in the bar. Absolutely positioned so it stays dead
   center regardless of how many buttons sit in the left slot. */
.toolbar-home-link {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;

  &:hover {
    color: var(--text);
  }
}

/* Hamburger is mobile-only; double class outranks the .toolbar-btn
   display:flex below regardless of load order. */
.toolbar-btn.hamburger {
  display: none;

  @media (max-width: 768px) {
    display: flex;
  }
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  position: relative;
  padding: 0;
  font-size: 1rem;
  transition: background 0.15s ease;

  &:hover {
    background: var(--primary-hover);
  }
}

/* Canonical side-panels toggle, always visible in the toolbar's left
   slot; the icon (inline Lucide SVGs) swaps with the collapse state. */
.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar-toggle .icon-panel-open {
  display: none;
}

html.sidebar-collapsed .sidebar-toggle .icon-panel-close {
  display: none;
}

html.sidebar-collapsed .sidebar-toggle .icon-panel-open {
  display: block;
}

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

/* Theme dropdown */
.theme-btn {
  position: relative;
}

.theme-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 150px;
  margin: 0.25rem 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 60;

  li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: var(--font-size-sm);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;

    &:hover {
      background: var(--primary-hover);
    }

    &.active {
      font-weight: 700;
    }

    i {
      width: 1rem;
      text-align: center;
    }
  }
}

/* Search overlay */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: var(--toolbar-height);
}

.search-container {
  width: 100%;
  max-width: 560px;
  margin: 0 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-muted);
  border-radius: 0.5rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-muted);

  kbd {
    flex-shrink: 0;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    background: var(--kbd-bg);
    color: var(--kbd-text);
    border-radius: var(--radius);
  }
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--font-size-base);
  color: var(--text);
  font-family: var(--font-sans);

  &::placeholder {
    color: var(--input-placeholder);
  }
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;

  li {
    border-bottom: 1px solid var(--border-muted);

    &:last-child {
      border-bottom: none;
    }
  }

  a {
    display: block;
    padding: 0.75rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s ease;

    &:hover,
    &.active {
      background: var(--primary-hover);
    }
  }

  .search-result-title {
    font-weight: 600;
    font-size: var(--font-size-base);
    margin-bottom: 0.25rem;
  }

  .search-result-snippet {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    line-height: 1.4;
  }

  mark {
    background: var(--mark-bg);
    color: var(--mark-text);
    border-radius: 2px;
    padding: 0 1px;
  }
}

.search-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.toolbar-project-link {
  margin-left: auto;
  text-decoration: none;
}
