/* ── Header container ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ── Inner wrapper (flex container) ── */
.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  height: 64px;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 12px;
}

/* ── Logo (always visible) ── */
.header-logo {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-right: auto;
}

.header-logo img {
  display: block;
  height: 36px;
  width: auto;
}

/* ── Hamburger menu toggle (mobile only) ── */
.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
}

/* ── Main navigation (mobile sidebar) ── */
.nav-menu {
  position: fixed;
  top: 64px;
  right: 0;
  z-index: 2000;
  width: 240px;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0 24px;
  background: var(--surface-el);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease, top 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.header-inner:has(.search-form.is-active) .nav-menu {
  top: 120px;
  height: calc(100vh - 120px);
  height: calc(100dvh - 120px);
}

.nav-menu::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.nav-menu.is-active {
  transform: translateX(0);
}

.nav-menu.is-active::before {
  opacity: 1;
  pointer-events: auto;
}

.nav-menu-item {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 24px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-left: 3px solid transparent;
  border-radius: 0;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-menu-item:hover {
  color: var(--text-primary);
  background: var(--accent-muted);
  border-left-color: var(--accent);
}

.nav-menu-form {
  display: contents;
}

.nav-menu-item--logout {
  width: 100%;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  padding: 0 24px;
  height: 48px;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-menu-item--logout:hover {
  color: var(--text-primary);
  background: var(--accent-muted);
  border-left-color: var(--accent);
}

/* ── Search toggle button (mobile only) ── */
.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
}

.search-toggle:hover {
  color: var(--accent);
}

/* ── Search form ── */
.search-form {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-form.is-active {
  max-height: 64px;
}

.search-input-group {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 12px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  background: var(--surface-el);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  display: none;
}

.search-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  background: var(--accent);
  border: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.search-submit:hover {
  background: var(--accent-hover);
}

/* ── Desktop (768px+) ── */
@media (min-width: 768px) {
  .header-inner {
    height: 80px;
    padding: 0 24px;
    gap: 16px;
    justify-content: space-between;
  }

  .header-logo {
    margin-right: 0;
  }

  .header-logo img {
    height: 44px;
  }

  .menu-toggle {
    display: none;
  }

  .nav-menu {
    position: static;
    transform: none;
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    border-left: none;
    overflow: visible;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }

  .nav-menu::before {
    display: none;
  }

  .nav-menu-item {
    height: 44px;
    padding: 0 14px;
    font-size: 14px;
    border-left: none;
    border-radius: var(--r-sm);
    transition: color 0.2s ease, background 0.2s ease;
  }

  .nav-menu-item:hover {
    border-left-color: transparent;
    background: var(--accent-muted);
  }

  .nav-menu-item--logout {
    width: auto;
    height: 44px;
    padding: 0 14px;
    font-size: 14px;
    border-left: none;
    border-radius: var(--r-sm);
  }

  .nav-menu-item--logout:hover {
    border-left-color: transparent;
    background: var(--accent-muted);
  }

  .search-toggle {
    display: none;
  }

  .search-form {
    position: static;
    max-height: none;
    overflow: visible;
    width: 240px;
    background: transparent;
    border-bottom: none;
  }

  .search-form.is-active {
    max-height: none;
  }

  .search-input-group {
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    transition: border-color 0.2s ease;
  }

  .search-input-group:focus-within {
    border-color: var(--accent);
  }

  .search-input {
    border: none;
    background: transparent;
    height: 40px;
  }
}

/* ── Large desktop (1024px+) ── */
@media (min-width: 1024px) {
  .header-inner {
    padding: 0 32px;
  }

  .nav-menu {
    gap: 8px;
  }
}